Merge pull request #5 from PVince81/stream_close_scare_away_ghosts

Prevent duplicate closeCallback calls in case of GC ghosts
This commit is contained in:
Robin Appelman 2016-12-02 15:21:23 +01:00 committed by GitHub
commit 6bfd2fdbd9

View file

@ -107,6 +107,8 @@ class CallbackWrapper extends Wrapper {
$result = parent::stream_close(); $result = parent::stream_close();
if (is_callable($this->closeCallback)) { if (is_callable($this->closeCallback)) {
call_user_func($this->closeCallback); call_user_func($this->closeCallback);
// prevent further calls by potential PHP 7 GC ghosts
$this->closeCallback = null;
} }
return $result; return $result;
} }