X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=clients%2Fexecute.cc;h=47319778e868b7b51efff6b40dffd9acdae552fa;hb=32eebdc2e1ae14f41bb15e212036b772760a3fd1;hp=f877851e8adb50743779f0cee7844af535df3f1d;hpb=a2d3699da26720a399bd7f563ccdbccf26e610c5;p=awesomized%2Flibmemcached diff --git a/clients/execute.cc b/clients/execute.cc index f877851e..47319778 100644 --- a/clients/execute.cc +++ b/clients/execute.cc @@ -1,4 +1,5 @@ /* LibMemcached + * Copyright (C) 2011-2012 Data Differential, http://datadifferential.com/ * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * @@ -14,36 +15,32 @@ Return the number of rows set. */ -#include +#include #include "clients/execute.h" unsigned int execute_set(memcached_st *memc, pairs_st *pairs, unsigned int number_of) { - unsigned int x; - unsigned int pairs_sent; - - for (x= 0, pairs_sent= 0; x < number_of; x++) + uint32_t count= 0; + for (; count < number_of; ++count) { - memcached_return_t rc= memcached_set(memc, pairs[x].key, pairs[x].key_length, - pairs[x].value, pairs[x].value_length, + memcached_return_t rc= memcached_set(memc, pairs[count].key, pairs[count].key_length, + pairs[count].value, pairs[count].value_length, 0, 0); if (memcached_failed(rc)) { - fprintf(stderr, "%s:%d Failure on insert (%s) of %.*s\n", - __FILE__, __LINE__, + fprintf(stderr, "%s:%d Failure on %u insert (%s) of %.*s\n", + __FILE__, __LINE__, count, memcached_last_error_message(memc), - (unsigned int)pairs[x].key_length, pairs[x].key); + (unsigned int)pairs[count].key_length, pairs[count].key); // We will try to reconnect and see if that fixes the issue memcached_quit(memc); - } - else - { - pairs_sent++; + + return count; } } - return pairs_sent; + return count; } /*