/** * Get a connection to the Swift proxy * * @return CF_Connection|false * @throws InvalidResponseException */ protected function getConnection() { if ($this->conn === false) { throw new InvalidResponseException(); // failed last attempt } // Session keys expire after a while, so we renew them periodically if ($this->conn && time() - $this->connStarted > $this->authTTL) { $this->conn->close(); // close active cURL connections $this->conn = null; } // Authenticate with proxy and get a session key... if ($this->conn === null) { $this->connContainers = array(); try { $this->auth->authenticate(); $this->conn = new CF_Connection($this->auth); $this->connStarted = time(); } catch (AuthenticationException $e) { $this->conn = false; // don't keep re-trying } catch (InvalidResponseException $e) { $this->conn = false; // don't keep re-trying } } if (!$this->conn) { throw new InvalidResponseException(); // auth/connection problem } return $this->conn; }
/** * Close the connection to the Swift proxy * * @return void */ protected function closeConnection() { if ( $this->conn ) { $this->conn->close(); // close active cURL handles in CF_Http object $this->conn = null; $this->sessionStarted = 0; $this->connContainerCache->clear(); } }
/** * Close the connection to the Swift proxy * * @return void */ protected function closeConnection() { if ($this->conn) { $this->srvCache->delete($this->getCredsCacheKey($this->auth->username)); $this->conn->close(); // close active cURL handles in CF_Http object $this->conn = null; $this->connStarted = 0; } }