From 0d0de3efc1cb8a1cd3e4b9bcc31c329a16dffce5 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Sat, 2 Apr 2011 21:19:46 -0700 Subject: [PATCH] Merge in behavior change such that if a weight is specified we now turn on weighting automagically. --- ChangeLog | 3 +++ libmemcached/server.c | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) 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); -- 2.30.2