From: Brian Aker Date: Sun, 3 Apr 2011 04:19:46 +0000 (-0700) Subject: Merge in behavior change such that if a weight is specified we now turn on X-Git-Tag: 0.51~15^2~50 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=0d0de3efc1cb8a1cd3e4b9bcc31c329a16dffce5;p=m6w6%2Flibmemcached Merge in behavior change such that if a weight is specified we now turn on weighting automagically. --- diff --git a/ChangeLog b/ChangeLog index 9c0bea9c..b2ca1f74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,9 @@ * New parser calls for generating memcached_st objects. * New error system. + * A behavior change has been now made that if you specify a weight for any + server, we enable the weight flag and do weight balancing. + 0.48 Tue Mar 15 23:05:18 PDT 2011 * Fix memory leak in server parse. * Move test framework out to be its own library (easier to work with Gearman). diff --git a/libmemcached/server.c b/libmemcached/server.c index fa750c25..ea44092c 100644 --- a/libmemcached/server.c +++ b/libmemcached/server.c @@ -52,12 +52,21 @@ static inline void _server_init(memcached_server_st *self, const memcached_st *r self->next_retry= 0; } + if (self->weight > 1 && root) + { + ((memcached_st *)root)->ketama.weighted= true; + } + self->root= root; self->limit_maxbytes= 0; if (hostname == NULL) + { self->hostname[0]= 0; + } else + { strncpy(self->hostname, hostname, NI_MAXHOST - 1); + } } static memcached_server_st *_server_create(memcached_server_st *self, const memcached_st *memc) @@ -246,8 +255,6 @@ void memcached_server_list_free(memcached_server_list_st self) if (self == NULL) return; - const memcached_st *root= self->root; - for (uint32_t x= 0; x < memcached_server_list_count(self); x++) { if (self[x].address_info) @@ -257,6 +264,7 @@ void memcached_server_list_free(memcached_server_list_st self) } } + const memcached_st *root= self->root; if (root) { libmemcached_free(root, self);