Skip to content

Commit

Permalink
Suppress errors also for stream_socket_shutdown, relates to #32
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik committed Dec 10, 2017
1 parent c5e31aa commit 0c059ba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/ResourceInputStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ public function __construct($stream, int $chunkSize = self::DEFAULT_CHUNK_SIZE)

\assert($data !== false, "Trying to read from a previously fclose()'d resource. Do NOT manually fclose() resources the loop still has a reference to.");

// error suppression, because pthreads does crazy things with resources, which might be closed during two operations
// see https://github.com/amphp/byte-stream/issues/32
// Error suppression, because pthreads does crazy things with resources,
// which might be closed during two operations.
// See https://github.com/amphp/byte-stream/issues/32
if ($data === '' && @\feof($stream)) {
$readable = false;
Loop::cancel($watcher);
Expand Down Expand Up @@ -108,7 +109,7 @@ public function close() {
$meta = @\stream_get_meta_data($this->resource);

if ($meta && \strpos($meta["mode"], "+") !== false) {
\stream_socket_shutdown($this->resource, \STREAM_SHUT_RD);
@\stream_socket_shutdown($this->resource, \STREAM_SHUT_RD);
} else {
@\fclose($this->resource);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ResourceOutputStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function close() {
$meta = @\stream_get_meta_data($this->resource);

if ($meta && \strpos($meta["mode"], "+") !== false) {
\stream_socket_shutdown($this->resource, \STREAM_SHUT_WR);
@\stream_socket_shutdown($this->resource, \STREAM_SHUT_WR);
} else {
@\fclose($this->resource);
}
Expand Down

0 comments on commit 0c059ba

Please sign in to comment.