Skip to content

Commit d1e28d5

Browse files
committed
Adjusts waitgroup logic.
1 parent 2a9a9a8 commit d1e28d5

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

frankenphp.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -765,11 +765,12 @@ func go_schedule_opcache_reset(threadIndex C.uintptr_t) C.bool {
765765
return C.bool(true)
766766
}
767767

768+
// always call the original opcache_reset if already restarting
768769
return C.bool(phpThreads[threadIndex].state.Is(state.Restarting))
769770
}
770771

771772
// restart all threads for an opcache_reset
772-
func restartThreadsForOpcacheReset(exceptThisThread *phpThread) {
773+
func restartThreadsForOpcacheReset(callingThread *phpThread) {
773774
if threadsAreRestarting.Load() {
774775
// ignore reloads while a restart is already ongoing
775776
return
@@ -792,16 +793,13 @@ func restartThreadsForOpcacheReset(exceptThisThread *phpThread) {
792793
thread.state.Set(state.Restarting)
793794
close(thread.drainChan)
794795

795-
if thread == exceptThisThread {
796-
continue
797-
}
798-
799796
wg.Go(func() {
800797
thread.state.WaitFor(state.Yielding)
801798
})
802799
}
803800
}
804801

802+
wg.Done() // ignore the calling thread
805803
done := make(chan struct{})
806804
go func() {
807805
wg.Wait()
@@ -816,7 +814,7 @@ func restartThreadsForOpcacheReset(exceptThisThread *phpThread) {
816814
}
817815

818816
go func() {
819-
exceptThisThread.state.WaitFor(state.Yielding)
817+
callingThread.state.WaitFor(state.Yielding)
820818
for _, thread := range threadsToRestart {
821819
thread.drainChan = make(chan struct{})
822820
thread.state.Set(state.Ready)

0 commit comments

Comments
 (0)