X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fauto.c;h=a221144f06a75851e39d2779a1c4cad1ddf09d4e;hb=51e7b091691cb268aead6598c52bebaca31c5777;hp=16e65b863a3ad85b4b987d8f596d0e2c3c4eeda4;hpb=4767d70bea3e4930081016a15630ac927757962b;p=awesomized%2Flibmemcached diff --git a/libmemcached/auto.c b/libmemcached/auto.c index 16e65b86..a221144f 100644 --- a/libmemcached/auto.c +++ b/libmemcached/auto.c @@ -18,7 +18,6 @@ static memcached_return_t text_incr_decr(memcached_st *ptr, uint64_t offset, uint64_t *value) { - size_t send_length; memcached_return_t rc; char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; uint32_t server_key; @@ -34,16 +33,17 @@ static memcached_return_t text_incr_decr(memcached_st *ptr, server_key= memcached_generate_hash_with_redistribution(ptr, master_key, master_key_length); instance= memcached_server_instance_fetch(ptr, server_key); - send_length= (size_t)snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, - "%s %.*s%.*s %" PRIu64 "%s\r\n", verb, - (int)ptr->prefix_key_length, - ptr->prefix_key, - (int)key_length, key, - offset, no_reply ? " noreply" : ""); - unlikely (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE) + int send_length; + send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, + "%s %.*s%.*s %" PRIu64 "%s\r\n", verb, + (int)ptr->prefix_key_length, + ptr->prefix_key, + (int)key_length, key, + offset, no_reply ? " noreply" : ""); + if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE || send_length < 0) return MEMCACHED_WRITE_FAILURE; - rc= memcached_do(instance, buffer, send_length, true); + rc= memcached_do(instance, buffer, (size_t)send_length, true); if (no_reply || rc != MEMCACHED_SUCCESS) return rc; @@ -60,7 +60,7 @@ static memcached_return_t text_incr_decr(memcached_st *ptr, { *value= 0; rc= MEMCACHED_PROTOCOL_ERROR; - } + } else if (! strncmp(buffer, "CLIENT_ERROR\r\n", 14)) { *value= 0; @@ -116,15 +116,15 @@ static memcached_return_t binary_incr_decr(memcached_st *ptr, uint8_t cmd, request.message.body.initial= htonll(initial); request.message.body.expiration= htonl((uint32_t) expiration); - struct __write_vector_st vector[]= + struct libmemcached_io_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_do(instance, request.bytes, sizeof(request.bytes), false)) != MEMCACHED_SUCCESS) || - (memcached_io_writev(instance, vector, 2, true) == -1)) + if ((rc= memcached_vdo(instance, vector, 3, true)) != MEMCACHED_SUCCESS) { memcached_io_reset(instance); return (rc == MEMCACHED_SUCCESS) ? MEMCACHED_WRITE_FAILURE : rc;