1
0
mirror of https://github.com/danog/file.git synced 2024-11-26 20:04:51 +01:00

Ignore errors when closing

This commit is contained in:
Aaron Piotrowski 2017-06-23 17:47:22 -05:00
parent 2ce32d57ff
commit ad309f0cd2
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB
2 changed files with 4 additions and 13 deletions

View File

@ -201,18 +201,9 @@ class EioHandle implements Handle {
return $deferred->promise(); return $deferred->promise();
} }
private function onClose($deferred, $result, $req) { private function onClose(Deferred $deferred, $result, $req) {
if ($result === -1) { // Ignore errors when closing file, as the handle will become invalid anyway.
$error = \eio_get_last_error($req);
if ($error === "Bad file descriptor") {
// Handle is already closed, ignore
$deferred->resolve(); $deferred->resolve();
} else {
$deferred->fail(new StreamException("Closing the file failed: " . $error));
}
} else {
$deferred->resolve();
}
} }
/** /**

View File

@ -247,7 +247,7 @@ class UvHandle implements Handle {
$this->poll->listen($this->closing = $deferred->promise()); $this->poll->listen($this->closing = $deferred->promise());
\uv_fs_close($this->loop, $this->fh, function ($fh) use ($deferred) { \uv_fs_close($this->loop, $this->fh, function ($fh) use ($deferred) {
// FIXME: Check for errors // Ignore errors when closing file, as the handle will become invalid anyway.
$deferred->resolve(); $deferred->resolve();
}); });