Fix problem with bumping the command counter _before_ connecting to the server
authorTrond Norbye <tn202803@atum03>
Fri, 18 Dec 2009 12:07:20 +0000 (13:07 +0100)
committerTrond Norbye <tn202803@atum03>
Fri, 18 Dec 2009 12:07:20 +0000 (13:07 +0100)
libmemcached/connect.c
libmemcached/delete.c

index 96f26fb80e07f6116435eb4ef9259f4d9db14134..e58e37fc1bcc7746dadcff00828d5d50ea92d3db 100644 (file)
@@ -208,6 +208,8 @@ static memcached_return_t network_connect(memcached_server_st *ptr)
   {
     struct addrinfo *use;
 
+    WATCHPOINT_ASSERT(ptr->cursor_active == 0);
+
     if (!ptr->sockaddr_inited ||
         (!(ptr->root->flags.use_cache_lookups)))
     {
@@ -282,7 +284,6 @@ static memcached_return_t network_connect(memcached_server_st *ptr)
 
       if (ptr->fd != -1)
       {
-        WATCHPOINT_ASSERT(ptr->cursor_active == 0);
         ptr->server_failure_counter= 0;
         return MEMCACHED_SUCCESS;
       }
index bbdd2527bf7945b686242b3d84c5dc1e90dbb783..8250d58e0d21c210ce14efa136b4c60365b3cd2f 100644 (file)
@@ -59,6 +59,14 @@ memcached_return_t memcached_delete_by_key(memcached_st *ptr,
        }
        else
        {
+          /* ensure that we are connected, otherwise we might bump the
+           * command counter before connection */
+          if ((rc= memcached_connect(&ptr->hosts[server_key])) != MEMCACHED_SUCCESS)
+          {
+            WATCHPOINT_ERROR(rc);
+            return rc;
+          }
+
           if (ptr->hosts[server_key].minor_version == 0)
           {
              if (no_reply || !to_write)