Skip to content

Commit

Permalink
Remove stream subscription to write events on empty buffer.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nrk committed Aug 27, 2013
1 parent 7992c0f commit 94e64f4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Predis/Async/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
*/
class Client
{
const VERSION = '0.2.0';
const VERSION = '0.2.1-dev';

protected $profile;
protected $connection;
Expand Down
6 changes: 4 additions & 2 deletions lib/Predis/Async/Connection/StreamConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 94e64f4

Please sign in to comment.