Completed work on Ketama (it is now dynamic)
author <brian@localhost.localdomain> <>
Mon, 21 Apr 2008 17:08:50 +0000 (10:08 -0700)
committer <brian@localhost.localdomain> <>
Mon, 21 Apr 2008 17:08:50 +0000 (10:08 -0700)
libmemcached/memcached.c
libmemcached/memcached_behavior.c
libmemcached/memcached_hash.c

index 353d135f312b0c7e0465ec637d8a88449bcdf16f..bcc0477deaa4c2a369492a02012258a6c9c1abbe 100644 (file)
@@ -41,6 +41,14 @@ void memcached_free(memcached_st *ptr)
   if (ptr->on_cleanup)
     ptr->on_cleanup(ptr);
 
+  if (ptr->continuum)
+  {
+    if (ptr->call_free)
+      ptr->call_free(ptr, ptr->continuum);
+    else
+      free(ptr->continuum);
+  }
+
   if (ptr->is_allocated == MEMCACHED_ALLOCATED)
   {
     if (ptr->call_free)
index 287f8f0ce0ac344a30958b1f1e8efa1e0e51ea6b..351b87cd90be859b25ff73ddd1e24663ed3b6075 100644 (file)
@@ -38,8 +38,11 @@ memcached_return memcached_behavior_set(memcached_st *ptr,
     memcached_quit(ptr);
     break;
   case MEMCACHED_BEHAVIOR_DISTRIBUTION:
-    ptr->distribution= (memcached_server_distribution)(data);
-    break;
+    {
+      ptr->distribution= (memcached_server_distribution)(data);
+      run_distribution(ptr);
+      break;
+    }
   case MEMCACHED_BEHAVIOR_HASH:
     ptr->hash= (memcached_hash)(data);
     break;
@@ -56,12 +59,7 @@ memcached_return memcached_behavior_set(memcached_st *ptr,
   case MEMCACHED_BEHAVIOR_SORT_HOSTS:
     {
       set_behavior_flag(ptr, MEM_USE_SORT_HOSTS, data);
-
-      if (ptr->flags & MEM_USE_SORT_HOSTS)
-      {
-        memcached_quit(ptr);
-        run_distribution(ptr);
-      }
+      run_distribution(ptr);
 
       break;
     }
index 3294a0a6875c16a87e113f35967b7c415b8f4b8a..c0e928a10cd90e86e7f32613e8762465272e46f2 100644 (file)
@@ -110,6 +110,7 @@ unsigned int dispatch_host(memcached_st *ptr, uint32_t hash)
   case MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA:
     {
       int num= ptr->number_of_hosts * MEMCACHED_POINTS_PER_SERVER;
+      WATCHPOINT_ASSERT(ptr->continuum);
 
       hash= hash;
       memcached_continuum_item_st *begin, *end, *left, *right, *middle;