Skip to content

Commit 2f85e8e

Browse files
committed
Fix unsupported EventConfig for ext-event on Windows
1 parent 131d92d commit 2f85e8e

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@ matrix:
3737
- export PATH="$(powershell -Command '("Process", "Machine" | % { [Environment]::GetEnvironmentVariable("PATH", $_) -Split ";" -Replace "\\$", "" } | Select -Unique | % { cygpath $_ }) -Join ":"')"
3838
install:
3939
- composer install
40+
- name: "Windows PHP 7.2 with ext-event"
41+
os: windows
42+
language: shell # no built-in php support
43+
before_install:
44+
- curl -OL https://windows.php.net/downloads/pecl/releases/event/2.5.3/php_event-2.5.3-7.2-nts-vc15-x64.zip # latest version as of 2019-12-23
45+
- choco install php --version=7.2.26 # latest version supported by ext-event as of 2019-12-23
46+
- choco install composer
47+
- export PATH="$(powershell -Command '("Process", "Machine" | % { [Environment]::GetEnvironmentVariable("PATH", $_) -Split ";" -Replace "\\$", "" } | Select -Unique | % { cygpath $_ }) -Join ":"')"
48+
- php -r "\$z=new ZipArchive();\$z->open(glob('php_event*.zip')[0]);\$z->extractTo(dirname(php_ini_loaded_file()).'/ext','php_event.dll');"
49+
- php -r "file_put_contents(php_ini_loaded_file(),'extension_dir=ext'.PHP_EOL,FILE_APPEND);"
50+
- php -r "file_put_contents(php_ini_loaded_file(),'extension=sockets'.PHP_EOL,FILE_APPEND);" # ext-sockets needs to be loaded before ext-event
51+
- php -r "file_put_contents(php_ini_loaded_file(),'extension=event'.PHP_EOL,FILE_APPEND);"
52+
install:
53+
- composer install
4054
allow_failures:
4155
- php: hhvm
4256
- os: windows

src/ExtEventLoop.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use BadMethodCallException;
66
use Event;
77
use EventBase;
8-
use EventConfig as EventBaseConfig;
98
use React\EventLoop\Tick\FutureTickQueue;
109
use React\EventLoop\Timer\Timer;
1110
use SplObjectStorage;
@@ -43,8 +42,13 @@ public function __construct()
4342
throw new BadMethodCallException('Cannot create ExtEventLoop, ext-event extension missing');
4443
}
4544

46-
$config = new EventBaseConfig();
47-
$config->requireFeatures(EventBaseConfig::FEATURE_FDS);
45+
// support arbitrary file descriptors and not just sockets
46+
// Windows only has limited file descriptor support, so do not require this (will fail otherwise)
47+
// @link http://www.wangafu.net/~nickm/libevent-book/Ref2_eventbase.html#_setting_up_a_complicated_event_base
48+
$config = new \EventConfig();
49+
if (\DIRECTORY_SEPARATOR !== '\\') {
50+
$config->requireFeatures(\EventConfig::FEATURE_FDS);
51+
}
4852

4953
$this->eventBase = new EventBase($config);
5054
$this->futureTickQueue = new FutureTickQueue();

0 commit comments

Comments
 (0)