5
5
use BadMethodCallException ;
6
6
use Event ;
7
7
use EventBase ;
8
- use EventConfig as EventBaseConfig ;
9
8
use React \EventLoop \Tick \FutureTickQueue ;
10
9
use React \EventLoop \Timer \Timer ;
11
10
use SplObjectStorage ;
@@ -43,8 +42,13 @@ public function __construct()
43
42
throw new BadMethodCallException ('Cannot create ExtEventLoop, ext-event extension missing ' );
44
43
}
45
44
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
+ }
48
52
49
53
$ this ->eventBase = new EventBase ($ config );
50
54
$ this ->futureTickQueue = new FutureTickQueue ();
@@ -55,6 +59,17 @@ public function __construct()
55
59
$ this ->createStreamCallback ();
56
60
}
57
61
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
+
58
73
public function addReadStream ($ stream , $ listener )
59
74
{
60
75
$ key = (int ) $ stream ;
0 commit comments