Merge in support for prefix keys in the binary protoocol.
[m6w6/libmemcached] / libmemcached / auto.c
index d94d26f102ed42c1d3b931f6a952105392776679..b4575f07ac3fee6d90d02b96f33432ecd0a9b3a4 100644 (file)
@@ -108,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);