Skip to content

Commit 82d6696

Browse files
committed
fix: race condition in thread shutdown during drain
1 parent 49d7380 commit 82d6696

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

phpthread.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,11 @@ func (thread *phpThread) boot() {
6666
// shutdown the underlying PHP thread
6767
func (thread *phpThread) shutdown() {
6868
if !thread.state.RequestSafeStateChange(state.ShuttingDown) {
69-
// already shutting down or done
69+
// already shutting down or done, wait for the C thread to finish
70+
thread.state.WaitFor(state.Done, state.Reserved)
7071
return
7172
}
73+
7274
close(thread.drainChan)
7375
thread.state.WaitFor(state.Done)
7476
thread.drainChan = make(chan struct{})

0 commit comments

Comments
 (0)