mirror of
https://github.com/php/frankenphp.git
synced 2026-03-24 00:52:11 +01:00
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:
committed by
GitHub
parent
11160fb7b3
commit
ecad5ec0a0
@@ -79,6 +79,9 @@ func initPHPThreads(numThreads int, numMaxThreads int, phpIni map[string]string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func drainPHPThreads() {
|
func drainPHPThreads() {
|
||||||
|
if mainThread == nil {
|
||||||
|
return // mainThread was never initialized
|
||||||
|
}
|
||||||
doneWG := sync.WaitGroup{}
|
doneWG := sync.WaitGroup{}
|
||||||
doneWG.Add(len(phpThreads))
|
doneWG.Add(len(phpThreads))
|
||||||
mainThread.state.Set(state.ShuttingDown)
|
mainThread.state.Set(state.ShuttingDown)
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ func TestTransitionThreadsWhileDoingRequests(t *testing.T) {
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
isDone atomic.Bool
|
isDone atomic.Bool
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
)
|
)
|
||||||
|
|
||||||
numThreads := 10
|
numThreads := 10
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type hotReloadOpt struct {
|
type hotReloadOpt struct {
|
||||||
hotReload []*watcher.PatternGroup
|
hotReload []*watcher.PatternGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
var restartWorkers atomic.Bool
|
var restartWorkers atomic.Bool
|
||||||
|
|||||||
Reference in New Issue
Block a user