Add support for AUTO_EJECT_HOST
[awesomized/libmemcached] / libmemcached / memcached_hash.c
index d2af51653be0e815511addc738d15f51aab22cf5..0527733a9b766503731a7054805664a75ee400f9 100644 (file)
@@ -179,6 +179,14 @@ uint32_t memcached_generate_hash(memcached_st *ptr, const char *key, size_t key_
 
   WATCHPOINT_ASSERT(hash);
 
+  if (memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS) && ptr->next_distribution_rebuild) {
+    struct timeval now;
+
+    if (gettimeofday(&now, NULL) == 0 &&
+        now.tv_sec > ptr->next_distribution_rebuild)
+      run_distribution(ptr);
+  }
+
   return dispatch_host(ptr, hash);
 }