File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ class ExtEventLoop implements LoopInterface
2222 private $ streamCallback ;
2323 private $ streamEvents = [];
2424 private $ streamFlags = [];
25+ private $ streamRefs = [];
2526 private $ readListeners = [];
2627 private $ writeListeners = [];
2728 private $ running ;
@@ -110,7 +111,8 @@ private function removeStream($stream)
110111 $ this ->streamFlags [$ key ],
111112 $ this ->streamEvents [$ key ],
112113 $ this ->readListeners [$ key ],
113- $ this ->writeListeners [$ key ]
114+ $ this ->writeListeners [$ key ],
115+ $ this ->streamRefs [$ key ]
114116 );
115117 }
116118 }
@@ -224,6 +226,12 @@ private function subscribeStreamEvent($stream, $flag)
224226
225227 $ this ->streamEvents [$ key ] = $ event ;
226228 $ this ->streamFlags [$ key ] = $ flag ;
229+
230+ // ext-event does not increase refcount on stream resources for PHP 7+
231+ // manually keep track of stream resource to prevent premature garbage collection
232+ if (PHP_VERSION_ID >= 70000 ) {
233+ $ this ->streamRefs [$ key ] = $ stream ;
234+ }
227235 }
228236
229237 $ event ->add ();
You can’t perform that action at this time.
0 commit comments