Fix for most errors around non-block
authorBrian Aker <brian@tangent.org>
Sun, 16 Nov 2008 02:15:28 +0000 (18:15 -0800)
committerBrian Aker <brian@tangent.org>
Sun, 16 Nov 2008 02:15:28 +0000 (18:15 -0800)
libmemcached/memcached_connect.c
libmemcached/memcached_do.c
libmemcached/memcached_io.c
libmemcached/memcached_storage.c

index 57bce10107255bbef5c00a3506b6fd9c7a2a709d..4cd5219afebabb90689bb6c1fcf6e5a749138cb6 100644 (file)
@@ -234,7 +234,7 @@ test_connect:
             {
               goto handle_retry;
             }
-            else if (error != 1 || fds[0].revents & POLLERR)
+            else if (error != 1 && fds[0].revents & POLLERR)
             {
               ptr->cached_errno= errno;
               WATCHPOINT_ERRNO(ptr->cached_errno);
index 91f7506bc740b306e5e817c20b99143709aaf466..f788582f8d54c91a6996c07b4fd9bcfca367edfc 100644 (file)
@@ -10,7 +10,10 @@ memcached_return memcached_do(memcached_server_st *ptr, const void *command,
   WATCHPOINT_ASSERT(command);
 
   if ((rc= memcached_connect(ptr)) != MEMCACHED_SUCCESS)
+  {
+    WATCHPOINT_ERROR(rc);
     return rc;
+  }
 
   sent_length= memcached_io_write(ptr, command, command_length, with_flush);
 
index 0afcc29eaa4756670c25fa525b48d2fd93049fc1..506dfd7a1013c5f3b9790105830c132c53ec220e 100644 (file)
@@ -225,16 +225,19 @@ memcached_return memcached_io_close(memcached_server_st *ptr)
     return MEMCACHED_SUCCESS;
 
   /* in case of death shutdown to avoid blocking at close() */
-  r= shutdown(ptr->fd, SHUT_RDWR);
+  if (1)
+  {
+    r= shutdown(ptr->fd, SHUT_RDWR);
 
 #ifdef HAVE_DEBUG
-  if (r && errno != ENOTCONN)
-  {
-    WATCHPOINT_NUMBER(ptr->fd);
-    WATCHPOINT_ERRNO(errno);
-    WATCHPOINT_ASSERT(errno);
-  }
+    if (r && errno != ENOTCONN)
+    {
+      WATCHPOINT_NUMBER(ptr->fd);
+      WATCHPOINT_ERRNO(errno);
+      WATCHPOINT_ASSERT(errno);
+    }
 #endif
+  }
 
   r= close(ptr->fd);
 #ifdef HAVE_DEBUG
index 93bc140ae2175341c56c446935f5fa4a2420cee3..770b27d4006a2a46137f89501b642750bce4643e 100644 (file)
@@ -106,10 +106,12 @@ static inline memcached_return memcached_send(memcached_st *ptr,
     goto error;
   }
 
+  /* Send command header */
   rc=  memcached_do(&ptr->hosts[server_key], buffer, write_length, 0);
   if (rc != MEMCACHED_SUCCESS)
     goto error;
 
+  /* Send command body */
   if ((sent_length= memcached_io_write(&ptr->hosts[server_key], value, value_length, 0)) == -1)
   {
     rc= MEMCACHED_WRITE_FAILURE;