X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fdump.cc;h=f74f3ed1f564ce22fb53bdb09478ac5bf210a168;hb=1d0993d84fd87ef620f60380745914bac3e77d34;hp=8a2ba14467d46d71a1f7d5d555f1a1d6794f745b;hpb=e62187d9544abeffaa8552742da6c154fb77cf7c;p=awesomized%2Flibmemcached diff --git a/libmemcached/dump.cc b/libmemcached/dump.cc index 8a2ba144..f74f3ed1 100644 --- a/libmemcached/dump.cc +++ b/libmemcached/dump.cc @@ -44,7 +44,7 @@ #include -static memcached_return_t ascii_dump(memcached_st *memc, memcached_dump_fn *callback, void *context, uint32_t number_of_callbacks) +static memcached_return_t ascii_dump(Memcached *memc, memcached_dump_fn *callback, void *context, uint32_t number_of_callbacks) { /* MAX_NUMBER_OF_SLAB_CLASSES is defined to 200 in Memcached 1.4.10 */ for (uint32_t x= 0; x < 200; x++) @@ -61,14 +61,14 @@ static memcached_return_t ascii_dump(memcached_st *memc, memcached_dump_fn *call libmemcached_io_vector_st vector[]= { { memcached_literal_param("stats cachedump ") }, - { buffer, buffer_length }, + { buffer, size_t(buffer_length) }, { memcached_literal_param(" 0\r\n") } }; // Send message to all servers for (uint32_t server_key= 0; server_key < memcached_server_count(memc); server_key++) { - memcached_server_write_instance_st instance= memcached_server_instance_fetch(memc, server_key); + memcached_instance_st* instance= memcached_instance_fetch(memc, server_key); memcached_return_t vdo_rc; if (memcached_success((vdo_rc= memcached_vdo(instance, vector, 3, true)))) @@ -82,8 +82,9 @@ static memcached_return_t ascii_dump(memcached_st *memc, memcached_dump_fn *call } // Collect the returned items - memcached_server_write_instance_st instance; - while ((instance= memcached_io_get_readable_server(memc))) + memcached_instance_st* instance; + memcached_return_t read_ret= MEMCACHED_SUCCESS; + while ((instance= memcached_io_get_readable_server(memc, read_ret))) { memcached_return_t response_rc= memcached_response(instance, buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, NULL); if (response_rc == MEMCACHED_ITEM) @@ -113,7 +114,7 @@ static memcached_return_t ascii_dump(memcached_st *memc, memcached_dump_fn *call { // All items have been returned } - else if (response_rc == MEMCACHED_SERVER_ERROR or response_rc == MEMCACHED_CLIENT_ERROR or response_rc == MEMCACHED_ERROR) + else if (response_rc == MEMCACHED_SERVER_ERROR) { /* If we try to request stats cachedump for a slab class that is too big * the server will return an incorrect error message: @@ -125,6 +126,18 @@ static memcached_return_t ascii_dump(memcached_st *memc, memcached_dump_fn *call assert(response_rc == MEMCACHED_SUCCESS); // Just fail return response_rc; } + else if (response_rc == MEMCACHED_CLIENT_ERROR) + { + /* The maximum number of slabs has changed in the past (currently 1<<6-1), + * so ignore any client errors complaining about an illegal slab id. + */ + if (0 == strncmp(buffer, "CLIENT_ERROR Illegal slab id", sizeof("CLIENT_ERROR Illegal slab id") - 1)) { + memcached_error_free(*instance); + memcached_error_free(*memc); + } else { + return response_rc; + } + } else { // IO error of some sort must have occurred @@ -136,8 +149,9 @@ static memcached_return_t ascii_dump(memcached_st *memc, memcached_dump_fn *call return memcached_has_current_error(*memc) ? MEMCACHED_SOME_ERRORS : MEMCACHED_SUCCESS; } -memcached_return_t memcached_dump(memcached_st *ptr, memcached_dump_fn *callback, void *context, uint32_t number_of_callbacks) +memcached_return_t memcached_dump(memcached_st *shell, memcached_dump_fn *callback, void *context, uint32_t number_of_callbacks) { + Memcached* ptr= memcached2Memcached(shell); memcached_return_t rc; if (memcached_failed(rc= initialize_query(ptr, true))) {