From: Brian Aker Date: Mon, 11 Jun 2012 20:03:20 +0000 (-0400) Subject: Update with current fixes. X-Git-Tag: 1.0.9~28 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=536d248a75fb329a48f06157d2bd8cea2f06f903;p=awesomized%2Flibmemcached Update with current fixes. --- diff --git a/example/include.am b/example/include.am index bf620d0c..80e446eb 100644 --- a/example/include.am +++ b/example/include.am @@ -3,25 +3,25 @@ # All paths should be given relative to the root if HAVE_LIBEVENT -noinst_PROGRAMS += example/memcached_light +noinst_PROGRAMS+= example/memcached_light endif -noinst_HEADERS+= \ - example/byteorder.h \ - example/memcached_light.h \ - example/storage.h +noinst_HEADERS+= example/byteorder.h +noinst_HEADERS+= example/memcached_light.h +noinst_HEADERS+= example/storage.h -example_memcached_light_SOURCES= \ - example/byteorder.cc \ - example/interface_v0.cc \ - example/interface_v1.cc \ - example/memcached_light.cc \ - util/daemon.cc \ - util/pidfile.cc - -example_memcached_light_LDADD= libmemcached/libmemcachedprotocol.la \ - $(LIBEVENT_LDFLAGS) +example_memcached_light_SOURCES= +example_memcached_light_LDADD= +example_memcached_light_SOURCES+= example/byteorder.cc +example_memcached_light_SOURCES+= example/interface_v0.cc +example_memcached_light_SOURCES+= example/interface_v1.cc +example_memcached_light_SOURCES+= example/memcached_light.cc example_memcached_light_SOURCES+= example/storage.cc +example_memcached_light_SOURCES+= util/daemon.cc +example_memcached_light_SOURCES+= util/pidfile.cc + +example_memcached_light_LDADD+= libmemcached/libmemcachedprotocol.la +example_memcached_light_LDADD+= $(LIBEVENT_LDFLAGS) include example/t/include.am diff --git a/example/t/include.am b/example/t/include.am index 212207f4..394e4c6c 100644 --- a/example/t/include.am +++ b/example/t/include.am @@ -13,15 +13,18 @@ MEMCACHED_LIGHT_TESTS_LDADDS= \ libmemcached/libmemcachedutil.la \ libtest/libtest.la -example_t_memcached_light_SOURCES= +example_t_memcached_light_CXXFLAGS= +example_t_memcached_light_DEPENDENCIES= example_t_memcached_light_LDADD= +example_t_memcached_light_SOURCES= example_t_memcached_light_SOURCES+= example/t/memcached_light.cc example_t_memcached_light_SOURCES+= tests/libmemcached-1.0/memcached_get.cc example_t_memcached_light_SOURCES+= tests/libmemcached-1.0/print.cc example_t_memcached_light_SOURCES+= tests/libmemcached-1.0/setup_and_teardowns.cc -example_t_memcached_light_CXXFLAGS = $(AM_CXXFLAGS) -example_t_memcached_light_DEPENDENCIES= $(MEMCACHED_LIGHT_TESTS_LDADDS) example/memcached_light +example_t_memcached_light_CXXFLAGS+= $(AM_CXXFLAGS) +example_t_memcached_light_DEPENDENCIES+= $(MEMCACHED_LIGHT_TESTS_LDADDS) +example_t_memcached_light_DEPENDENCIES+= example/memcached_light example_t_memcached_light_LDADD+= $(MEMCACHED_LIGHT_TESTS_LDADDS) example_t_memcached_light_LDADD+= $(LIBUUID_LDFLAGS) check_PROGRAMS+= example/t/memcached_light diff --git a/example/t/memcached_light.cc b/example/t/memcached_light.cc index b9c4e5fb..9158b142 100644 --- a/example/t/memcached_light.cc +++ b/example/t/memcached_light.cc @@ -199,6 +199,12 @@ collection_st collection[] ={ static void *world_create(server_startup_st& servers, test_return_t& error) { + if (access(executable.c_str(), X_OK) != 0) + { + error= TEST_SKIPPED; + return NULL; + } + if (HAVE_MEMCACHED_LIGHT_BINARY == 0) { error= TEST_SKIPPED; @@ -208,6 +214,7 @@ static void *world_create(server_startup_st& servers, test_return_t& error) if (server_startup(servers, "memcached-light", libtest::default_port(), 0, NULL) == 0) { error= TEST_FAILURE; + return NULL; } diff --git a/libmemcached/behavior.cc b/libmemcached/behavior.cc index fe489cf2..c91acc5d 100644 --- a/libmemcached/behavior.cc +++ b/libmemcached/behavior.cc @@ -162,13 +162,17 @@ memcached_return_t memcached_behavior_set(memcached_st *ptr, case MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED: { + if (bool(data) == false) + { + return memcached_behavior_set(ptr, MEMCACHED_BEHAVIOR_KETAMA, true); + } + (void)memcached_behavior_set_key_hash(ptr, MEMCACHED_HASH_MD5); (void)memcached_behavior_set_distribution_hash(ptr, MEMCACHED_HASH_MD5); - ptr->ketama.weighted= bool(data); /** @note We try to keep the same distribution going. This should be deprecated and rewritten. */ - return memcached_behavior_set_distribution(ptr, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA); + return memcached_behavior_set_distribution(ptr, MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED); } case MEMCACHED_BEHAVIOR_HASH: @@ -487,23 +491,36 @@ uint64_t memcached_behavior_get(memcached_st *ptr, memcached_return_t memcached_behavior_set_distribution(memcached_st *ptr, memcached_server_distribution_t type) { - if (type < MEMCACHED_DISTRIBUTION_CONSISTENT_MAX) + switch (type) { - if (type == MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED) - { - ptr->ketama.weighted= true; - } - else - { - ptr->ketama.weighted= false; - } + case MEMCACHED_DISTRIBUTION_MODULA: + break; - ptr->distribution= type; - return run_distribution(ptr); + case MEMCACHED_DISTRIBUTION_CONSISTENT: + case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA: + ptr->ketama.weighted= false; + break; + + case MEMCACHED_DISTRIBUTION_RANDOM: + break; + + case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY: + break; + + case MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED: + ptr->ketama.weighted= true; + break; + + case MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET: + break; + + default: + case MEMCACHED_DISTRIBUTION_CONSISTENT_MAX: + return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, + memcached_literal_param("Invalid memcached_server_distribution_t")); } - return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, - memcached_literal_param("Invalid memcached_server_distribution_t")); + return run_distribution(ptr); } @@ -531,7 +548,9 @@ memcached_hash_t memcached_behavior_get_key_hash(memcached_st *ptr) memcached_return_t memcached_behavior_set_distribution_hash(memcached_st *ptr, memcached_hash_t type) { if (hashkit_success(hashkit_set_distribution_function(&ptr->hashkit, (hashkit_hash_algorithm_t)type))) + { return MEMCACHED_SUCCESS; + } return memcached_set_error(*ptr, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid memcached_hash_t()")); diff --git a/tests/libmemcached-1.0/setup_and_teardowns.cc b/tests/libmemcached-1.0/setup_and_teardowns.cc index 15c7a3e0..3d6a4a08 100644 --- a/tests/libmemcached-1.0/setup_and_teardowns.cc +++ b/tests/libmemcached-1.0/setup_and_teardowns.cc @@ -183,17 +183,13 @@ test_return_t pre_behavior_ketama(memcached_st *memc) test_return_t pre_behavior_ketama_weighted(memcached_st *memc) { - memcached_return_t rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1); - test_compare(MEMCACHED_SUCCESS, rc); + test_compare(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, true), MEMCACHED_SUCCESS); - uint64_t value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED); - test_compare(value, uint64_t(1)); + test_compare(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED), uint64_t(1)); - test_compare(MEMCACHED_SUCCESS, - memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH, MEMCACHED_HASH_MD5)); + test_compare(memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH, MEMCACHED_HASH_MD5), MEMCACHED_SUCCESS); - value= memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH); - test_compare(MEMCACHED_HASH_MD5, memcached_hash_t(value)); + test_compare(memcached_hash_t(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_HASH)), MEMCACHED_HASH_MD5); return TEST_SUCCESS; }