protected _reconnect ( ) |
protected function _reconnect()
{
/* Return if we are already connected. */
if ($this->_link) {
return;
}
/* Sleep for a backoff period in seconds. */
sleep($this->_config['current_backoff']);
/* Retry all available connections. */
$this->_downHostList = array();
try {
$this->_connect();
} catch (Horde_Ldap_Exception $e) {
$this->_config['current_backoff'] *= 2;
if ($this->_config['current_backoff'] > $this->_config['max_backoff']) {
$this->_config['current_backoff'] = $this->_config['max_backoff'];
}
throw $e;
}
/* Now we should be able to safely (re-)bind. */
try {
$this->bind();
} catch (Exception $e) {
$this->_config['current_backoff'] *= 2;
if ($this->_config['current_backoff'] > $this->_config['max_backoff']) {
$this->_config['current_backoff'] = $this->_config['max_backoff'];
}
/* $this->_config['hostspec'] should have had the last connected
* host stored in it by _connect(). Since we are unable to
* bind to that host we can safely assume that it is down or has
* some other problem. */
$this->_downHostList[] = $this->_config['hostspec'];
throw $e;
}
/* At this stage we have connected, bound, and set up options, so we
* have a known good LDAP server. Time to go home. */
$this->_config['current_backoff'] = $this->_config['min_backoff'];
}