55use BadMethodCallException ;
66use Event ;
77use EventBase ;
8- use EventConfig as EventBaseConfig ;
98use React \EventLoop \Tick \FutureTickQueue ;
109use React \EventLoop \Timer \Timer ;
1110use 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 ();
@@ -55,6 +59,17 @@ public function __construct()
5559 $ this ->createStreamCallback ();
5660 }
5761
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+
5873 public function addReadStream ($ stream , $ listener )
5974 {
6075 $ key = (int ) $ stream ;
0 commit comments