Parcourir la source

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 il y a 10 ans
Parent
commit
fe554ec870
1 fichiers modifiés avec 1 ajouts et 1 suppressions
  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();
             }