Merged Jean-Charles Redoutey
[awesomized/libmemcached] / libmemcached / memcached_connect.c
index 10df0198c15928c066330974b218664cc7ec34c0..cee75e4c7c24412752155464c4f5e263f2810d26 100644 (file)
@@ -310,18 +310,18 @@ memcached_return memcached_connect(memcached_server_st *ptr)
   WATCHPOINT_ASSERT(ptr->root);
   if (ptr->root->retry_timeout && ptr->root->server_failure_limit)
   {
-    struct timeval next_time;
+    struct timeval curr_time;
 
-    gettimeofday(&next_time, NULL);
+    gettimeofday(&curr_time, NULL);
 
     /* if we've had too many consecutive errors on this server, mark it dead. */
-    if (ptr->server_failure_counter > ptr->root->server_failure_limit)
+    if (ptr->server_failure_counter >= ptr->root->server_failure_limit)
     {
-      ptr->next_retry= next_time.tv_sec + ptr->root->retry_timeout;
+      ptr->next_retry= curr_time.tv_sec + ptr->root->retry_timeout;
       ptr->server_failure_counter= 0;
     }
 
-    if (next_time.tv_sec < ptr->next_retry)
+    if (curr_time.tv_sec < ptr->next_retry)
     {
       if (memcached_behavior_get(ptr->root, MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS))
         run_distribution(ptr->root);