mirror of
https://github.com/predis/predis.git
synced 2026-08-20 15:51:51 +00:00
Use stream_socket_recvfrom() in PhpiredisStreamConnection.
Similarly to the socket-ext based connection using phpiredis, in our stream based PhpiredisStreamConnection class we should read data from the stream using stream_socket_recvfrom() instead of fread() because the latter could block until a timeout is reached when the read buffer contains less data then the specified length. IMPORTANT: stream_socket_recvfrom() bypasses stream wrappers which means that TLS/SSL, as requested by PR #158, won't ever work with this connection class as the function returns the original encrypted bytes. This commit fixes issue #180.
This commit is contained in:
@@ -141,7 +141,7 @@ class PhpiredisStreamConnection extends StreamConnection
|
||||
$reader = $this->reader;
|
||||
|
||||
while (PHPIREDIS_READER_STATE_INCOMPLETE === $state = phpiredis_reader_get_state($reader)) {
|
||||
$buffer = fread($socket, 4096);
|
||||
$buffer = stream_socket_recvfrom($socket, 4096);
|
||||
|
||||
if ($buffer === false || $buffer === '') {
|
||||
$this->onConnectionError('Error while reading bytes from the server.');
|
||||
|
||||
Reference in New Issue
Block a user