mirror of
https://github.com/dunglas/frankenphp.git
synced 2026-04-22 16:27:12 +08:00
fix: prevent segfault on early shutdown. (#2120)
Fixes #2114 This early [Shutdown](https://github.com/php/frankenphp/blob/11160fb7b31171d706cf9933abb9102dbb1cdb3c/frankenphp.go#L281) introduced in #2031 segfaults instead of returning an error since threads have not started yet.
This commit is contained in:
committed by
GitHub
parent
11160fb7b3
commit
ecad5ec0a0
@@ -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)
|
||||
|
||||
@@ -96,7 +96,7 @@ func TestTransitionThreadsWhileDoingRequests(t *testing.T) {
|
||||
|
||||
var (
|
||||
isDone atomic.Bool
|
||||
wg sync.WaitGroup
|
||||
wg sync.WaitGroup
|
||||
)
|
||||
|
||||
numThreads := 10
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import (
|
||||
)
|
||||
|
||||
type hotReloadOpt struct {
|
||||
hotReload []*watcher.PatternGroup
|
||||
hotReload []*watcher.PatternGroup
|
||||
}
|
||||
|
||||
var restartWorkers atomic.Bool
|
||||
|
||||
Reference in New Issue
Block a user