소스 검색

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();
             }