mirror of
https://github.com/danog/byte-stream.git
synced 2024-12-02 17:28:21 +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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$resource = null;
|
||||||
$writable = false;
|
$writable = false;
|
||||||
|
|
||||||
$message = "Failed to write to socket";
|
$message = "Failed to write to socket";
|
||||||
@ -144,7 +145,7 @@ final class ResourceOutputStream implements OutputStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function send(string $data, bool $end = false): Promise {
|
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"));
|
return new Failure(new StreamException("The stream is not writable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user