X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fmemcached_hosts.c;h=b97476a5b7e76be3c8279a3a203386eebe4b3f41;hb=26aff973ea8db6495862e66cb287e9c000103c9e;hp=c62c3b41984402665b324b097f3717ef930a1a01;hpb=2f44187ce709c4524aef74f9d2e788d5845829d5;p=m6w6%2Flibmemcached diff --git a/libmemcached/memcached_hosts.c b/libmemcached/memcached_hosts.c index c62c3b41..b97476a5 100644 --- a/libmemcached/memcached_hosts.c +++ b/libmemcached/memcached_hosts.c @@ -179,11 +179,12 @@ static memcached_return server_add(memcached_st *ptr, char *hostname, host_reset(ptr, &ptr->hosts[ptr->number_of_hosts], hostname, port, type); ptr->number_of_hosts++; - ptr->hosts[0].count++; if (ptr->number_of_hosts > 1) qsort(ptr->hosts, ptr->number_of_hosts, sizeof(memcached_server_st), compare_servers); + ptr->hosts[0].count= ptr->number_of_hosts; + rebalance_wheel(ptr); LIBMEMCACHED_MEMCACHED_SERVER_ADD_END(); @@ -220,14 +221,11 @@ memcached_server_st *memcached_server_list_append(memcached_server_st *ptr, host_reset(NULL, &new_host_list[count-1], hostname, port, MEMCACHED_CONNECTION_TCP); - /* Backwards compatibility hack */ - new_host_list[0].count++; - - count= new_host_list[0].count; - + /* We alway sort lists by default */ if (new_host_list[0].count > 1) qsort(new_host_list, count, sizeof(memcached_server_st), compare_servers); + /* Backwards compatibility hack */ new_host_list[0].count= count;