|
@@ -229,7 +229,7 @@ class PhpiredisSocketConnection extends AbstractConnection
|
|
|
* @param ParametersInterface $parameters Parameters used to initialize the connection.
|
|
|
* @return string
|
|
|
*/
|
|
|
- private static function getAddress(ParametersInterface $parameters)
|
|
|
+ protected static function getAddress(ParametersInterface $parameters)
|
|
|
{
|
|
|
if ($parameters->scheme === 'unix') {
|
|
|
return $parameters->path;
|
|
@@ -238,8 +238,8 @@ class PhpiredisSocketConnection extends AbstractConnection
|
|
|
$host = $parameters->host;
|
|
|
|
|
|
if (ip2long($host) === false) {
|
|
|
- if (($addresses = gethostbynamel($host)) === false) {
|
|
|
- $this->onConnectionError("Cannot resolve the address of '$host'.");
|
|
|
+ if (false === $addresses = gethostbynamel($host)) {
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
return $addresses[array_rand($addresses)];
|
|
@@ -256,7 +256,10 @@ class PhpiredisSocketConnection extends AbstractConnection
|
|
|
*/
|
|
|
private function connectWithTimeout(ParametersInterface $parameters)
|
|
|
{
|
|
|
- $host = self::getAddress($parameters);
|
|
|
+ if (false === $host = self::getAddress($parameters)) {
|
|
|
+ $this->onConnectionError("Cannot resolve the address of '$parameters->host'.");
|
|
|
+ }
|
|
|
+
|
|
|
$socket = $this->getResource();
|
|
|
|
|
|
socket_set_nonblock($socket);
|