Skip to content

Commit

Permalink
Fix segfault with ev on shutdown, fixes amphp/parallel#3
Browse files Browse the repository at this point in the history
  • Loading branch information
kelunik committed Dec 19, 2017
1 parent be3ae73 commit 3f08f61
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/Loop/EvDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ public function __destruct() {
foreach ($this->events as $event) {
$event->stop();
}

// We need to clear all references to events manually, see
// https://bitbucket.org/osmanov/pecl-ev/issues/31/segfault-in-ev_timer_stop
$this->events = [];
}

/**
Expand Down Expand Up @@ -231,6 +235,7 @@ protected function activate(array $watchers) {
protected function deactivate(Watcher $watcher) {
if (isset($this->events[$id = $watcher->id])) {
$this->events[$id]->stop();

if ($watcher->type === Watcher::SIGNAL) {
unset($this->signals[$id]);
}
Expand Down

0 comments on commit 3f08f61

Please sign in to comment.