From 9a00fe7032d5b9521004198479a4656f77bd4e3c Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Sat, 13 Feb 2010 16:05:19 -0800 Subject: [PATCH] Merge in additional type fixes. --- libmemcached/server.c | 35 ++++++++++++++++++----------------- libmemcached/server.h | 26 +++++++++++++++----------- libmemcached/types.h | 2 +- tests/mem_functions.c | 6 +++--- 4 files changed, 37 insertions(+), 32 deletions(-) diff --git a/libmemcached/server.c b/libmemcached/server.c index 13216bcf..3b28515b 100644 --- a/libmemcached/server.c +++ b/libmemcached/server.c @@ -152,7 +152,7 @@ memcached_return_t memcached_server_cursor(const memcached_st *ptr, { for (uint32_t x= 0; x < memcached_server_count(ptr); x++) { - const memcached_server_instance_st *instance= + memcached_server_instance_st *instance= memcached_server_instance_by_position(ptr, x); for (uint32_t y= 0; y < number_of_callbacks; y++) @@ -169,13 +169,13 @@ memcached_return_t memcached_server_cursor(const memcached_st *ptr, return MEMCACHED_SUCCESS; } -const memcached_server_st *memcached_server_by_key(const memcached_st *ptr, - const char *key, - size_t key_length, - memcached_return_t *error) +memcached_server_instance_st *memcached_server_by_key(const memcached_st *ptr, + const char *key, + size_t key_length, + memcached_return_t *error) { uint32_t server_key; - const memcached_server_instance_st *instance; + memcached_server_instance_st *instance; *error= memcached_validate_key_length(key_length, ptr->flags.binary_protocol); @@ -201,19 +201,12 @@ const memcached_server_st *memcached_server_by_key(const memcached_st *ptr, } -const char *memcached_server_error(const memcached_server_st *ptr) -{ - return ptr - ? ptr->cached_server_error - : NULL; -} - void memcached_server_error_reset(memcached_server_st *ptr) { ptr->cached_server_error[0]= 0; } -memcached_server_st *memcached_server_get_last_disconnect(memcached_st *ptr) +memcached_server_instance_st *memcached_server_get_last_disconnect(const memcached_st *ptr) { return ptr->last_disconnected_server; } @@ -283,12 +276,12 @@ inline uint32_t memcached_server_count(const memcached_st *self) return self->number_of_hosts; } -inline const char *memcached_server_name(const memcached_server_st *self) +inline const char *memcached_server_name(memcached_server_instance_st *self) { return self->hostname; } -inline in_port_t memcached_server_port(const memcached_server_st *self) +inline in_port_t memcached_server_port(memcached_server_instance_st *self) { return self->port; } @@ -303,7 +296,15 @@ inline void memcached_server_list_set(memcached_st *self, memcached_server_st *l self->servers= list; } -inline uint32_t memcached_server_response_count(const memcached_server_st *self) +inline uint32_t memcached_server_response_count(memcached_server_instance_st *self) { return self->cursor_active; } + +const char *memcached_server_error(memcached_server_instance_st *ptr) +{ + return ptr + ? ptr->cached_server_error + : NULL; +} + diff --git a/libmemcached/server.h b/libmemcached/server.h index 8a9b7a36..7d0be189 100644 --- a/libmemcached/server.h +++ b/libmemcached/server.h @@ -61,13 +61,10 @@ memcached_return_t memcached_server_cursor(const memcached_st *ptr, uint32_t number_of_callbacks); LIBMEMCACHED_API - const memcached_server_st *memcached_server_by_key(const memcached_st *ptr, - const char *key, - size_t key_length, - memcached_return_t *error); - -LIBMEMCACHED_API -const char *memcached_server_error(const memcached_server_st *ptr); + memcached_server_instance_st *memcached_server_by_key(const memcached_st *ptr, + const char *key, + size_t key_length, + memcached_return_t *error); LIBMEMCACHED_API void memcached_server_error_reset(memcached_server_st *ptr); @@ -83,7 +80,7 @@ LIBMEMCACHED_API memcached_return_t memcached_server_remove(memcached_server_st *st_ptr); LIBMEMCACHED_API -memcached_server_st *memcached_server_get_last_disconnect(memcached_st *ptr); +memcached_server_instance_st *memcached_server_get_last_disconnect(const memcached_st *ptr); LIBMEMCACHED_API @@ -146,14 +143,21 @@ memcached_server_st *memcached_server_list(memcached_st *); LIBMEMCACHED_LOCAL void memcached_server_list_set(memcached_st *self, memcached_server_st *list); +/** + Operations on Single Servers. +*/ LIBMEMCACHED_API -uint32_t memcached_server_response_count(const memcached_server_st *self); +uint32_t memcached_server_response_count(memcached_server_instance_st *self); LIBMEMCACHED_API -const char *memcached_server_name(const memcached_server_st *self); +const char *memcached_server_name(memcached_server_instance_st *self); LIBMEMCACHED_API -in_port_t memcached_server_port(const memcached_server_st *self); +in_port_t memcached_server_port(memcached_server_instance_st *self); + +LIBMEMCACHED_API +const char *memcached_server_error(memcached_server_instance_st *ptr); + #ifdef __cplusplus diff --git a/libmemcached/types.h b/libmemcached/types.h index 057c9e6d..f639c9eb 100644 --- a/libmemcached/types.h +++ b/libmemcached/types.h @@ -42,7 +42,7 @@ typedef void *(*memcached_calloc_fn)(const memcached_st *ptr, size_t nelem, cons typedef memcached_return_t (*memcached_execute_fn)(const memcached_st *ptr, memcached_result_st *result, void *context); -typedef memcached_return_t (*memcached_server_fn)(const memcached_st *ptr, const memcached_server_st *server, void *context); +typedef memcached_return_t (*memcached_server_fn)(const memcached_st *ptr, memcached_server_instance_st *server, void *context); /** Trigger functions. diff --git a/tests/mem_functions.c b/tests/mem_functions.c index 32fc3c6d..26cf6fd9 100644 --- a/tests/mem_functions.c +++ b/tests/mem_functions.c @@ -5704,7 +5704,7 @@ static test_return_t regression_bug_463297(memcached_st *memc) static test_return_t test_get_last_disconnect(memcached_st *memc) { memcached_return_t rc; - memcached_server_st *disconnected_server; + memcached_server_instance_st *disconnected_server; /* With the working set of server */ const char *key= "marmotte"; @@ -5739,8 +5739,8 @@ static test_return_t test_get_last_disconnect(memcached_st *memc) disconnected_server = memcached_server_get_last_disconnect(mine); test_true(disconnected_server != NULL); - test_true(disconnected_server->port == 9); - test_true(strncmp(disconnected_server->hostname,"localhost",9) == 0); + test_true(memcached_server_port(disconnected_server)== 9); + test_true(strncmp(memcached_server_name(disconnected_server),"localhost",9) == 0); memcached_quit(mine); memcached_free(mine); -- 2.30.2