X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fauto.c;h=b73425f08c2f10320dc3d8c78e40336f78fb22e6;hb=09ef521d2c88955d04d6c91f7b5a1671a1955130;hp=c36cd92f4c969ccf0508f89b19d09a75093a1596;hpb=04ef974c23973986d4475e3cb8a876012264e2da;p=m6w6%2Flibmemcached diff --git a/libmemcached/auto.c b/libmemcached/auto.c index c36cd92f..b73425f0 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= sizeof(request.bytes), .buffer= request.bytes }, + { .length= ptr->prefix_key_length, .buffer= ptr->prefix_key }, + { .length= key_length, .buffer= key } + }; + + memcached_return_t rc; + if ((rc= memcached_vdo(instance, vector, 3, true)) != MEMCACHED_SUCCESS) { memcached_io_reset(instance); - return MEMCACHED_WRITE_FAILURE; + return (rc == MEMCACHED_SUCCESS) ? MEMCACHED_WRITE_FAILURE : rc; } if (no_reply)