Just clean up a call (use the previous method).
[m6w6/libmemcached] / libmemcached / auto.c
index fde81d47e3da67ceb19265a2d42cb1f203fee8e0..b4575f07ac3fee6d90d02b96f33432ecd0a9b3a4 100644 (file)
@@ -56,7 +56,12 @@ static memcached_return_t text_incr_decr(memcached_st *ptr,
     use it. We still called memcached_response() though since it
     worked its magic for non-blocking IO.
   */
-  if (!strncmp(buffer, "ERROR\r\n", 7))
+  if (! strncmp(buffer, "ERROR\r\n", 7))
+  {
+    *value= 0;
+    rc= MEMCACHED_PROTOCOL_ERROR;
+  } 
+  else if (! strncmp(buffer, "CLIENT_ERROR\r\n", 14))
   {
     *value= 0;
     rc= MEMCACHED_PROTOCOL_ERROR;
@@ -103,17 +108,17 @@ static memcached_return_t binary_incr_decr(memcached_st *ptr, uint8_t cmd,
 
   request.message.header.request.magic= PROTOCOL_BINARY_REQ;
   request.message.header.request.opcode= cmd;
-  request.message.header.request.keylen= htons((uint16_t) key_length);
+  request.message.header.request.keylen= htons((uint16_t)(key_length + ptr->prefix_key_length));
   request.message.header.request.extlen= 20;
   request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES;
-  request.message.header.request.bodylen= htonl((uint32_t) (key_length + request.message.header.request.extlen));
+  request.message.header.request.bodylen= htonl((uint32_t)(key_length + ptr->prefix_key_length +  request.message.header.request.extlen));
   request.message.body.delta= htonll(offset);
   request.message.body.initial= htonll(initial);
   request.message.body.expiration= htonl((uint32_t) expiration);
 
   memcached_return_t rc;
-  if (((rc= memcached_do(instance, request.bytes,
-                         sizeof(request.bytes), false)) != MEMCACHED_SUCCESS) ||
+  if (((rc= memcached_do(instance, request.bytes, sizeof(request.bytes), false)) != MEMCACHED_SUCCESS) ||
+      (memcached_io_write(instance, ptr->prefix_key, ptr->prefix_key_length, false) == -1) ||
       (memcached_io_write(instance, key, key_length, true) == -1))
   {
     memcached_io_reset(instance);