From: Date: Mon, 21 Apr 2008 17:08:50 +0000 (-0700) Subject: Completed work on Ketama (it is now dynamic) X-Git-Tag: 0.20~1^2~11 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=4091a52bdd43a6c562eee5a1e5a34d06b592263d;p=awesomized%2Flibmemcached Completed work on Ketama (it is now dynamic) --- diff --git a/libmemcached/memcached.c b/libmemcached/memcached.c index 353d135f..bcc0477d 100644 --- a/libmemcached/memcached.c +++ b/libmemcached/memcached.c @@ -41,6 +41,14 @@ void memcached_free(memcached_st *ptr) if (ptr->on_cleanup) ptr->on_cleanup(ptr); + if (ptr->continuum) + { + if (ptr->call_free) + ptr->call_free(ptr, ptr->continuum); + else + free(ptr->continuum); + } + if (ptr->is_allocated == MEMCACHED_ALLOCATED) { if (ptr->call_free) diff --git a/libmemcached/memcached_behavior.c b/libmemcached/memcached_behavior.c index 287f8f0c..351b87cd 100644 --- a/libmemcached/memcached_behavior.c +++ b/libmemcached/memcached_behavior.c @@ -38,8 +38,11 @@ memcached_return memcached_behavior_set(memcached_st *ptr, memcached_quit(ptr); break; case MEMCACHED_BEHAVIOR_DISTRIBUTION: - ptr->distribution= (memcached_server_distribution)(data); - break; + { + ptr->distribution= (memcached_server_distribution)(data); + run_distribution(ptr); + break; + } case MEMCACHED_BEHAVIOR_HASH: ptr->hash= (memcached_hash)(data); break; @@ -56,12 +59,7 @@ memcached_return memcached_behavior_set(memcached_st *ptr, case MEMCACHED_BEHAVIOR_SORT_HOSTS: { set_behavior_flag(ptr, MEM_USE_SORT_HOSTS, data); - - if (ptr->flags & MEM_USE_SORT_HOSTS) - { - memcached_quit(ptr); - run_distribution(ptr); - } + run_distribution(ptr); break; } diff --git a/libmemcached/memcached_hash.c b/libmemcached/memcached_hash.c index 3294a0a6..c0e928a1 100644 --- a/libmemcached/memcached_hash.c +++ b/libmemcached/memcached_hash.c @@ -110,6 +110,7 @@ unsigned int dispatch_host(memcached_st *ptr, uint32_t hash) case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA: { int num= ptr->number_of_hosts * MEMCACHED_POINTS_PER_SERVER; + WATCHPOINT_ASSERT(ptr->continuum); hash= hash; memcached_continuum_item_st *begin, *end, *left, *right, *middle;