fix: race condition in thread shutdown during drain

This commit is contained in:
Kévin Dunglas
2026-02-11 15:18:55 +01:00
parent 49d738012a
commit 82d6696c9d

View File

@@ -66,9 +66,11 @@ func (thread *phpThread) boot() {
// shutdown the underlying PHP thread
func (thread *phpThread) shutdown() {
if !thread.state.RequestSafeStateChange(state.ShuttingDown) {
// already shutting down or done
// already shutting down or done, wait for the C thread to finish
thread.state.WaitFor(state.Done, state.Reserved)
return
}
close(thread.drainChan)
thread.state.WaitFor(state.Done)
thread.drainChan = make(chan struct{})