Skip to content

Commit

Permalink
Prevent duplicate closeCallback calls in case of GC ghosts
Browse files Browse the repository at this point in the history
Sometimes PHP 7 GC decides to call stream_close again even after the
PHP request has ended, and even if fclose was called before already.
  • Loading branch information
PVince81 committed Dec 2, 2016
1 parent 0700f81 commit 668abfe
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/CallbackWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ public function stream_close() {
$result = parent::stream_close();
if (is_callable($this->closeCallback)) {
call_user_func($this->closeCallback);
// prevent further calls by potential PHP 7 GC ghosts
$this->closeCallback = null;
}
return $result;
}
Expand Down

0 comments on commit 668abfe

Please sign in to comment.