mirror of
https://github.com/predis/predis.git
synced 2026-09-13 20:07:28 +00:00
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. Conflicts: src/Connection/PhpiredisSocketConnection.php
This commit is contained in:
committed by
Daniele Alessandri
parent
5cd4f41424
commit
d84bca131b
@@ -354,7 +354,7 @@ class PhpiredisSocketConnection extends AbstractConnection
|
||||
$reader = $this->reader;
|
||||
|
||||
while (PHPIREDIS_READER_STATE_INCOMPLETE === $state = phpiredis_reader_get_state($reader)) {
|
||||
if (@socket_recv($socket, $buffer, 4096, 0) === false || $buffer === '') {
|
||||
if (@socket_recv($socket, $buffer, 4096, 0) === false || $buffer === '' || $buffer === null) {
|
||||
$this->emitSocketError();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user