X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fhosts.cc;h=1bcaaa7aca4bc9b7e90dff04e6d4ffbe3c67fcf4;hb=refs%2Ftags%2F0.51;hp=db6398914a699472d6163c3d4327b9f882e93055;hpb=9cd57ce737375540f6c3b5e2e3684160e5c4bfce;p=awesomized%2Flibmemcached diff --git a/libmemcached/hosts.cc b/libmemcached/hosts.cc index db639891..1bcaaa7a 100644 --- a/libmemcached/hosts.cc +++ b/libmemcached/hosts.cc @@ -80,7 +80,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) { @@ -89,15 +91,18 @@ memcached_return_t run_distribution(memcached_st *ptr) case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY: case MEMCACHED_DISTRIBUTION_CONSISTENT_WEIGHTED: return update_continuum(ptr); + case MEMCACHED_DISTRIBUTION_VIRTUAL_BUCKET: case MEMCACHED_DISTRIBUTION_MODULA: break; + case MEMCACHED_DISTRIBUTION_RANDOM: srandom((uint32_t) time(NULL)); break; + case MEMCACHED_DISTRIBUTION_CONSISTENT_MAX: default: - WATCHPOINT_ASSERT(0); /* We have added a distribution without extending the logic */ + assert_msg(0, "Invalid distribution type passed to run_distribution()"); } return MEMCACHED_SUCCESS; @@ -246,14 +251,12 @@ static memcached_return_t update_continuum(memcached_st *ptr) if (sort_host_length >= MEMCACHED_MAX_HOST_SORT_LENGTH || sort_host_length < 0) { - return MEMCACHED_FAILURE; + return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, + memcached_literal_param("snprintf(MEMCACHED_DEFAULT_COMMAND_SIZE)")); } #ifdef DEBUG printf("update_continuum: key is %s\n", sort_host); #endif - - WATCHPOINT_ASSERT(sort_host_length); - if (is_ketama_weighted) { for (uint32_t x= 0; x < pointer_per_hash; x++) @@ -298,11 +301,10 @@ static memcached_return_t update_continuum(memcached_st *ptr) if (sort_host_length >= MEMCACHED_MAX_HOST_SORT_LENGTH || sort_host_length < 0) { - return MEMCACHED_FAILURE; + return memcached_set_error(*ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, + memcached_literal_param("snprintf(MEMCACHED_DEFAULT_COMMAND_SIZE)")); } - WATCHPOINT_ASSERT(sort_host_length); - if (is_ketama_weighted) { for (uint32_t x = 0; x < pointer_per_hash; x++)