Skip to content

Commit 3698022

Browse files
committed
Avoid SEGFAULTs for ext-event on Windows by clearing all Event refs
1 parent 47ab46f commit 3698022

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ matrix:
5151
- php -r "file_put_contents(php_ini_loaded_file(),'extension=event'.PHP_EOL,FILE_APPEND);"
5252
install:
5353
- composer install
54-
script:
55-
- vendor/bin/phpunit --coverage-text || ([[ $? = 139 ]] && echo && echo "Ignoring SEGFAULT.." >&2) # ignore unrelated SEGFAULT when all tests pass
5654
allow_failures:
5755
- php: hhvm
5856
- os: windows

src/ExtEventLoop.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@ public function __construct()
5959
$this->createStreamCallback();
6060
}
6161

62+
public function __destruct()
63+
{
64+
// explicitly clear all references to Event objects to prevent SEGFAULTs on Windows
65+
foreach ($this->timerEvents as $timer) {
66+
$this->timerEvents->detach($timer);
67+
}
68+
69+
$this->readEvents = array();
70+
$this->writeEvents = array();
71+
}
72+
6273
public function addReadStream($stream, $listener)
6374
{
6475
$key = (int) $stream;

0 commit comments

Comments
 (0)