1
0
mirror of https://github.com/danog/byte-stream.git synced 2024-11-30 04:19:23 +01:00

Check writable flag rather than for null resource

Also null resource when writing in watcher callback fails. Fixes #20.
This commit is contained in:
Aaron Piotrowski 2017-09-15 00:17:42 -05:00
parent 8047db9b9c
commit fdcf400f19
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB

View File

@ -81,6 +81,7 @@ final class ResourceOutputStream implements OutputStream {
return;
}
$resource = null;
$writable = false;
$message = "Failed to write to socket";
@ -144,7 +145,7 @@ final class ResourceOutputStream implements OutputStream {
}
private function send(string $data, bool $end = false): Promise {
if ($this->resource === null) {
if (!$this->writable) {
return new Failure(new StreamException("The stream is not writable"));
}