From: Brian Aker Date: Thu, 22 Dec 2011 02:20:28 +0000 (-0800) Subject: Update dump code. X-Git-Tag: 1.0.3~3^2~1^2~26 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=53388ebeb198bd14dcd5ace337cb66922b35e729;p=awesomized%2Flibmemcached Update dump code. --- diff --git a/libmemcached/auto.cc b/libmemcached/auto.cc index 7f8dc9bb..a04ede52 100644 --- a/libmemcached/auto.cc +++ b/libmemcached/auto.cc @@ -59,8 +59,7 @@ static memcached_return_t text_incr_decr(memcached_st *ptr, server_key= memcached_generate_hash_with_redistribution(ptr, group_key, group_key_length); instance= memcached_server_instance_fetch(ptr, server_key); - int send_length; - send_length= snprintf(buffer, sizeof(buffer), " %" PRIu64, offset); + int send_length= snprintf(buffer, sizeof(buffer), " %" PRIu64, offset); if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE || send_length < 0) { return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, diff --git a/libmemcached/dump.cc b/libmemcached/dump.cc index dcbe15b8..603c5560 100644 --- a/libmemcached/dump.cc +++ b/libmemcached/dump.cc @@ -1,3 +1,39 @@ +/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab: + * + * Libmemcached library + * + * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * + * * The names of its contributors may not be used to endorse or + * promote products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + /* We use this to dump all keys. @@ -21,17 +57,21 @@ static memcached_return_t ascii_dump(memcached_st *ptr, memcached_dump_fn *callb for (uint32_t x= 0; x < 256; x++) { char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; - int send_length; - send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, - "stats cachedump %u 0 0\r\n", x); - - if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE || send_length < 0) + int buffer_length= snprintf(buffer, sizeof(buffer), "%u", x); + if (buffer_length >= MEMCACHED_DEFAULT_COMMAND_SIZE or buffer_length < 0) { return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_literal_param("snprintf(MEMCACHED_DEFAULT_COMMAND_SIZE)")); } - rc= memcached_do(instance, buffer, (size_t)send_length, true); + struct libmemcached_io_vector_st vector[]= + { + { memcached_literal_param("stats cachedump ") }, + { buffer, buffer_length }, + { memcached_literal_param(" 0 0\r\n") } + }; + + rc= memcached_vdo(instance, vector, 3, true); if (rc != MEMCACHED_SUCCESS) { @@ -76,7 +116,7 @@ static memcached_return_t ascii_dump(memcached_st *ptr, memcached_dump_fn *callb * This isn't really a fatal error, so let's just skip it. I want to * fix the return value from the memcached server to a CLIENT_ERROR, * so let's add support for that as well right now. - */ + */ rc= MEMCACHED_END; break; }