X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fhash.c;h=6ead8d46e38793fb5bfea0606346ee03c95a0cfa;hb=b4aaefe9a54dd25f1288c714ac13aaef8fc4fcd6;hp=7683761ee28eb940a831de1403f44429a2eb6f1a;hpb=965bde2b42f5ef2dd7b55b6b4b74822e7cfaa1de;p=m6w6%2Flibmemcached diff --git a/libmemcached/hash.c b/libmemcached/hash.c index 7683761e..6ead8d46 100644 --- a/libmemcached/hash.c +++ b/libmemcached/hash.c @@ -111,9 +111,9 @@ uint32_t generate_hash(memcached_st *ptr, const char *key, size_t key_length) uint32_t hash= 1; /* Just here to remove compile warning */ - WATCHPOINT_ASSERT(ptr->number_of_hosts); + WATCHPOINT_ASSERT(memcached_server_count(ptr)); - if (ptr->number_of_hosts == 1) + if (memcached_server_count(ptr) == 1) return 0; hash= memcached_generate_hash_value(key, key_length, ptr->hash); @@ -150,13 +150,13 @@ static uint32_t dispatch_host(memcached_st *ptr, uint32_t hash) return right->index; } case MEMCACHED_DISTRIBUTION_MODULA: - return hash % ptr->number_of_hosts; + return hash % memcached_server_count(ptr); case MEMCACHED_DISTRIBUTION_RANDOM: - return (uint32_t) random() % ptr->number_of_hosts; + return (uint32_t) random() % memcached_server_count(ptr); case MEMCACHED_DISTRIBUTION_CONSISTENT_MAX: default: WATCHPOINT_ASSERT(0); /* We have added a distribution without extending the logic */ - return hash % ptr->number_of_hosts; + return hash % memcached_server_count(ptr); } /* NOTREACHED */ } @@ -169,9 +169,9 @@ uint32_t memcached_generate_hash(memcached_st *ptr, const char *key, size_t key_ { uint32_t hash= 1; /* Just here to remove compile warning */ - WATCHPOINT_ASSERT(ptr->number_of_hosts); + WATCHPOINT_ASSERT(memcached_server_count(ptr)); - if (ptr->number_of_hosts == 1) + if (memcached_server_count(ptr) == 1) return 0; if (ptr->flags.hash_with_prefix_key)