From 6a6fc4a2fe5528d8be1e6ee4405a9ac09d873224 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Fri, 8 Jun 2012 12:57:03 +0100 Subject: [PATCH] Fixes condition where we were not correctly setting weighted vs not. --- libmemcached/behavior.cc | 2 +- tests/libmemcached-1.0/all_tests.h | 1 + tests/libmemcached-1.0/mem_functions.cc | 17 +++++++++++++++++ tests/libmemcached-1.0/mem_functions.h | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/libmemcached/behavior.cc b/libmemcached/behavior.cc index 68e617d1..fe489cf2 100644 --- a/libmemcached/behavior.cc +++ b/libmemcached/behavior.cc @@ -489,7 +489,7 @@ memcached_return_t memcached_behavior_set_distribution(memcached_st *ptr, memcac { if (type < MEMCACHED_DISTRIBUTION_CONSISTENT_MAX) { - if (MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED) + if (type == MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED) { ptr->ketama.weighted= true; } diff --git a/tests/libmemcached-1.0/all_tests.h b/tests/libmemcached-1.0/all_tests.h index 92db0b8b..a3a8dcfc 100644 --- a/tests/libmemcached-1.0/all_tests.h +++ b/tests/libmemcached-1.0/all_tests.h @@ -276,6 +276,7 @@ test_st regression_tests[]= { {"lp:854604", true, (test_callback_fn*)regression_bug_854604 }, {"lp:996813", true, (test_callback_fn*)regression_996813_TEST }, {"lp:994772", true, (test_callback_fn*)regression_994772_TEST }, + {"lp:1009493", true, (test_callback_fn*)regression_1009493_TEST }, {0, false, (test_callback_fn*)0} }; diff --git a/tests/libmemcached-1.0/mem_functions.cc b/tests/libmemcached-1.0/mem_functions.cc index 83ea1317..ce0514d7 100644 --- a/tests/libmemcached-1.0/mem_functions.cc +++ b/tests/libmemcached-1.0/mem_functions.cc @@ -4620,6 +4620,23 @@ test_return_t regression_bug_490520(memcached_st *original_memc) return TEST_SUCCESS; } +test_return_t regression_1009493_TEST(memcached_st*) +{ + memcached_st* memc= memcached_create(NULL); + test_true(memc); + test_compare(MEMCACHED_SUCCESS, memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA, true)); + + memcached_st* clone= memcached_clone(NULL, memc); + test_true(clone); + + test_compare(memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED), + memcached_behavior_get(clone, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED)); + + memcached_free(memc); + memcached_free(clone); + + return TEST_SUCCESS; +} test_return_t regression_994772_TEST(memcached_st* memc) { diff --git a/tests/libmemcached-1.0/mem_functions.h b/tests/libmemcached-1.0/mem_functions.h index b037b86e..571c1607 100644 --- a/tests/libmemcached-1.0/mem_functions.h +++ b/tests/libmemcached-1.0/mem_functions.h @@ -177,3 +177,4 @@ test_return_t wrong_failure_counter_two_test(memcached_st *memc); test_return_t kill_HUP_TEST(memcached_st *memc); test_return_t regression_996813_TEST(memcached_st*); test_return_t regression_994772_TEST(memcached_st*); +test_return_t regression_1009493_TEST(memcached_st*); -- 2.30.2