Just clean up a call (use the previous method).
[m6w6/libmemcached] / libmemcached / delete.c
index 7fd1f2aa307c1837521fbb6b8fa41ad0b54fca42..c83ea5e6f3846754b261f707059860cb99e94903 100644 (file)
@@ -158,9 +158,9 @@ static inline memcached_return_t binary_delete(memcached_st *ptr,
     request.message.header.request.opcode= PROTOCOL_BINARY_CMD_DELETEQ;
   else
     request.message.header.request.opcode= PROTOCOL_BINARY_CMD_DELETE;
-  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.datatype= PROTOCOL_BINARY_RAW_BYTES;
-  request.message.header.request.bodylen= htonl((uint32_t) key_length);
+  request.message.header.request.bodylen= htonl((uint32_t)(key_length + ptr->prefix_key_length));
 
   if (ptr->flags.use_udp && ! flush)
   {
@@ -173,13 +173,12 @@ static inline memcached_return_t binary_delete(memcached_st *ptr,
 
   memcached_return_t rc= MEMCACHED_SUCCESS;
 
-  if ((memcached_do(instance, request.bytes,
-                    sizeof(request.bytes), false) != MEMCACHED_SUCCESS) ||
-      (memcached_io_write(instance, key,
-                          key_length, flush) == -1))
+  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, flush) == -1))
   {
     memcached_io_reset(instance);
-    rc= MEMCACHED_WRITE_FAILURE;
+    rc= (rc == MEMCACHED_SUCCESS) ? MEMCACHED_WRITE_FAILURE : rc;
   }
 
   unlikely (ptr->number_of_replicas > 0)