Added support for two part shutdown of socket.
[m6w6/libmemcached] / libmemcached / auto.cc
index 3054368bc965d7f1fb80205a5a16adb07742f66f..f9f84d7b699a1cc53d07a69a771c0c6624c970ea 100644 (file)
@@ -37,7 +37,7 @@
 
 #include <libmemcached/common.h>
 
-static void auto_response(memcached_server_write_instance_st instance, const bool reply,  memcached_return_t& rc, uint64_t* value)
+static void auto_response(org::libmemcached::Instance* instance, const bool reply,  memcached_return_t& rc, uint64_t* value)
 {
   // If the message was successfully sent, then get the response, otherwise
   // fail.
@@ -52,17 +52,19 @@ static void auto_response(memcached_server_write_instance_st instance, const boo
     rc= memcached_response(instance, &instance->root->result);
   }
 
-  if (memcached_success(rc))
+  if (memcached_fatal(rc))
   {
-    *value= instance->root->result.numeric_value;
+    fprintf(stderr, "%s\n", memcached_strerror(NULL, rc));
+    assert(memcached_last_error(instance->root) != MEMCACHED_SUCCESS);
+    *value= UINT64_MAX;
   }
   else
   {
-    *value= UINT64_MAX;
+    *value= instance->root->result.numeric_value;
   }
 }
 
-static memcached_return_t text_incr_decr(memcached_server_write_instance_st instance,
+static memcached_return_t text_incr_decr(org::libmemcached::Instance* instance,
                                          const bool is_incr,
                                          const char *key, size_t key_length,
                                          const uint64_t offset,
@@ -83,7 +85,7 @@ static memcached_return_t text_incr_decr(memcached_server_write_instance_st inst
     { memcached_literal_param("incr ") },
     { memcached_array_string(instance->root->_namespace), memcached_array_size(instance->root->_namespace) },
     { key, key_length },
-    { buffer, send_length },
+    { buffer, size_t(send_length) },
     { " noreply", reply ? 0 : memcached_literal_param_size(" noreply") },
     { memcached_literal_param("\r\n") }
   };
@@ -96,7 +98,7 @@ static memcached_return_t text_incr_decr(memcached_server_write_instance_st inst
   return memcached_vdo(instance, vector, 7, true);
 }
 
-static memcached_return_t binary_incr_decr(memcached_server_write_instance_st instance,
+static memcached_return_t binary_incr_decr(org::libmemcached::Instance* instance,
                                            protocol_binary_command cmd,
                                            const char *key, const size_t key_length,
                                            const uint64_t offset,
@@ -179,7 +181,7 @@ static memcached_return_t increment_decrement_by_key(const protocol_binary_comma
   }
 
   uint32_t server_key= memcached_generate_hash_with_redistribution(memc, group_key, group_key_length);
-  memcached_server_write_instance_st instance= memcached_server_instance_fetch(memc, server_key);
+  org::libmemcached::Instance* instance= memcached_instance_fetch(memc, server_key);
 
   bool reply= memcached_is_replying(instance->root);
 
@@ -238,7 +240,7 @@ static memcached_return_t increment_decrement_with_initial_by_key(const protocol
   }
 
   uint32_t server_key= memcached_generate_hash_with_redistribution(memc, group_key, group_key_length);
-  memcached_server_write_instance_st instance= memcached_server_instance_fetch(memc, server_key);
+  org::libmemcached::Instance* instance= memcached_instance_fetch(memc, server_key);
 
   bool reply= memcached_is_replying(instance->root);