Merge in fix so that we don't have to do weight on the const root
authorBrian Aker <brian@tangent.org>
Wed, 4 May 2011 00:45:03 +0000 (17:45 -0700)
committerBrian Aker <brian@tangent.org>
Wed, 4 May 2011 00:45:03 +0000 (17:45 -0700)
libmemcached/hosts.cc
libmemcached/server.cc
libmemcached/server_list.cc

index 885a79b7e8c5ffd84f8e3567d1d5387d2d81821c..6a8b660fb8c1a52faa0598b53d5e0b1e6bd39c9f 100644 (file)
@@ -343,10 +343,16 @@ memcached_return_t memcached_server_push(memcached_st *ptr, const memcached_serv
     /* TODO check return type */
     instance= memcached_server_create_with(ptr, instance, list[x].hostname,
                                            list[x].port, list[x].weight, list[x].type);
-    if (! instance)
+    if (not instance)
     {
       return memcached_set_error(ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE);
     }
+
+    if (list[x].weight > 1)
+    {
+      ptr->ketama.weighted= true;
+    }
+
     ptr->number_of_hosts++;
   }
 
@@ -440,7 +446,14 @@ static memcached_return_t server_add(memcached_st *ptr, const char *hostname,
 
   /* TODO: Check return type */
   instance= memcached_server_instance_fetch(ptr, memcached_server_count(ptr));
+
   (void)memcached_server_create_with(ptr, instance, hostname, port, weight, type);
+
+  if (weight > 1)
+  {
+    ptr->ketama.weighted= true;
+  }
+
   ptr->number_of_hosts++;
 
   instance= memcached_server_instance_fetch(ptr, 0);
index 1eb50ee4632a4ab655e301175e3b5189d2534b73..02078860c52dfe8ace27e0c00405a05fdd78c870 100644 (file)
@@ -51,11 +51,6 @@ 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)
index ca37f7f9a4b3f159e5f8747d50be33c4918a3698..8a76bf392981ca0b1515aa970446b3129b290a6a 100644 (file)
@@ -10,7 +10,7 @@
  */
 
 
-#include "common.h"
+#include <libmemcached/common.h>
 
 memcached_server_list_st 
 memcached_server_list_append_with_weight(memcached_server_list_st ptr,