Skip to content

Commit 23d51f0

Browse files
committed
Simplify interaction between Stream and Buffer
1 parent d5ade6b commit 23d51f0

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Stream.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ public function __construct($stream, LoopInterface $loop, WritableStreamInterfac
6363

6464
$this->buffer->on('error', function ($error) use ($that) {
6565
$that->emit('error', array($error, $that));
66-
$that->close();
6766
});
6867

68+
$this->buffer->on('close', array($this, 'close'));
69+
6970
$this->buffer->on('drain', function () use ($that) {
7071
$that->emit('drain', array($that));
7172
});
@@ -118,7 +119,7 @@ public function close()
118119
$this->emit('end', array($this));
119120
$this->emit('close', array($this));
120121
$this->loop->removeStream($this->stream);
121-
$this->buffer->removeAllListeners();
122+
$this->buffer->close();
122123
$this->removeAllListeners();
123124

124125
$this->handleClose();
@@ -135,8 +136,6 @@ public function end($data = null)
135136
$this->readable = false;
136137
$this->writable = false;
137138

138-
$this->buffer->on('close', array($this, 'close'));
139-
140139
$this->buffer->end($data);
141140
}
142141

0 commit comments

Comments
 (0)