X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fauto.c;h=16e65b863a3ad85b4b987d8f596d0e2c3c4eeda4;hb=4767d70bea3e4930081016a15630ac927757962b;hp=c36cd92f4c969ccf0508f89b19d09a75093a1596;hpb=04ef974c23973986d4475e3cb8a876012264e2da;p=awesomized%2Flibmemcached diff --git a/libmemcached/auto.c b/libmemcached/auto.c index c36cd92f..16e65b86 100644 --- a/libmemcached/auto.c +++ b/libmemcached/auto.c @@ -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,20 +108,26 @@ 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); - if ((memcached_do(instance, request.bytes, - sizeof(request.bytes), false) != MEMCACHED_SUCCESS) || - (memcached_io_write(instance, key, key_length, true) == -1)) + struct __write_vector_st vector[]= + { + { .length= ptr->prefix_key_length, .buffer= ptr->prefix_key }, + { .length= key_length, .buffer= key } + }; + + memcached_return_t rc; + if (((rc= memcached_do(instance, request.bytes, sizeof(request.bytes), false)) != MEMCACHED_SUCCESS) || + (memcached_io_writev(instance, vector, 2, true) == -1)) { memcached_io_reset(instance); - return MEMCACHED_WRITE_FAILURE; + return (rc == MEMCACHED_SUCCESS) ? MEMCACHED_WRITE_FAILURE : rc; } if (no_reply)