Merge in dead UDP code.
[m6w6/libmemcached] / libmemcached / auto.cc
index 174f2623001dd47df60b82383ac7f755b2e2ddf7..28550a18c1e73940a36523122fde7d416d002770 100644 (file)
@@ -53,8 +53,9 @@ static memcached_return_t text_incr_decr(memcached_server_write_instance_st inst
                                memcached_literal_param("snprintf(MEMCACHED_DEFAULT_COMMAND_SIZE)"));
   }
 
-  struct libmemcached_io_vector_st vector[]=
+  libmemcached_io_vector_st vector[]=
   {
+    { NULL, 0 },
     { memcached_literal_param("incr ") },
     { memcached_array_string(instance->root->_namespace), memcached_array_size(instance->root->_namespace) },
     { key, key_length },
@@ -65,10 +66,10 @@ static memcached_return_t text_incr_decr(memcached_server_write_instance_st inst
 
   if (is_incr == false)
   {
-    vector[0].buffer= "decr ";
+    vector[1].buffer= "decr ";
   }
 
-  memcached_return_t rc= memcached_vdo(instance, vector, 6, true);
+  memcached_return_t rc= memcached_vdo(instance, vector, 7, true);
 
   if (reply == false)
   {
@@ -119,15 +120,16 @@ static memcached_return_t binary_incr_decr(memcached_server_write_instance_st in
   request.message.body.initial= memcached_htonll(initial);
   request.message.body.expiration= htonl((uint32_t) expiration);
 
-  struct libmemcached_io_vector_st vector[]=
+  libmemcached_io_vector_st vector[]=
   {
+    { NULL, 0 },
     { request.bytes, sizeof(request.bytes) },
     { memcached_array_string(instance->root->_namespace), memcached_array_size(instance->root->_namespace) },
     { key, key_length }
   };
 
   memcached_return_t rc;
-  if (memcached_failed(rc= memcached_vdo(instance, vector, 3, true)))
+  if (memcached_failed(rc= memcached_vdo(instance, vector, 4, true)))
   {
     memcached_io_reset(instance);
     return MEMCACHED_WRITE_FAILURE;
@@ -170,7 +172,7 @@ memcached_return_t memcached_increment_by_key(memcached_st *ptr,
     value= &local_value;
   }
 
-  if (memcached_failed(rc= initialize_query(ptr)))
+  if (memcached_failed(rc= initialize_query(ptr, true)))
   {
     return rc;
   }
@@ -222,7 +224,7 @@ memcached_return_t memcached_decrement_by_key(memcached_st *ptr,
   }
 
   memcached_return_t rc;
-  if (memcached_failed(rc= initialize_query(ptr)))
+  if (memcached_failed(rc= initialize_query(ptr, true)))
   {
     return rc;
   }
@@ -287,7 +289,7 @@ memcached_return_t memcached_increment_with_initial_by_key(memcached_st *ptr,
   }
 
   memcached_return_t rc;
-  if (memcached_failed(rc= initialize_query(ptr)))
+  if (memcached_failed(rc= initialize_query(ptr, true)))
   {
     return rc;
   }
@@ -313,7 +315,8 @@ memcached_return_t memcached_increment_with_initial_by_key(memcached_st *ptr,
   }
   else
   {
-    rc= MEMCACHED_PROTOCOL_ERROR;
+    rc=  memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT,
+                             memcached_literal_param("memcached_increment_with_initial_by_key() is not supported via the ASCII protocol"));
   }
 
   LIBMEMCACHED_MEMCACHED_INCREMENT_WITH_INITIAL_END();
@@ -351,7 +354,7 @@ memcached_return_t memcached_decrement_with_initial_by_key(memcached_st *ptr,
   }
 
   memcached_return_t rc;
-  if (memcached_failed(rc= initialize_query(ptr)))
+  if (memcached_failed(rc= initialize_query(ptr, true)))
   {
     return rc;
   }
@@ -378,7 +381,8 @@ memcached_return_t memcached_decrement_with_initial_by_key(memcached_st *ptr,
   }
   else
   {
-    rc= MEMCACHED_PROTOCOL_ERROR;
+    rc=  memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT,
+                             memcached_literal_param("memcached_decrement_with_initial_by_key() is not supported via the ASCII protocol"));
   }
 
   LIBMEMCACHED_MEMCACHED_INCREMENT_WITH_INITIAL_END();