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:
parent
8047db9b9c
commit
fdcf400f19
@ -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"));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user