From: Brian Aker Date: Sun, 3 Jan 2010 01:58:40 +0000 (-0800) Subject: Updated stats object to use a root like other structures. X-Git-Tag: 0.37~33 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=0b0a30bb53359a9aff8afff1a45209c4be7b8881;p=awesomized%2Flibmemcached Updated stats object to use a root like other structures. --- diff --git a/libmemcached/internal.h b/libmemcached/internal.h index 3e4415dd..2a151514 100644 --- a/libmemcached/internal.h +++ b/libmemcached/internal.h @@ -1,5 +1,5 @@ /* LibMemcached - * Copyright (C) 2006-2009 Brian Aker + * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See diff --git a/libmemcached/io.h b/libmemcached/io.h index 7aab7bae..af515065 100644 --- a/libmemcached/io.h +++ b/libmemcached/io.h @@ -40,34 +40,43 @@ struct udp_datagram_header_st uint16_t reserved; }; +LIBMEMCACHED_LOCAL ssize_t memcached_io_write(memcached_server_st *ptr, const void *buffer, size_t length, char with_flush); +LIBMEMCACHED_LOCAL void memcached_io_reset(memcached_server_st *ptr); +LIBMEMCACHED_LOCAL memcached_return_t memcached_io_read(memcached_server_st *ptr, void *buffer, size_t length, ssize_t *nread); /* Read a line (terminated by '\n') into the buffer */ +LIBMEMCACHED_LOCAL memcached_return_t memcached_io_readline(memcached_server_st *ptr, char *buffer_ptr, size_t size); +LIBMEMCACHED_LOCAL memcached_return_t memcached_io_close(memcached_server_st *ptr); /* Read n bytes of data from the server and store them in dta */ +LIBMEMCACHED_LOCAL memcached_return_t memcached_safe_read(memcached_server_st *ptr, void *dta, size_t size); /* Read a single response from the server */ +LIBMEMCACHED_LOCAL memcached_return_t memcached_read_one_response(memcached_server_st *ptr, char *buffer, size_t buffer_length, memcached_result_st *result); +LIBMEMCACHED_LOCAL memcached_return_t memcached_io_init_udp_header(memcached_server_st *ptr, uint16_t thread_id); +LIBMEMCACHED_LOCAL memcached_server_st *memcached_io_get_readable_server(memcached_st *memc); #endif /* BUILDING_LIBMEMCACHED */ diff --git a/libmemcached/stats.c b/libmemcached/stats.c index 6b09e604..4f3bdb0d 100644 --- a/libmemcached/stats.c +++ b/libmemcached/stats.c @@ -371,6 +371,8 @@ memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_retur stats= ptr->call_calloc(ptr, ptr->number_of_hosts, sizeof(memcached_stat_st)); + stats->root= ptr; + if (!stats) { *error= MEMCACHED_MEMORY_ALLOCATION_FAILURE; @@ -451,8 +453,16 @@ void memcached_stat_free(memcached_st *ptr, memcached_stat_st *memc_stat) return; } - if (ptr) + if (memc_stat->root) + { + memc_stat->root->call_free(ptr, memc_stat); + } + else if (ptr) + { ptr->call_free(ptr, memc_stat); + } else + { free(memc_stat); + } } diff --git a/libmemcached/stats.h b/libmemcached/stats.h index 79f7e6cf..4b7d48ca 100644 --- a/libmemcached/stats.h +++ b/libmemcached/stats.h @@ -5,7 +5,7 @@ * Use and distribution licensed under the BSD license. See * the COPYING file in the parent directory for full text. * - * Summary: Change the behavior of the memcached connection. + * Summary: Collect up the stats for a memcached server. * */ @@ -41,6 +41,7 @@ struct memcached_stat_st { uint64_t get_misses; uint64_t limit_maxbytes; char version[MEMCACHED_VERSION_STRING_LENGTH]; + memcached_st *root; }; LIBMEMCACHED_API