From 94e64f4c81e0f28e935723090c3f61f74755f88b Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Tue, 27 Aug 2013 10:47:59 +0200 Subject: [PATCH] Remove stream subscription to write events on empty buffer. This commit fixes issue #5. The reported bug was introduced in v0.2.0 due to a breaking change in react/event-loop that was not properly addressed in Predis\Async after bumping the above mentioned dependency. Props to @bixuehujin for spotting the actual cause of the issue. --- lib/Predis/Async/Client.php | 2 +- lib/Predis/Async/Connection/StreamConnection.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Predis/Async/Client.php b/lib/Predis/Async/Client.php index 6356cdd..3b0035c 100644 --- a/lib/Predis/Async/Client.php +++ b/lib/Predis/Async/Client.php @@ -36,7 +36,7 @@ */ class Client { - const VERSION = '0.2.0'; + const VERSION = '0.2.1-dev'; protected $profile; protected $connection; diff --git a/lib/Predis/Async/Connection/StreamConnection.php b/lib/Predis/Async/Connection/StreamConnection.php index b646414..e27a305 100644 --- a/lib/Predis/Async/Connection/StreamConnection.php +++ b/lib/Predis/Async/Connection/StreamConnection.php @@ -374,11 +374,13 @@ protected function getIdentifier() */ public function write() { + $socket = $this->getResource(); + if ($this->buffer->isEmpty()) { - return false; + $this->loop->removeWriteStream($socket); + return; } - $socket = $this->getResource(); $buffer = $this->buffer->read(4096); if (-1 === $ret = @stream_socket_sendto($socket, $buffer)) {