File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ public function __destruct()
6464 {
6565 if ($ this ->id !== null && $ this ->worker ->isRunning ()) {
6666 $ id = $ this ->id ;
67+ $ this ->id = null ;
6768 $ worker = $ this ->worker ;
6869 EventLoop::queue (static fn () => $ worker ->execute (new Internal \FileTask ('fclose ' , [], $ id )));
6970 }
@@ -88,14 +89,19 @@ public function close(): void
8889
8990 $ this ->closing = async (function (): void {
9091 $ id = $ this ->id ;
91- $ this ->id = null ;
92- $ this ->worker ->execute (new Internal \FileTask ('fclose ' , [], $ id ));
92+ // Guard against explicit close calls happening inside garbage collection
93+ if ($ id !== null ) {
94+ $ this ->id = null ;
95+ $ this ->worker ->execute (new Internal \FileTask ('fclose ' , [], $ id ));
96+ }
9397 });
9498
9599 try {
96100 $ this ->closing ->await ();
97101 } finally {
98- $ this ->onClose ->complete ();
102+ if (!$ this ->onClose ->isComplete ()) {
103+ $ this ->onClose ->complete ();
104+ }
99105 $ this ->lockType = null ;
100106 }
101107 }
You can’t perform that action at this time.
0 commit comments