libmemcached/connect.cc
/*
  backoff_handling()

  Based on time/failure count fail the connect without trying. This prevents waiting in a state where
  we get caught spending cycles just waiting.
*/
backoff_handling()
Based on time/failure count fail the connect without trying. This prevents waiting in a state where
we get caught spending cycles just waiting.
backoff_handling () Based on time / failure count fail the connect without trying . This prevents waiting in a state where we get caught spending cycles just waiting .
static memcached_return_t backoff_handling(memcached_server_write_instance_st server, bool& in_timeout)
{
  if (server->server_failure_counter >= server->root->server_failure_limit)
  {
    if (_is_auto_eject_host(server->root))
    {
      set_last_disconnected_host(server);
      run_distribution((memcached_st *)server->root);
      return memcached_set_error(*server, MEMCACHED_SERVER_MARKED_DEAD, MEMCACHED_AT);
    }
    server->state= MEMCACHED_SERVER_STATE_IN_TIMEOUT;
    if (server->next_retry == 0)
    {
      server->next_retry= 1;
    }
  }
  if (server->state == MEMCACHED_SERVER_STATE_IN_TIMEOUT)
  {
    struct timeval curr_time;
    bool _gettime_success= (gettimeofday(&curr_time, NULL) == 0);
    if (_gettime_success and server->next_retry < curr_time.tv_sec)
    {
      server->state= MEMCACHED_SERVER_STATE_NEW;
    }
    else
    {
      return memcached_set_error(*server, MEMCACHED_SERVER_TEMPORARILY_DISABLED, MEMCACHED_AT);
    }
    in_timeout= true;
  }
  return MEMCACHED_SUCCESS;
}
static memcached_return_t backoff_handling ( memcached_server_write_instance_st server , bool & in_timeout ) { if ( server -> server_failure_counter >= server -> root -> server_failure_limit ) { if ( _is_auto_eject_host ( server -> root ) ) { set_last_disconnected_host ( server ) ; run_distribution ( ( memcached_st * ) server -> root ) ; return memcached_set_error ( * server , MEMCACHED_SERVER_MARKED_DEAD , MEMCACHED_AT ) ; } server -> state = MEMCACHED_SERVER_STATE_IN_TIMEOUT ; if ( server -> next_retry == 0 ) { server -> next_retry = 1 ; } } if ( server -> state == MEMCACHED_SERVER_STATE_IN_TIMEOUT ) { struct timeval curr_time ; bool _gettime_success = ( gettimeofday ( & curr_time , NULL ) == 0 ) ; if ( _gettime_success and server -> next_retry < curr_time . tv_sec ) { server -> state = MEMCACHED_SERVER_STATE_NEW ; } else { return memcached_set_error ( * server , MEMCACHED_SERVER_TEMPORARILY_DISABLED , MEMCACHED_AT ) ; } in_timeout = true ; } return MEMCACHED_SUCCESS ; }
backoff_handling()
Based on time/failure count fail the connect without trying.
backoff_handling () Based on time / failure count fail the connect without trying .
/* 
    If we hit server_failure_limit then something is completely wrong about the server.

    1) If autoeject is enabled we do that.
    2) If not? We go into timeout again, there is much else to do :(
  */ /*
      We just auto_eject if we hit this point 
    */ // Sanity check/setting /*
      If next_retry is less then our current time, then we reset and try everything again.
    */