X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fmemcached_dump.c;h=5872aa40de4b9f953d1ff7492553fa8c4e1605d4;hb=9141e90dccb732d6e7ef10ea248ce2fd7d1ef46b;hp=4899df56feafbea3eae51209d0c97b69f02a0cc3;hpb=ad1dda861388a32864c435eaa139a72bc61298f3;p=awesomized%2Flibmemcached diff --git a/libmemcached/memcached_dump.c b/libmemcached/memcached_dump.c index 4899df56..5872aa40 100644 --- a/libmemcached/memcached_dump.c +++ b/libmemcached/memcached_dump.c @@ -9,7 +9,7 @@ #include "common.h" static memcached_return ascii_dump(memcached_st *ptr, memcached_dump_func *callback, void *context, uint32_t number_of_callbacks) { - memcached_return rc; + memcached_return rc= 0; char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; size_t send_length; uint32_t server_key; @@ -23,8 +23,8 @@ static memcached_return ascii_dump(memcached_st *ptr, memcached_dump_func *callb /* 256 I BELIEVE is the upper limit of slabs */ for (x= 0; x < 256; x++) { - send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, - "stats cachedump %u 0 0\r\n", x); + send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, + "stats cachedump %u 0 0\r\n", x); rc= memcached_do(&ptr->hosts[server_key], buffer, send_length, 1); @@ -55,6 +55,18 @@ static memcached_return ascii_dump(memcached_st *ptr, memcached_dump_func *callb } else if (rc == MEMCACHED_END) break; + else if (rc == MEMCACHED_SERVER_ERROR || rc == MEMCACHED_CLIENT_ERROR) + { + /* If we try to request stats cachedump for a slab class that is too big + * the server will return an incorrect error message: + * "MEMCACHED_SERVER_ERROR failed to allocate memory" + * 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; + } else goto error; }