From 27ca5b1f0a822d5f26882f829d342c8601d433d2 Mon Sep 17 00:00:00 2001 From: ljfuyuan Date: Tue, 12 May 2015 12:01:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=5Fmulti=5Fbulk=5Freply?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=9C=A8=E8=8E=B7=E5=8F=96=E5=A4=9A=E4=B8=AA?= =?UTF-8?q?=E7=A9=BA=E5=80=BC=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B=E8=B6=85?= =?UTF-8?q?=E6=97=B6=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复_multi_bulk_reply方法在获取多个空值的情况下超时问题。 如:hmget('aaaa','a','b'),当aaaa不存在时候,会导致超时 --- libraries/Redis.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libraries/Redis.php b/libraries/Redis.php index 1e4c389..0ee6f72 100644 --- a/libraries/Redis.php +++ b/libraries/Redis.php @@ -370,7 +370,8 @@ private function _bulk_reply() } } - + // Remove the new line and carriage return before reading another bulk reply + fgets($this->_connection); // Clear the socket in case anything remains in there $this->_clear_socket(); @@ -392,17 +393,16 @@ private function _multi_bulk_reply() // Loop all values and add them to the response array for ($i = 0; $i < $total_values; $i++) { - // Remove the new line and carriage return before reading - // another bulk reply + // Remove the '$' flags fgets($this->_connection, 2); // If this is a second or later pass, we also need to get rid // of the $ indicating a new bulk reply and its length. - if ($i > 0) - { - fgets($this->_connection); - fgets($this->_connection, 2); - } +// if ($i > 0) +// { +// fgets($this->_connection); +// fgets($this->_connection, 2); +// } $response[] = $this->_bulk_reply();