From: Brian Aker Date: Sun, 14 Feb 2010 01:04:45 +0000 (-0800) Subject: Updating memcached_server_instance_st structure. X-Git-Tag: 0.40~43 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=c29c787187baac1f403668a5dbf8ba481b9a8c8e;p=awesomized%2Flibmemcached Updating memcached_server_instance_st structure. --- diff --git a/libmemcached/common.h b/libmemcached/common.h index 67d7cb05..a03cabbf 100644 --- a/libmemcached/common.h +++ b/libmemcached/common.h @@ -124,10 +124,6 @@ memcached_return_t run_distribution(memcached_st *ptr); #define memcached_set_allocated(__object, __value) ((__object)->options.is_allocated(= (__value)) -LIBMEMCACHED_LOCAL -memcached_return_t value_fetch(memcached_server_instance_st *ptr, - char *buffer, - memcached_result_st *result); LIBMEMCACHED_LOCAL memcached_return_t memcached_key_test(const char * const *keys, const size_t *key_length, diff --git a/libmemcached/hosts.c b/libmemcached/hosts.c index e907be4a..72c5ca56 100644 --- a/libmemcached/hosts.c +++ b/libmemcached/hosts.c @@ -22,8 +22,8 @@ static memcached_return_t update_continuum(memcached_st *ptr); static int compare_servers(const void *p1, const void *p2) { int return_value; - memcached_server_instance_st *a= (memcached_server_instance_st *)p1; - memcached_server_instance_st *b= (memcached_server_instance_st *)p2; + memcached_server_instance_st a= (memcached_server_instance_st)p1; + memcached_server_instance_st b= (memcached_server_instance_st)p2; return_value= strcmp(a->hostname, b->hostname); @@ -41,7 +41,7 @@ static void sort_hosts(memcached_st *ptr) { memcached_server_write_instance_st instance; - qsort(memcached_server_list(ptr), memcached_server_count(ptr), sizeof(memcached_server_instance_st), compare_servers); + qsort(memcached_server_list(ptr), memcached_server_count(ptr), sizeof(memcached_server_st), compare_servers); instance= memcached_server_instance_fetch(ptr, 0); instance->number_of_hosts= memcached_server_count(ptr); } @@ -315,7 +315,7 @@ memcached_return_t memcached_server_push(memcached_st *ptr, const memcached_serv count= memcached_server_list_count(list); new_host_list= libmemcached_realloc(ptr, memcached_server_list(ptr), - sizeof(memcached_server_instance_st) * (count + memcached_server_count(ptr))); + sizeof(memcached_server_st) * (count + memcached_server_count(ptr))); if (! new_host_list) return MEMCACHED_MEMORY_ALLOCATION_FAILURE; diff --git a/libmemcached/memcached.c b/libmemcached/memcached.c index f7946241..2925de7f 100644 --- a/libmemcached/memcached.c +++ b/libmemcached/memcached.c @@ -307,7 +307,7 @@ inline memcached_server_write_instance_st memcached_server_instance_fetch(memcac return &ptr->servers[server_key]; } -inline memcached_server_instance_st *memcached_server_instance_by_position(const memcached_st *ptr, uint32_t server_key) +inline memcached_server_instance_st memcached_server_instance_by_position(const memcached_st *ptr, uint32_t server_key) { return &ptr->servers[server_key]; } diff --git a/libmemcached/memcached.h b/libmemcached/memcached.h index 2ee25812..a934c5a2 100644 --- a/libmemcached/memcached.h +++ b/libmemcached/memcached.h @@ -153,7 +153,7 @@ LIBMEMCACHED_API memcached_return_t memcached_push(memcached_st *destination, const memcached_st *source); LIBMEMCACHED_API -memcached_server_instance_st *memcached_server_instance_by_position(const memcached_st *ptr, uint32_t server_key); +memcached_server_instance_st memcached_server_instance_by_position(const memcached_st *ptr, uint32_t server_key); LIBMEMCACHED_LOCAL void server_list_free(memcached_st *ptr, memcached_server_st *servers); diff --git a/libmemcached/memcached.hpp b/libmemcached/memcached.hpp index 39ca36d8..4e6fdd61 100644 --- a/libmemcached/memcached.hpp +++ b/libmemcached/memcached.hpp @@ -960,7 +960,7 @@ public: */ for (uint32_t x= 0; x < server_count; x++) { - const memcached_server_instance_st *instance= + memcached_server_instance_st instance= memcached_server_instance_by_position(&memc, x); std::ostringstream strstm; std::string server_name(memcached_server_name(instance)); diff --git a/libmemcached/server.c b/libmemcached/server.c index 3b28515b..ee9d8575 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++) { - 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; } -memcached_server_instance_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; - memcached_server_instance_st *instance; + memcached_server_instance_st instance; *error= memcached_validate_key_length(key_length, ptr->flags.binary_protocol); @@ -206,7 +206,7 @@ void memcached_server_error_reset(memcached_server_st *ptr) ptr->cached_server_error[0]= 0; } -memcached_server_instance_st *memcached_server_get_last_disconnect(const memcached_st *ptr) +memcached_server_instance_st memcached_server_get_last_disconnect(const memcached_st *ptr) { return ptr->last_disconnected_server; } @@ -276,12 +276,12 @@ inline uint32_t memcached_server_count(const memcached_st *self) return self->number_of_hosts; } -inline const char *memcached_server_name(memcached_server_instance_st *self) +inline const char *memcached_server_name(memcached_server_instance_st self) { return self->hostname; } -inline in_port_t memcached_server_port(memcached_server_instance_st *self) +inline in_port_t memcached_server_port(memcached_server_instance_st self) { return self->port; } @@ -296,12 +296,12 @@ inline void memcached_server_list_set(memcached_st *self, memcached_server_st *l self->servers= list; } -inline uint32_t memcached_server_response_count(memcached_server_instance_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) +const char *memcached_server_error(memcached_server_instance_st ptr) { return ptr ? ptr->cached_server_error diff --git a/libmemcached/server.h b/libmemcached/server.h index 7d0be189..2fc25f69 100644 --- a/libmemcached/server.h +++ b/libmemcached/server.h @@ -61,7 +61,7 @@ memcached_return_t memcached_server_cursor(const memcached_st *ptr, uint32_t number_of_callbacks); LIBMEMCACHED_API - memcached_server_instance_st *memcached_server_by_key(const memcached_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); @@ -80,7 +80,7 @@ LIBMEMCACHED_API memcached_return_t memcached_server_remove(memcached_server_st *st_ptr); LIBMEMCACHED_API -memcached_server_instance_st *memcached_server_get_last_disconnect(const memcached_st *ptr); +memcached_server_instance_st memcached_server_get_last_disconnect(const memcached_st *ptr); LIBMEMCACHED_API @@ -147,16 +147,16 @@ void memcached_server_list_set(memcached_st *self, memcached_server_st *list); Operations on Single Servers. */ LIBMEMCACHED_API -uint32_t memcached_server_response_count(memcached_server_instance_st *self); +uint32_t memcached_server_response_count(memcached_server_instance_st self); LIBMEMCACHED_API -const char *memcached_server_name(memcached_server_instance_st *self); +const char *memcached_server_name(memcached_server_instance_st self); LIBMEMCACHED_API -in_port_t memcached_server_port(memcached_server_instance_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); +const char *memcached_server_error(memcached_server_instance_st ptr); diff --git a/libmemcached/types.h b/libmemcached/types.h index f639c9eb..56adf1e0 100644 --- a/libmemcached/types.h +++ b/libmemcached/types.h @@ -17,7 +17,7 @@ typedef struct memcached_stat_st memcached_stat_st; typedef struct memcached_analysis_st memcached_analysis_st; typedef struct memcached_result_st memcached_result_st; typedef struct memcached_server_st memcached_server_st; -typedef const struct memcached_server_st memcached_server_instance_st; +typedef const struct memcached_server_st * memcached_server_instance_st; typedef struct memcached_callback_st memcached_callback_st; @@ -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, memcached_server_instance_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/libmemcached_world.h b/tests/libmemcached_world.h index ce0c44a4..b608d9ae 100644 --- a/tests/libmemcached_world.h +++ b/tests/libmemcached_world.h @@ -98,7 +98,7 @@ test_return_t world_pre_run(libmemcached_test_container_st *container) { for (uint32_t loop= 0; loop < memcached_server_list_count(container->construct.servers); loop++) { - const memcached_server_instance_st *instance= + memcached_server_instance_st instance= memcached_server_instance_by_position(container->memc, loop); test_true(instance->fd == -1); diff --git a/tests/mem_functions.c b/tests/mem_functions.c index 26cf6fd9..f5e3da13 100644 --- a/tests/mem_functions.c +++ b/tests/mem_functions.c @@ -130,7 +130,7 @@ static test_return_t server_sort2_test(memcached_st *ptr __attribute__((unused)) memcached_return_t rc; memcached_server_fn callbacks[1]; memcached_st *local_memc; - memcached_server_instance_st *instance; + memcached_server_instance_st instance; local_memc= memcached_create(NULL); test_true(local_memc); @@ -1208,7 +1208,7 @@ static test_return_t stats_servername_test(memcached_st *memc) { memcached_return_t rc; memcached_stat_st memc_stat; - memcached_server_instance_st *instance= + memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0); rc= memcached_stat_servername(&memc_stat, NULL, @@ -2806,7 +2806,7 @@ static test_return_t user_supplied_bug18(memcached_st *trash) { uint32_t server_idx = memcached_generate_hash(memc, ketama_test_cases[x].key, strlen(ketama_test_cases[x].key)); - memcached_server_instance_st *instance= + memcached_server_instance_st instance= memcached_server_instance_by_position(memc, server_idx); const char *hostname = memcached_server_name(instance); @@ -2911,7 +2911,7 @@ static test_return_t user_supplied_bug21(memcached_st *memc) static test_return_t auto_eject_hosts(memcached_st *trash) { (void) trash; - memcached_server_instance_st *instance; + memcached_server_instance_st instance; memcached_return_t rc; memcached_st *memc= memcached_create(NULL); @@ -3246,7 +3246,7 @@ static test_return_t generate_data_with_stats(memcached_st *memc) { /* This test was changes so that "make test" would work properlly */ #ifdef DEBUG - memcached_server_instance_st *instance= + memcached_server_instance_st instance= memcached_server_instance_by_position(memc, host_index); printf("\nserver %u|%s|%u bytes: %llu\n", host_index, instance->hostname, instance->port, (unsigned long long)(stat_p + host_index)->bytes); @@ -3480,7 +3480,7 @@ static test_return_t pre_nonblock_binary(memcached_st *memc) { memcached_return_t rc= MEMCACHED_FAILURE; memcached_st *memc_clone; - memcached_server_instance_st *instance; + memcached_server_instance_st instance; memc_clone= memcached_clone(NULL, memc); test_true(memc_clone); @@ -3616,7 +3616,7 @@ static test_return_t pre_binary(memcached_st *memc) { memcached_return_t rc= MEMCACHED_FAILURE; memcached_st *memc_clone; - memcached_server_instance_st *instance; + memcached_server_instance_st instance; memc_clone= memcached_clone(NULL, memc); test_true(memc_clone); @@ -3935,7 +3935,7 @@ static test_return_t enable_cas(memcached_st *memc) { unsigned int set= 1; - memcached_server_instance_st *instance= + memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0); memcached_version(memc); @@ -3955,7 +3955,7 @@ static test_return_t check_for_1_2_3(memcached_st *memc) { memcached_version(memc); - memcached_server_instance_st *instance= + memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0); if ((instance->major_version >= 1 && (instance->minor_version == 2 && instance->micro_version >= 4)) @@ -4062,7 +4062,7 @@ static test_return_t noreply_test(memcached_st *memc) int no_msg=0; for (uint32_t x= 0; x < memcached_server_count(memc); ++x) { - memcached_server_instance_st *instance= + memcached_server_instance_st instance= memcached_server_instance_by_position(memc, x); no_msg+=(int)(instance->cursor_active); } @@ -4349,7 +4349,7 @@ static test_return_t replication_get_test(memcached_st *memc) for (uint32_t host= 0; host < memcached_server_count(memc); ++host) { memcached_st *memc_clone= memcached_clone(NULL, memc); - memcached_server_instance_st *instance= + memcached_server_instance_st instance= memcached_server_instance_by_position(memc_clone, host); ((memcached_server_write_instance_st)instance)->port= 0; @@ -4411,7 +4411,7 @@ static test_return_t replication_mget_test(memcached_st *memc) for (uint32_t host= 0; host < memc_clone->number_of_hosts; host++) { memcached_st *new_clone= memcached_clone(NULL, memc); - memcached_server_instance_st *instance= + memcached_server_instance_st instance= memcached_server_instance_by_position(new_clone, host); ((memcached_server_write_instance_st)instance)->port= 0; @@ -4509,7 +4509,7 @@ static test_return_t replication_delete_test(memcached_st *memc) uint32_t hash= memcached_generate_hash(memc, keys[0], len[0]); for (uint32_t x= 0; x < (repl + 1); ++x) { - memcached_server_instance_st *instance= + memcached_server_instance_st instance= memcached_server_instance_by_position(memc_clone, x); ((memcached_server_write_instance_st)instance)->port= 0; @@ -4558,10 +4558,10 @@ static uint16_t *get_udp_request_ids(memcached_st *memc) for (uint32_t x= 0; x < memcached_server_count(memc); x++) { - memcached_server_instance_st *instance= + memcached_server_instance_st instance= memcached_server_instance_by_position(memc, x); - ids[x]= get_udp_datagram_request_id((struct udp_datagram_header_st *) ((memcached_server_instance_st *)instance)->write_buffer); + ids[x]= get_udp_datagram_request_id((struct udp_datagram_header_st *) ((memcached_server_instance_st )instance)->write_buffer); } return ids; @@ -4590,7 +4590,7 @@ static test_return_t post_udp_op_check(memcached_st *memc, uint16_t *expected_re static test_return_t init_udp(memcached_st *memc) { memcached_version(memc); - memcached_server_instance_st *instance= + memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0); /* For the time being, only support udp test for >= 1.2.6 && < 1.3 */ @@ -4603,8 +4603,8 @@ static test_return_t init_udp(memcached_st *memc) memcpy(servers, memcached_server_list(memc), sizeof(memcached_server_st) * num_hosts); for (uint32_t x= 0; x < num_hosts; x++) { - memcached_server_instance_st *set_instance= - memcached_server_instance_by_position(memc, x); + memcached_server_instance_st set_instance= + memcached_server_instance_by_position(memc, x); memcached_server_free(((memcached_server_write_instance_st)set_instance)); } @@ -4613,7 +4613,7 @@ static test_return_t init_udp(memcached_st *memc) memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_USE_UDP, 1); for (uint32_t x= 0; x < num_hosts; x++) { - memcached_server_instance_st *set_instance= + memcached_server_instance_st set_instance= memcached_server_instance_by_position(memc, x); test_true(memcached_server_add_udp(memc, servers[x].hostname, servers[x].port) == MEMCACHED_SUCCESS); @@ -4640,7 +4640,7 @@ static test_return_t add_tcp_server_udp_client_test(memcached_st *memc) (void)memc; #if 0 memcached_server_st server; - memcached_server_instance_st *instance= + memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0); memcached_server_clone(&server, &memc->hosts[0]); test_true(memcached_server_remove(&(memc->hosts[0])) == MEMCACHED_SUCCESS); @@ -4655,7 +4655,7 @@ static test_return_t add_udp_server_tcp_client_test(memcached_st *memc) (void)memc; #if 0 memcached_server_st server; - memcached_server_instance_st *instance= + memcached_server_instance_st instance= memcached_server_instance_by_position(memc, 0); memcached_server_clone(&server, &memc->hosts[0]); test_true(memcached_server_remove(&(memc->hosts[0])) == MEMCACHED_SUCCESS); @@ -4699,7 +4699,7 @@ static test_return_t udp_set_test(memcached_st *memc) const char *value= "when we sanitize"; uint16_t *expected_ids= get_udp_request_ids(memc); unsigned int server_key= memcached_generate_hash(memc, key, strlen(key)); - memcached_server_instance_st *instance= + memcached_server_instance_st instance= memcached_server_instance_by_position(memc, server_key); size_t init_offset= instance->write_buffer_offset; @@ -4759,7 +4759,7 @@ static test_return_t udp_delete_test(memcached_st *memc) const char *key= "foo"; uint16_t *expected_ids=get_udp_request_ids(memc); unsigned int server_key= memcached_generate_hash(memc, key, strlen(key)); - memcached_server_instance_st *instance= + memcached_server_instance_st instance= memcached_server_instance_by_position(memc, server_key); size_t init_offset= instance->write_buffer_offset; @@ -5253,7 +5253,7 @@ static test_return_t ketama_compatibility_libmemcached(memcached_st *trash) for (x= 0; x < 99; x++) { uint32_t server_idx = memcached_generate_hash(memc, ketama_test_cases[x].key, strlen(ketama_test_cases[x].key)); - memcached_server_instance_st *instance= + memcached_server_instance_st instance= memcached_server_instance_by_position(memc, server_idx); const char *hostname = memcached_server_name(instance); @@ -5313,7 +5313,7 @@ static test_return_t ketama_compatibility_spymemcached(memcached_st *trash) { uint32_t server_idx= memcached_generate_hash(memc, ketama_test_cases_spy[x].key, strlen(ketama_test_cases_spy[x].key)); - memcached_server_instance_st *instance= + memcached_server_instance_st instance= memcached_server_instance_by_position(memc, server_idx); const char *hostname= memcached_server_name(instance); @@ -5518,8 +5518,8 @@ static test_return_t regression_bug_442914(memcached_st *memc) static test_return_t regression_bug_447342(memcached_st *memc) { - memcached_server_instance_st *instance_one; - memcached_server_instance_st *instance_two; + memcached_server_instance_st instance_one; + memcached_server_instance_st instance_two; if (memcached_server_count(memc) < 3 || pre_replication(memc) != MEMCACHED_SUCCESS) return TEST_SKIPPED; @@ -5642,7 +5642,7 @@ static test_return_t regression_bug_463297(memcached_st *memc) test_true(memc_clone != NULL); test_true(memcached_version(memc_clone) == MEMCACHED_SUCCESS); - memcached_server_instance_st *instance= + memcached_server_instance_st instance= memcached_server_instance_by_position(memc_clone, 0); if (instance->major_version > 1 || @@ -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_instance_st *disconnected_server; + memcached_server_instance_st disconnected_server; /* With the working set of server */ const char *key= "marmotte"; @@ -5755,7 +5755,7 @@ static test_return_t test_get_last_disconnect(memcached_st *memc) static test_return_t wrong_failure_counter_test(memcached_st *memc) { memcached_return_t rc; - memcached_server_instance_st *instance; + memcached_server_instance_st instance; /* Set value to force connection to the server */ const char *key= "marmotte";