X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fmemcached_hosts.c;h=d75da5d2d6114410ffaf1519e0469cef2b113821;hb=073c4085895027aabe10aec9264dd8f4dae7e264;hp=231b2167ba37b2f876e3527baea682eee73316c1;hpb=aadde7bff9b295789dbf4a1eeb9b37825a970c02;p=m6w6%2Flibmemcached diff --git a/libmemcached/memcached_hosts.c b/libmemcached/memcached_hosts.c index 231b2167..d75da5d2 100644 --- a/libmemcached/memcached_hosts.c +++ b/libmemcached/memcached_hosts.c @@ -6,49 +6,6 @@ static memcached_return server_add(memcached_st *ptr, char *hostname, memcached_connection type); memcached_return update_continuum(memcached_st *ptr); -#define MEMCACHED_WHEEL_SIZE 1024 -#define MEMCACHED_STRIDE 4 -static memcached_return rebalance_wheel(memcached_st *ptr) -{ - unsigned int x; - unsigned int y; - unsigned int latch; - - if (ptr->number_of_hosts > ptr->wheel_count) - { - uint32_t *new_ptr; - - if (ptr->call_realloc) - new_ptr= (uint32_t *)ptr->call_realloc(ptr, ptr->wheel, sizeof(uint32_t) * (ptr->number_of_hosts + MEMCACHED_CONTINUUM_ADDITION) * MEMCACHED_STRIDE); - else - new_ptr= (uint32_t *)realloc(ptr->wheel, sizeof(uint32_t) * (ptr->number_of_hosts + MEMCACHED_CONTINUUM_ADDITION) * MEMCACHED_STRIDE); - - if (new_ptr == 0) - return MEMCACHED_MEMORY_ALLOCATION_FAILURE; - - ptr->wheel= new_ptr; - ptr->wheel_count= ptr->number_of_hosts + MEMCACHED_CONTINUUM_ADDITION; - } - - /* Seed the Wheel */ - memset(ptr->wheel, 0, sizeof(uint32_t) * MEMCACHED_STRIDE * ptr->wheel_count); - - for (latch= y= x= 0; x < MEMCACHED_STRIDE * ptr->wheel_count; x++, latch++) - { - if (latch == MEMCACHED_STRIDE) - { - y++; - if (y == ptr->number_of_hosts) - y= 0; - latch= 0; - } - - ptr->wheel[x]= y; - } - - return MEMCACHED_SUCCESS; -} - static int compare_servers(const void *p1, const void *p2) { int return_value; @@ -82,9 +39,6 @@ memcached_return run_distribution(memcached_st *ptr) case MEMCACHED_DISTRIBUTION_CONSISTENT: case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA: return update_continuum(ptr); - case MEMCACHED_DISTRIBUTION_CONSISTENT_WHEEL: - return rebalance_wheel(ptr); - break; case MEMCACHED_DISTRIBUTION_MODULA: if (ptr->flags & MEM_USE_SORT_HOSTS) sort_hosts(ptr); @@ -221,10 +175,7 @@ memcached_return memcached_server_push(memcached_st *ptr, memcached_server_st *l sizeof(memcached_server_st) * (count + ptr->number_of_hosts)); if (!new_host_list) - { - assert(0); return MEMCACHED_MEMORY_ALLOCATION_FAILURE; - } ptr->hosts= new_host_list;