fix: prevent segfault on early shutdown. (#2120)

Fixes #2114

This early
[Shutdown](11160fb7b3/frankenphp.go (L281))
introduced in #2031 segfaults instead of returning an error since
threads have not started yet.
This commit is contained in:
Alexander Stecher
2026-01-10 21:40:54 +01:00
committed by GitHub
parent 11160fb7b3
commit ecad5ec0a0
3 changed files with 5 additions and 2 deletions

View File

@@ -79,6 +79,9 @@ func initPHPThreads(numThreads int, numMaxThreads int, phpIni map[string]string)
}
func drainPHPThreads() {
if mainThread == nil {
return // mainThread was never initialized
}
doneWG := sync.WaitGroup{}
doneWG.Add(len(phpThreads))
mainThread.state.Set(state.ShuttingDown)

View File

@@ -96,7 +96,7 @@ func TestTransitionThreadsWhileDoingRequests(t *testing.T) {
var (
isDone atomic.Bool
wg sync.WaitGroup
wg sync.WaitGroup
)
numThreads := 10

View File

@@ -10,7 +10,7 @@ import (
)
type hotReloadOpt struct {
hotReload []*watcher.PatternGroup
hotReload []*watcher.PatternGroup
}
var restartWorkers atomic.Bool