瀏覽代碼

Emit socket error if ipredis connection has been lost/reset.

The current code is checking for a failure (return false) or an empty buffer string, however
neither of these will be the case if the connection has been reset or has errored. According
to the docs for socket_recv, $buffer will be set to null if the connection is reset or their
is no data. As currently null is not allowed for, we enter an infinite loop, to prevent this
I've added null to the things we check before we emit a socket error. This prevents the
infinite loop and correctly results in an Exception if the connection is lost/reset.
Richard Heelin 10 年之前
父節點
當前提交
fe554ec870
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      lib/Predis/Connection/PhpiredisConnection.php

+ 1 - 1
lib/Predis/Connection/PhpiredisConnection.php

@@ -358,7 +358,7 @@ class PhpiredisConnection extends AbstractConnection
         $reader = $this->reader;
 
         while (($state = phpiredis_reader_get_state($reader)) === PHPIREDIS_READER_STATE_INCOMPLETE) {
-            if (@socket_recv($socket, $buffer, 4096, 0) === false || $buffer === '') {
+            if (@socket_recv($socket, $buffer, 4096, 0) === false || $buffer === '' || $buffer === null) {
                 $this->emitSocketError();
             }