File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ import (
3232 "runtime"
3333 "strings"
3434 "sync"
35+ "sync/atomic"
3536 "syscall"
3637 "time"
3738 "unsafe"
6667
6768 metrics Metrics = nullMetrics {}
6869
69- maxWaitTime time.Duration
70+ // atomic: read by in-flight requests while a reload may rewrite it
71+ maxWaitTime atomic.Int64
7072 maxRequestsPerThread int
7173)
7274
@@ -275,7 +277,7 @@ func Init(options ...Option) error {
275277 metrics = opt .metrics
276278 }
277279
278- maxWaitTime = opt .maxWaitTime
280+ maxWaitTime . Store ( int64 ( opt .maxWaitTime ))
279281 maxRequestsPerThread = opt .maxRequests
280282
281283 if opt .maxIdleTime > 0 {
Original file line number Diff line number Diff line change 66 "runtime"
77 "sync"
88 "sync/atomic"
9+ "time"
910
1011 "github.com/dunglas/frankenphp/internal/state"
1112)
@@ -169,7 +170,7 @@ func handleRequestWithRegularPHPThreads(ch contextHolder) error {
169170 return nil
170171 case scaleChan <- ch .frankenPHPContext :
171172 // the request has triggered scaling, continue to wait for a thread
172- case <- timeoutChan (maxWaitTime ):
173+ case <- timeoutChan (time . Duration ( maxWaitTime . Load ()) ):
173174 // the request has timed out stalling
174175 queuedRegularThreads .Add (- 1 )
175176 metrics .DequeuedRequest ()
You can’t perform that action at this time.
0 commit comments