X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fstats.c;h=ff5416d4a5aef48a2c41d97d1e9af684b5021108;hb=09ef521d2c88955d04d6c91f7b5a1671a1955130;hp=a47b28205623d46061ad77fbf994b4ca76e1167a;hpb=c7f0791996a3814f4de76ba933890264a63feb99;p=m6w6%2Flibmemcached diff --git a/libmemcached/stats.c b/libmemcached/stats.c index a47b2820..ff5416d4 100644 --- a/libmemcached/stats.c +++ b/libmemcached/stats.c @@ -151,7 +151,8 @@ static memcached_return_t set_data(memcached_stat_st *memc_stat, char *key, char strcmp("listen_disabled_num", key) == 0 || strcmp("conn_yields", key) == 0 || strcmp("auth_cmds", key) == 0 || - strcmp("auth_errors", key) == 0)) + strcmp("auth_errors", key) == 0 || + strcmp("reclaimed", key) == 0)) { WATCHPOINT_STRING(key); return MEMCACHED_UNKNOWN_STAT_KEY; @@ -160,7 +161,7 @@ static memcached_return_t set_data(memcached_stat_st *memc_stat, char *key, char return MEMCACHED_SUCCESS; } -char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *memc_stat, +char *memcached_stat_get_value(const memcached_st *ptr, memcached_stat_st *memc_stat, const char *key, memcached_return_t *error) { char buffer[SMALL_STRING_LEN]; @@ -228,7 +229,7 @@ char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *memc_stat, static memcached_return_t binary_stats_fetch(memcached_stat_st *memc_stat, char *args, - memcached_server_instance_st *instance) + memcached_server_write_instance_st instance) { memcached_return_t rc; @@ -249,9 +250,13 @@ static memcached_return_t binary_stats_fetch(memcached_stat_st *memc_stat, request.message.header.request.keylen= htons((uint16_t)len); request.message.header.request.bodylen= htonl((uint32_t) len); - if ((memcached_do(instance, request.bytes, - sizeof(request.bytes), 0) != MEMCACHED_SUCCESS) || - (memcached_io_write(instance, args, len, 1) == -1)) + struct __write_vector_st vector[]= + { + { .length= sizeof(request.bytes), .buffer= request.bytes }, + { .length= len, .buffer= args } + }; + + if (memcached_vdo(instance, vector, 2, true) != MEMCACHED_SUCCESS) { memcached_io_reset(instance); return MEMCACHED_WRITE_FAILURE; @@ -260,7 +265,7 @@ static memcached_return_t binary_stats_fetch(memcached_stat_st *memc_stat, else { if (memcached_do(instance, request.bytes, - sizeof(request.bytes), 1) != MEMCACHED_SUCCESS) + sizeof(request.bytes), true) != MEMCACHED_SUCCESS) { memcached_io_reset(instance); return MEMCACHED_WRITE_FAILURE; @@ -270,8 +275,8 @@ static memcached_return_t binary_stats_fetch(memcached_stat_st *memc_stat, memcached_server_response_decrement(instance); do { - rc= memcached_response(instance, buffer, - sizeof(buffer), NULL); + rc= memcached_response(instance, buffer, sizeof(buffer), NULL); + if (rc == MEMCACHED_END) break; @@ -298,7 +303,7 @@ static memcached_return_t binary_stats_fetch(memcached_stat_st *memc_stat, static memcached_return_t ascii_stats_fetch(memcached_stat_st *memc_stat, char *args, - memcached_server_instance_st *instance) + memcached_server_write_instance_st instance) { memcached_return_t rc; char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; @@ -314,7 +319,7 @@ static memcached_return_t ascii_stats_fetch(memcached_stat_st *memc_stat, if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE) return MEMCACHED_WRITE_FAILURE; - rc= memcached_do(instance, buffer, send_length, 1); + rc= memcached_do(instance, buffer, send_length, true); if (rc != MEMCACHED_SUCCESS) goto error; @@ -378,7 +383,7 @@ memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_retur for (uint32_t x= 0; x < memcached_server_count(ptr); x++) { memcached_return_t temp_return; - memcached_server_instance_st *instance; + memcached_server_write_instance_st instance; memcached_stat_st *stat_instance; stat_instance= stats + x; @@ -410,7 +415,9 @@ memcached_return_t memcached_stat_servername(memcached_stat_st *memc_stat, char memcached_return_t rc; memcached_st memc; memcached_st *memc_ptr; - memcached_server_instance_st *instance; + memcached_server_write_instance_st instance; + + memset(memc_stat, 0, sizeof(memcached_stat_st)); memc_ptr= memcached_create(&memc); WATCHPOINT_ASSERT(memc_ptr); @@ -437,19 +444,18 @@ memcached_return_t memcached_stat_servername(memcached_stat_st *memc_stat, char We make a copy of the keys since at some point in the not so distant future we will add support for "found" keys. */ -char ** memcached_stat_get_keys(memcached_st *ptr, +char ** memcached_stat_get_keys(const memcached_st *ptr, memcached_stat_st *memc_stat, memcached_return_t *error) { char **list; size_t length= sizeof(memcached_stat_keys); - list= libmemcached_malloc(memc_stat && memc_stat->root - ? memc_stat->root - : ptr, - length); + (void)memc_stat; + + list= libmemcached_malloc(ptr, length); - if (!list) + if (! list) { *error= MEMCACHED_MEMORY_ALLOCATION_FAILURE; return NULL; @@ -462,7 +468,7 @@ char ** memcached_stat_get_keys(memcached_st *ptr, return list; } -void memcached_stat_free(memcached_st *ptr, memcached_stat_st *memc_stat) +void memcached_stat_free(const memcached_st *ptr, memcached_stat_st *memc_stat) { if (memc_stat == NULL) {