From 45e72198d91e50c04f00f19e5bf75abfa37bfb2c Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Sat, 9 Mar 2013 13:34:22 -0800 Subject: [PATCH] Fixed connection comparison in RedisConnectionPool::handleException(). * This was comparing a Redis with a RedisConnRef. Change-Id: I6353736c8ad42a18d90e8474d38398d305950346 --- includes/clientpool/RedisConnectionPool.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/includes/clientpool/RedisConnectionPool.php b/includes/clientpool/RedisConnectionPool.php index 0c91222085..8a3a1be879 100644 --- a/includes/clientpool/RedisConnectionPool.php +++ b/includes/clientpool/RedisConnectionPool.php @@ -255,15 +255,14 @@ class RedisConnectionPool { * object and let it be reopened during the next request. * * @param $server string - * @param $conn RedisConnRef + * @param $cref RedisConnRef * @param $e RedisException * @return void */ - public function handleException( $server, RedisConnRef $conn, RedisException $e ) { - wfDebugLog( 'redis', - "Redis exception on server $server: " . $e->getMessage() . "\n" ); + public function handleException( $server, RedisConnRef $cref, RedisException $e ) { + wfDebugLog( 'redis', "Redis exception on server $server: " . $e->getMessage() . "\n" ); foreach ( $this->connections[$server] as $key => $connection ) { - if ( $connection['conn'] === $conn ) { + if ( $cref->isConnIdentical( $connection['conn'] ) ) { $this->idlePoolSize -= $connection['free'] ? 1 : 0; unset( $this->connections[$server][$key] ); break; @@ -281,12 +280,11 @@ class RedisConnectionPool { class RedisConnRef { /** @var RedisConnectionPool */ protected $pool; - - protected $server; // string - /** @var Redis */ protected $conn; + protected $server; // string + /** * @param $pool RedisConnectionPool * @param $server string @@ -302,6 +300,10 @@ class RedisConnRef { return call_user_func_array( array( $this->conn, $name ), $arguments ); } + public function isConnIdentical( Redis $conn ) { + return $this->conn === $conn; + } + function __destruct() { $this->pool->freeConnection( $this->server, $this->conn ); } -- 2.20.1