Preserve errno for write failures
authorRobey Pointer <robey@twitter.com>
Thu, 26 Feb 2009 08:25:38 +0000 (09:25 +0100)
committerRobey Pointer <robey@twitter.com>
Thu, 26 Feb 2009 08:25:38 +0000 (09:25 +0100)
libmemcached/memcached_io.c

index ffbd680648814690ac5bc683511bf0b7c22758d8..72a02a0f97f52b030b3c1ab45cefa84b742c4bf4 100644 (file)
@@ -338,6 +338,7 @@ static ssize_t io_flush(memcached_server_st *ptr,
       if ((sent_length= write(ptr->fd, local_write_ptr, 
                               write_length)) == -1)
       {
+        ptr->cached_errno= errno;
         switch (errno)
         {
         case ENOBUFS:
@@ -355,7 +356,6 @@ static ssize_t io_flush(memcached_server_st *ptr,
           }
         default:
           memcached_quit_server(ptr, 1);
-          ptr->cached_errno= errno;
           *error= MEMCACHED_ERRNO;
           return -1;
         }