From 7c7750f02368b570353ea109f23a0ea26d226e02 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Wed, 16 Dec 2009 15:01:10 -0800 Subject: [PATCH] Mass rename to simplify names. Do you know how many times I get annoyed on a daily basis that I can't use tabs on the command line? Yeah... should have done this a while ago. --- libmemcached/Makefile.am | 139 +++++++++--------- .../{memcached_allocators.c => allocators.c} | 0 .../{memcached_analyze.c => analyze.c} | 0 libmemcached/{memcached_auto.c => auto.c} | 0 .../{memcached_behavior.c => behavior.c} | 0 .../{memcached_behavior.h => behavior.h} | 0 .../{memcached_callback.c => callback.c} | 0 .../{memcached_callback.h => callback.h} | 0 libmemcached/common.h | 6 +- .../{memcached_connect.c => connect.c} | 0 .../{memcached_constants.h => constants.h} | 0 libmemcached/{memcached_delete.c => delete.c} | 0 libmemcached/{memcached_do.c => do.c} | 0 libmemcached/{memcached_dump.c => dump.c} | 0 libmemcached/{memcached_fetch.c => fetch.c} | 1 - libmemcached/{memcached_flush.c => flush.c} | 0 ...cached_flush_buffers.c => flush_buffers.c} | 1 - libmemcached/{memcached_get.c => get.c} | 1 - libmemcached/{memcached_get.h => get.h} | 0 libmemcached/{memcached_hash.c => hash.c} | 0 libmemcached/{memcached_hosts.c => hosts.c} | 0 .../{memcached_internal.h => internal.h} | 0 libmemcached/{memcached_io.c => io.c} | 1 - libmemcached/{memcached_io.h => io.h} | 0 libmemcached/{memcached_key.c => key.c} | 0 libmemcached/memcached.h | 19 +-- libmemcached/memcached_util.h | 2 +- libmemcached/{memcached_parse.c => parse.c} | 0 libmemcached/{memcached_pool.h => pool.h} | 0 libmemcached/{memcached_purge.c => purge.c} | 2 - libmemcached/{memcached_quit.c => quit.c} | 0 .../{memcached_response.c => response.c} | 1 - libmemcached/{memcached_result.c => result.c} | 0 libmemcached/{memcached_result.h => result.h} | 0 libmemcached/{memcached_server.c => server.c} | 0 libmemcached/{memcached_server.h => server.h} | 0 libmemcached/{memcached_stats.c => stats.c} | 0 .../{memcached_storage.c => storage.c} | 1 - .../{memcached_storage.h => storage.h} | 2 +- .../{memcached_strerror.c => strerror.c} | 0 libmemcached/{memcached_string.c => string.c} | 0 libmemcached/{memcached_string.h => string.h} | 0 libmemcached/{memcached_types.h => types.h} | 0 .../util/{memcached_pool.c => pool.c} | 85 ++++++----- .../{memcached_verbosity.c => verbosity.c} | 0 .../{memcached_version.c => version.c} | 0 .../{memcached_watchpoint.h => watchpoint.h} | 0 47 files changed, 135 insertions(+), 126 deletions(-) rename libmemcached/{memcached_allocators.c => allocators.c} (100%) rename libmemcached/{memcached_analyze.c => analyze.c} (100%) rename libmemcached/{memcached_auto.c => auto.c} (100%) rename libmemcached/{memcached_behavior.c => behavior.c} (100%) rename libmemcached/{memcached_behavior.h => behavior.h} (100%) rename libmemcached/{memcached_callback.c => callback.c} (100%) rename libmemcached/{memcached_callback.h => callback.h} (100%) rename libmemcached/{memcached_connect.c => connect.c} (100%) rename libmemcached/{memcached_constants.h => constants.h} (100%) rename libmemcached/{memcached_delete.c => delete.c} (100%) rename libmemcached/{memcached_do.c => do.c} (100%) rename libmemcached/{memcached_dump.c => dump.c} (100%) rename libmemcached/{memcached_fetch.c => fetch.c} (99%) rename libmemcached/{memcached_flush.c => flush.c} (100%) rename libmemcached/{memcached_flush_buffers.c => flush_buffers.c} (95%) rename libmemcached/{memcached_get.c => get.c} (99%) rename libmemcached/{memcached_get.h => get.h} (100%) rename libmemcached/{memcached_hash.c => hash.c} (100%) rename libmemcached/{memcached_hosts.c => hosts.c} (100%) rename libmemcached/{memcached_internal.h => internal.h} (100%) rename libmemcached/{memcached_io.c => io.c} (99%) rename libmemcached/{memcached_io.h => io.h} (100%) rename libmemcached/{memcached_key.c => key.c} (100%) rename libmemcached/{memcached_parse.c => parse.c} (100%) rename libmemcached/{memcached_pool.h => pool.h} (100%) rename libmemcached/{memcached_purge.c => purge.c} (97%) rename libmemcached/{memcached_quit.c => quit.c} (100%) rename libmemcached/{memcached_response.c => response.c} (99%) rename libmemcached/{memcached_result.c => result.c} (100%) rename libmemcached/{memcached_result.h => result.h} (100%) rename libmemcached/{memcached_server.c => server.c} (100%) rename libmemcached/{memcached_server.h => server.h} (100%) rename libmemcached/{memcached_stats.c => stats.c} (100%) rename libmemcached/{memcached_storage.c => storage.c} (99%) rename libmemcached/{memcached_storage.h => storage.h} (99%) rename libmemcached/{memcached_strerror.c => strerror.c} (100%) rename libmemcached/{memcached_string.c => string.c} (100%) rename libmemcached/{memcached_string.h => string.h} (100%) rename libmemcached/{memcached_types.h => types.h} (100%) rename libmemcached/util/{memcached_pool.c => pool.c} (78%) rename libmemcached/{memcached_verbosity.c => verbosity.c} (100%) rename libmemcached/{memcached_version.c => version.c} (100%) rename libmemcached/{memcached_watchpoint.h => watchpoint.h} (100%) diff --git a/libmemcached/Makefile.am b/libmemcached/Makefile.am index 80db3505..e85fecb7 100644 --- a/libmemcached/Makefile.am +++ b/libmemcached/Makefile.am @@ -1,91 +1,96 @@ -EXTRA_DIST = libmemcached.ver \ - libmemcached_probes.d \ - memcached/README.txt \ - memcached_configure.h.in \ - protocol/libmemcachedprotocol.ver \ - util/libmemcachedutil.ver +EXTRA_DIST = \ + libmemcached.ver \ + libmemcached_probes.d \ + memcached/README.txt \ + memcached_configure.h.in \ + protocol/libmemcachedprotocol.ver \ + util/libmemcachedutil.ver EXTRA_HEADERS = BUILT_SOURCES= noinst_HEADERS = libmemcached_probes.h \ - memcached_io.h \ - memcached_internal.h \ + io.h \ + internal.h \ common.h \ memcached/protocol_binary.h \ protocol/common.h \ protocol/ascii_handler.h \ protocol/binary_handler.h -pkginclude_HEADERS= memcached.h \ - memcached.hpp \ +pkginclude_HEADERS= \ + behavior.h \ + callback.h \ + constants.h \ exception.hpp \ - memcached_behavior.h \ - memcached_callback.h \ - memcached_configure.h \ - memcached_constants.h \ - memcached_get.h \ - memcached_result.h \ - memcached_server.h \ - memcached_storage.h \ - memcached_string.h \ - memcached_types.h \ - memcached_watchpoint.h \ - protocol_handler.h \ - visibility.h - -nobase_pkginclude_HEADERS=protocol/cache.h \ - protocol/callback.h - - -libmemcachedprotocol_la_SOURCES= protocol/ascii_handler.c \ - protocol/binary_handler.c \ - protocol/cache.c \ - protocol/pedantic.c \ - protocol/protocol_handler.c + get.h \ + memcached.h \ + memcached.hpp \ + memcached_configure.h \ + protocol_handler.h \ + result.h \ + server.h \ + storage.h \ + string.h \ + types.h \ + visibility.h \ + watchpoint.h + +nobase_pkginclude_HEADERS = \ + protocol/cache.h \ + protocol/callback.h + + +libmemcachedprotocol_la_SOURCES = \ + protocol/ascii_handler.c \ + protocol/binary_handler.c \ + protocol/cache.c \ + protocol/pedantic.c \ + protocol/protocol_handler.c libmemcachedprotocol_la_LDFLAGS= ${AM_LDFLAGS} -version-info 0:0:0 lib_LTLIBRARIES = libmemcached.la libmemcachedprotocol.la noinst_LTLIBRARIES = libmemcachedcallbacks.la libmemcachedcallbacks_la_CFLAGS = ${AM_CFLAGS} ${NO_STRICT_ALIASING} -libmemcachedcallbacks_la_SOURCES = memcached_callback.c +libmemcachedcallbacks_la_SOURCES = callback.c libmemcached_la_CFLAGS= ${AM_CFLAGS} ${NO_CONVERSION} -libmemcached_la_SOURCES = crc.c \ - memcached.c \ - memcached_auto.c \ - memcached_analyze.c \ - memcached_behavior.c \ - memcached_connect.c \ - memcached_delete.c \ - memcached_do.c \ - memcached_dump.c \ - memcached_fetch.c \ - memcached_flush.c \ - memcached_get.c \ - memcached_hash.c \ - memcached_hosts.c \ - memcached_io.c \ - memcached_purge.c \ - memcached_flush_buffers.c \ +libmemcached_la_SOURCES = \ + allocators.c \ + analyze.c \ + auto.c \ + behavior.c \ + connect.c \ + crc.c \ + delete.c \ + do.c \ + dump.c \ + fetch.c \ + flush.c \ + flush_buffers.c \ + get.c \ + hash.c \ + hosts.c \ + io.c \ + jenkins_hash.c \ + key.c \ md5.c \ - memcached_key.c \ - memcached_quit.c \ - memcached_parse.c \ - memcached_response.c \ - memcached_result.c \ - memcached_server.c \ - memcached_storage.c \ - memcached_string.c \ - memcached_stats.c \ - memcached_strerror.c \ - memcached_verbosity.c \ - memcached_version.c \ + memcached.c \ murmur_hash.c \ - jenkins_hash.c \ - memcached_allocators.c + parse.c \ + purge.c \ + quit.c \ + response.c \ + result.c \ + server.c \ + stats.c \ + storage.c \ + strerror.c \ + string.c \ + verbosity.c \ + version.c if INCLUDE_HSIEH_SRC @@ -97,11 +102,11 @@ libmemcached_la_LIBADD= $(LIBM) libmemcachedcallbacks.la libmemcached_la_LDFLAGS= ${AM_LDFLAGS} -version-info 3:0:0 if BUILD_LIBMEMCACHEDUTIL -pkginclude_HEADERS+= memcached_util.h memcached_pool.h +pkginclude_HEADERS+= memcached_util.h pool.h lib_LTLIBRARIES+= libmemcachedutil.la endif -libmemcachedutil_la_SOURCES= util/memcached_pool.c +libmemcachedutil_la_SOURCES= util/pool.c libmemcachedutil_la_LIBADD= libmemcached.la libmemcachedutil_la_LDFLAGS= ${AM_LDFLAGS} -version-info 0:0:0 libmemcachedutil_la_DEPENDENCIES=libmemcached.la diff --git a/libmemcached/memcached_allocators.c b/libmemcached/allocators.c similarity index 100% rename from libmemcached/memcached_allocators.c rename to libmemcached/allocators.c diff --git a/libmemcached/memcached_analyze.c b/libmemcached/analyze.c similarity index 100% rename from libmemcached/memcached_analyze.c rename to libmemcached/analyze.c diff --git a/libmemcached/memcached_auto.c b/libmemcached/auto.c similarity index 100% rename from libmemcached/memcached_auto.c rename to libmemcached/auto.c diff --git a/libmemcached/memcached_behavior.c b/libmemcached/behavior.c similarity index 100% rename from libmemcached/memcached_behavior.c rename to libmemcached/behavior.c diff --git a/libmemcached/memcached_behavior.h b/libmemcached/behavior.h similarity index 100% rename from libmemcached/memcached_behavior.h rename to libmemcached/behavior.h diff --git a/libmemcached/memcached_callback.c b/libmemcached/callback.c similarity index 100% rename from libmemcached/memcached_callback.c rename to libmemcached/callback.c diff --git a/libmemcached/memcached_callback.h b/libmemcached/callback.h similarity index 100% rename from libmemcached/memcached_callback.h rename to libmemcached/callback.h diff --git a/libmemcached/common.h b/libmemcached/common.h index 3a08ffca..c9d7cf81 100644 --- a/libmemcached/common.h +++ b/libmemcached/common.h @@ -52,11 +52,11 @@ #include "libmemcached/memcached.h" -#include "libmemcached/memcached_watchpoint.h" +#include "libmemcached/watchpoint.h" /* These are private not to be installed headers */ -#include "libmemcached/memcached_io.h" -#include "libmemcached/memcached_internal.h" +#include "libmemcached/io.h" +#include "libmemcached/internal.h" #include "libmemcached/libmemcached_probes.h" #include "libmemcached/memcached/protocol_binary.h" #include "libmemcached/byteorder.h" diff --git a/libmemcached/memcached_connect.c b/libmemcached/connect.c similarity index 100% rename from libmemcached/memcached_connect.c rename to libmemcached/connect.c diff --git a/libmemcached/memcached_constants.h b/libmemcached/constants.h similarity index 100% rename from libmemcached/memcached_constants.h rename to libmemcached/constants.h diff --git a/libmemcached/memcached_delete.c b/libmemcached/delete.c similarity index 100% rename from libmemcached/memcached_delete.c rename to libmemcached/delete.c diff --git a/libmemcached/memcached_do.c b/libmemcached/do.c similarity index 100% rename from libmemcached/memcached_do.c rename to libmemcached/do.c diff --git a/libmemcached/memcached_dump.c b/libmemcached/dump.c similarity index 100% rename from libmemcached/memcached_dump.c rename to libmemcached/dump.c diff --git a/libmemcached/memcached_fetch.c b/libmemcached/fetch.c similarity index 99% rename from libmemcached/memcached_fetch.c rename to libmemcached/fetch.c index dbb1ff62..7baac544 100644 --- a/libmemcached/memcached_fetch.c +++ b/libmemcached/fetch.c @@ -1,5 +1,4 @@ #include "common.h" -#include "memcached_io.h" char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length, size_t *value_length, diff --git a/libmemcached/memcached_flush.c b/libmemcached/flush.c similarity index 100% rename from libmemcached/memcached_flush.c rename to libmemcached/flush.c diff --git a/libmemcached/memcached_flush_buffers.c b/libmemcached/flush_buffers.c similarity index 95% rename from libmemcached/memcached_flush_buffers.c rename to libmemcached/flush_buffers.c index f001e21e..950fa1e8 100644 --- a/libmemcached/memcached_flush_buffers.c +++ b/libmemcached/flush_buffers.c @@ -1,5 +1,4 @@ #include "common.h" -#include "memcached_io.h" memcached_return_t memcached_flush_buffers(memcached_st *mem) { diff --git a/libmemcached/memcached_get.c b/libmemcached/get.c similarity index 99% rename from libmemcached/memcached_get.c rename to libmemcached/get.c index 27a1410e..30682427 100644 --- a/libmemcached/memcached_get.c +++ b/libmemcached/get.c @@ -10,7 +10,6 @@ */ #include "common.h" -#include "memcached_io.h" /* What happens if no servers exist? diff --git a/libmemcached/memcached_get.h b/libmemcached/get.h similarity index 100% rename from libmemcached/memcached_get.h rename to libmemcached/get.h diff --git a/libmemcached/memcached_hash.c b/libmemcached/hash.c similarity index 100% rename from libmemcached/memcached_hash.c rename to libmemcached/hash.c diff --git a/libmemcached/memcached_hosts.c b/libmemcached/hosts.c similarity index 100% rename from libmemcached/memcached_hosts.c rename to libmemcached/hosts.c diff --git a/libmemcached/memcached_internal.h b/libmemcached/internal.h similarity index 100% rename from libmemcached/memcached_internal.h rename to libmemcached/internal.h diff --git a/libmemcached/memcached_io.c b/libmemcached/io.c similarity index 99% rename from libmemcached/memcached_io.c rename to libmemcached/io.c index fd86437f..8f96bc32 100644 --- a/libmemcached/memcached_io.c +++ b/libmemcached/io.c @@ -11,7 +11,6 @@ #include "common.h" -#include "memcached_io.h" #include #include diff --git a/libmemcached/memcached_io.h b/libmemcached/io.h similarity index 100% rename from libmemcached/memcached_io.h rename to libmemcached/io.h diff --git a/libmemcached/memcached_key.c b/libmemcached/key.c similarity index 100% rename from libmemcached/memcached_key.c rename to libmemcached/key.c diff --git a/libmemcached/memcached.h b/libmemcached/memcached.h index 39158498..efe16e0c 100644 --- a/libmemcached/memcached.h +++ b/libmemcached/memcached.h @@ -25,15 +25,16 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +// Everything above this line must be in the order specified. +#include +#include +#include +#include +#include +#include #ifdef __cplusplus extern "C" { diff --git a/libmemcached/memcached_util.h b/libmemcached/memcached_util.h index f06804b4..c1a719d6 100644 --- a/libmemcached/memcached_util.h +++ b/libmemcached/memcached_util.h @@ -15,6 +15,6 @@ #ifndef MEMCACHED_UTIL_H #define MEMCACHED_UTIL_H -#include +#include #endif /* MEMCACHED_UTIL_H */ diff --git a/libmemcached/memcached_parse.c b/libmemcached/parse.c similarity index 100% rename from libmemcached/memcached_parse.c rename to libmemcached/parse.c diff --git a/libmemcached/memcached_pool.h b/libmemcached/pool.h similarity index 100% rename from libmemcached/memcached_pool.h rename to libmemcached/pool.h diff --git a/libmemcached/memcached_purge.c b/libmemcached/purge.c similarity index 97% rename from libmemcached/memcached_purge.c rename to libmemcached/purge.c index 9042142b..e3f857b4 100644 --- a/libmemcached/memcached_purge.c +++ b/libmemcached/purge.c @@ -1,6 +1,4 @@ #include "common.h" -#include "memcached_io.h" -#include "memcached_constants.h" memcached_return_t memcached_purge(memcached_server_st *ptr) { diff --git a/libmemcached/memcached_quit.c b/libmemcached/quit.c similarity index 100% rename from libmemcached/memcached_quit.c rename to libmemcached/quit.c diff --git a/libmemcached/memcached_response.c b/libmemcached/response.c similarity index 99% rename from libmemcached/memcached_response.c rename to libmemcached/response.c index cb297428..a87ac249 100644 --- a/libmemcached/memcached_response.c +++ b/libmemcached/response.c @@ -6,7 +6,6 @@ */ #include "common.h" -#include "memcached_io.h" static memcached_return_t textual_read_one_response(memcached_server_st *ptr, char *buffer, size_t buffer_length, diff --git a/libmemcached/memcached_result.c b/libmemcached/result.c similarity index 100% rename from libmemcached/memcached_result.c rename to libmemcached/result.c diff --git a/libmemcached/memcached_result.h b/libmemcached/result.h similarity index 100% rename from libmemcached/memcached_result.h rename to libmemcached/result.h diff --git a/libmemcached/memcached_server.c b/libmemcached/server.c similarity index 100% rename from libmemcached/memcached_server.c rename to libmemcached/server.c diff --git a/libmemcached/memcached_server.h b/libmemcached/server.h similarity index 100% rename from libmemcached/memcached_server.h rename to libmemcached/server.h diff --git a/libmemcached/memcached_stats.c b/libmemcached/stats.c similarity index 100% rename from libmemcached/memcached_stats.c rename to libmemcached/stats.c diff --git a/libmemcached/memcached_storage.c b/libmemcached/storage.c similarity index 99% rename from libmemcached/memcached_storage.c rename to libmemcached/storage.c index c6a556f9..5aa1d771 100644 --- a/libmemcached/memcached_storage.c +++ b/libmemcached/storage.c @@ -10,7 +10,6 @@ */ #include "common.h" -#include "memcached_io.h" typedef enum { SET_OP, diff --git a/libmemcached/memcached_storage.h b/libmemcached/storage.h similarity index 99% rename from libmemcached/memcached_storage.h rename to libmemcached/storage.h index d4f4995c..ec982ba0 100644 --- a/libmemcached/memcached_storage.h +++ b/libmemcached/storage.h @@ -12,7 +12,7 @@ #ifndef __MEMCACHED_STORAGE_H__ #define __MEMCACHED_STORAGE_H__ -#include "libmemcached/memcached_types.h" +#include "libmemcached/memcached.h" #ifdef __cplusplus extern "C" { diff --git a/libmemcached/memcached_strerror.c b/libmemcached/strerror.c similarity index 100% rename from libmemcached/memcached_strerror.c rename to libmemcached/strerror.c diff --git a/libmemcached/memcached_string.c b/libmemcached/string.c similarity index 100% rename from libmemcached/memcached_string.c rename to libmemcached/string.c diff --git a/libmemcached/memcached_string.h b/libmemcached/string.h similarity index 100% rename from libmemcached/memcached_string.h rename to libmemcached/string.h diff --git a/libmemcached/memcached_types.h b/libmemcached/types.h similarity index 100% rename from libmemcached/memcached_types.h rename to libmemcached/types.h diff --git a/libmemcached/util/memcached_pool.c b/libmemcached/util/pool.c similarity index 78% rename from libmemcached/util/memcached_pool.c rename to libmemcached/util/pool.c index fac7d2d3..7cb25177 100644 --- a/libmemcached/util/memcached_pool.c +++ b/libmemcached/util/pool.c @@ -1,11 +1,11 @@ /* -*- Mode: C; tab-width: 2; c-basic-offset: 2; indent-tabs-mode: nil -*- */ #include "libmemcached/common.h" -#include "libmemcached/memcached_pool.h" +#include "libmemcached/pool.h" #include #include -struct memcached_pool_st +struct memcached_pool_st { pthread_mutex_t mutex; pthread_cond_t cond; @@ -17,17 +17,18 @@ struct memcached_pool_st char *version; }; -static memcached_return_t mutex_enter(pthread_mutex_t *mutex) +static memcached_return_t mutex_enter(pthread_mutex_t *mutex) { int ret; - do + do ret= pthread_mutex_lock(mutex); while (ret == -1 && errno == EINTR); return (ret == -1) ? MEMCACHED_ERRNO : MEMCACHED_SUCCESS; } -static memcached_return_t mutex_exit(pthread_mutex_t *mutex) { +static memcached_return_t mutex_exit(pthread_mutex_t *mutex) +{ int ret; do ret= pthread_mutex_unlock(mutex); @@ -40,8 +41,10 @@ static memcached_return_t mutex_exit(pthread_mutex_t *mutex) { * Grow the connection pool by creating a connection structure and clone the * original memcached handle. */ -static int grow_pool(memcached_pool_st* pool) { +static int grow_pool(memcached_pool_st* pool) +{ memcached_st *obj= calloc(1, sizeof(*obj)); + if (obj == NULL) return -1; @@ -57,45 +60,48 @@ static int grow_pool(memcached_pool_st* pool) { return 0; } -memcached_pool_st *memcached_pool_create(memcached_st* mmc, - uint32_t initial, uint32_t max) +memcached_pool_st *memcached_pool_create(memcached_st* mmc, + uint32_t initial, uint32_t max) { memcached_pool_st* ret = NULL; - memcached_pool_st object = { .mutex = PTHREAD_MUTEX_INITIALIZER, + memcached_pool_st object = { .mutex = PTHREAD_MUTEX_INITIALIZER, .cond = PTHREAD_COND_INITIALIZER, .master = mmc, .mmc = calloc(max, sizeof(memcached_st*)), .firstfree = -1, - .size = max, + .size = max, .current_size = 0 }; - if (object.mmc != NULL) + if (object.mmc != NULL) { ret= calloc(1, sizeof(*ret)); - if (ret == NULL) + if (ret == NULL) { free(object.mmc); return NULL; - } + } *ret = object; - /* Try to create the initial size of the pool. An allocation failure at - * this time is not fatal.. - */ - for (unsigned int ii=0; ii < initial; ++ii) + /* + Try to create the initial size of the pool. An allocation failure at + this time is not fatal.. + */ + for (unsigned int ii= 0; ii < initial; ++ii) + { if (grow_pool(ret) == -1) break; + } } return ret; } -memcached_st* memcached_pool_destroy(memcached_pool_st* pool) +memcached_st* memcached_pool_destroy(memcached_pool_st* pool) { memcached_st *ret = pool->master; - for (int xx= 0; xx <= pool->firstfree; ++xx) + for (int xx= 0; xx <= pool->firstfree; ++xx) { memcached_free(pool->mmc[xx]); free(pool->mmc[xx]); @@ -112,39 +118,39 @@ memcached_st* memcached_pool_destroy(memcached_pool_st* pool) memcached_st* memcached_pool_pop(memcached_pool_st* pool, bool block, - memcached_return_t *rc) + memcached_return_t *rc) { memcached_st *ret= NULL; - if ((*rc= mutex_enter(&pool->mutex)) != MEMCACHED_SUCCESS) + if ((*rc= mutex_enter(&pool->mutex)) != MEMCACHED_SUCCESS) return NULL; - do + do { if (pool->firstfree > -1) ret= pool->mmc[pool->firstfree--]; - else if (pool->current_size == pool->size) + else if (pool->current_size == pool->size) { - if (!block) + if (!block) { *rc= mutex_exit(&pool->mutex); return NULL; } - if (pthread_cond_wait(&pool->cond, &pool->mutex) == -1) + if (pthread_cond_wait(&pool->cond, &pool->mutex) == -1) { int err = errno; mutex_exit(&pool->mutex); - errno = err; + errno = err; *rc= MEMCACHED_ERRNO; return NULL; } - } - else if (grow_pool(pool) == -1) + } + else if (grow_pool(pool) == -1) { *rc= mutex_exit(&pool->mutex); return NULL; } - } + } while (ret == NULL); *rc= mutex_exit(&pool->mutex); @@ -152,7 +158,7 @@ memcached_st* memcached_pool_pop(memcached_pool_st* pool, return ret; } -memcached_return_t memcached_pool_push(memcached_pool_st* pool, +memcached_return_t memcached_pool_push(memcached_pool_st* pool, memcached_st *mmc) { memcached_return_t rc= mutex_enter(&pool->mutex); @@ -160,9 +166,9 @@ memcached_return_t memcached_pool_push(memcached_pool_st* pool, if (rc != MEMCACHED_SUCCESS) return rc; - char* version = memcached_get_user_data(mmc); + char* version= memcached_get_user_data(mmc); /* Someone updated the behavior on the object.. */ - if (version != pool->version) + if (version != pool->version) { memcached_free(mmc); memset(mmc, 0, sizeof(*mmc)); @@ -174,7 +180,7 @@ memcached_return_t memcached_pool_push(memcached_pool_st* pool, pool->mmc[++pool->firstfree]= mmc; - if (pool->firstfree == 0 && pool->current_size == pool->size) + if (pool->firstfree == 0 && pool->current_size == pool->size) { /* we might have people waiting for a connection.. wake them up :-) */ pthread_cond_broadcast(&pool->cond); @@ -188,8 +194,8 @@ memcached_return_t memcached_pool_push(memcached_pool_st* pool, } -memcached_return_t memcached_pool_behavior_set(memcached_pool_st *pool, - memcached_behavior_t flag, +memcached_return_t memcached_pool_behavior_set(memcached_pool_st *pool, + memcached_behavior_t flag, uint64_t data) { @@ -208,7 +214,7 @@ memcached_return_t memcached_pool_behavior_set(memcached_pool_st *pool, ++pool->version; memcached_set_user_data(pool->master, pool->version); /* update the clones */ - for (int xx= 0; xx <= pool->firstfree; ++xx) + for (int xx= 0; xx <= pool->firstfree; ++xx) { rc= memcached_behavior_set(pool->mmc[xx], flag, data); if (rc == MEMCACHED_SUCCESS) @@ -234,13 +240,18 @@ memcached_return_t memcached_pool_behavior_set(memcached_pool_st *pool, return mutex_exit(&pool->mutex); } -memcached_return_t memcached_pool_behavior_get(memcached_pool_st *pool, +memcached_return_t memcached_pool_behavior_get(memcached_pool_st *pool, memcached_behavior_t flag, uint64_t *value) { memcached_return_t rc= mutex_enter(&pool->mutex); + if (rc != MEMCACHED_SUCCESS) + { return rc; + } + *value= memcached_behavior_get(pool->master, flag); + return mutex_exit(&pool->mutex); } diff --git a/libmemcached/memcached_verbosity.c b/libmemcached/verbosity.c similarity index 100% rename from libmemcached/memcached_verbosity.c rename to libmemcached/verbosity.c diff --git a/libmemcached/memcached_version.c b/libmemcached/version.c similarity index 100% rename from libmemcached/memcached_version.c rename to libmemcached/version.c diff --git a/libmemcached/memcached_watchpoint.h b/libmemcached/watchpoint.h similarity index 100% rename from libmemcached/memcached_watchpoint.h rename to libmemcached/watchpoint.h -- 2.30.2