Fix problem with bumping the command counter _before_ connecting to the server
[awesomized/libmemcached] / libmemcached / delete.c
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)