From: Brian Aker Date: Thu, 17 Dec 2009 16:37:42 +0000 (-0800) Subject: Update for hosts.c for sort. X-Git-Tag: 0.37~63 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=c5e241403799b30e270688938964a9d7eca92ef0;p=m6w6%2Flibmemcached Update for hosts.c for sort. --- diff --git a/ChangeLog b/ChangeLog index 706285c2..f44a0ee4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ + * Modified use_sort so that the option can be applied to any distribution type. * We removed the MEMCACHED_BEHAVIOR_KETAMA_COMPAT_MODE added in 0.35. Instead use memcached_behavior_set_distribution(). diff --git a/libmemcached/hosts.c b/libmemcached/hosts.c index 09924f10..27a86a7b 100644 --- a/libmemcached/hosts.c +++ b/libmemcached/hosts.c @@ -36,6 +36,9 @@ static void sort_hosts(memcached_st *ptr) memcached_return_t run_distribution(memcached_st *ptr) { + if (ptr->flags.use_sort_hosts) + sort_hosts(ptr); + switch (ptr->distribution) { case MEMCACHED_DISTRIBUTION_CONSISTENT: @@ -43,8 +46,6 @@ memcached_return_t run_distribution(memcached_st *ptr) case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY: return update_continuum(ptr); case MEMCACHED_DISTRIBUTION_MODULA: - if (ptr->flags.use_sort_hosts) - sort_hosts(ptr); break; case MEMCACHED_DISTRIBUTION_RANDOM: srandom((uint32_t) time(NULL));