MCPcopy Index your code
hub / github.com/php/frankenphp / RestartWorkers

Function RestartWorkers

worker.go:239–250  ·  view source on GitHub ↗

RestartWorkers attempts to restart all workers gracefully. All workers must be restarted at the same time to prevent issues with opcache resetting. Blocks until every worker thread has yielded; force-kill is armed after a grace period to wake threads parked in blocking syscalls so a stuck sleep does

()

Source from the content-addressed store, hash-verified

237// blocking syscalls so a stuck sleep doesn't make this hang for the
238// full duration of the syscall.
239func RestartWorkers() {
240 // disallow scaling threads while restarting workers
241 scalingMu.Lock()
242 defer scalingMu.Unlock()
243
244 threadsToRestart := drainWorkerThreads()
245
246 for _, thread := range threadsToRestart {
247 thread.drainChan = make(chan struct{})
248 thread.state.Set(state.Ready)
249 }
250}
251
252func (worker *worker) attachThread(thread *phpThread) {
253 worker.threadMutex.Lock()

Callers 3

restartWorkersMethod · 0.92
initWatchersFunction · 0.85

Calls 2

drainWorkerThreadsFunction · 0.85
SetMethod · 0.80

Tested by 1