Skip to content

Commit

Permalink
Fixes race condition on restarts in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alliballibaba2 committed Jan 27, 2025
1 parent 2135354 commit 69597ef
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions scaling.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func initAutoScaling(mainThread *phpMainThread) {
autoScaledThreads = make([]*phpThread, 0, maxScaledThreads)
scalingMu.Unlock()

go startUpscalingThreads(mainThread.done, maxScaledThreads)
go startUpscalingThreads(maxScaledThreads, scaleChan, mainThread.done)
go startDownScalingThreads(mainThread.done)
}

Expand Down Expand Up @@ -155,7 +155,7 @@ func scaleRegularThread() {
autoScaledThreads = append(autoScaledThreads, thread)
}

func startUpscalingThreads(done chan struct{}, maxScaledThreads int) {
func startUpscalingThreads(maxScaledThreads int, scale chan *FrankenPHPContext, done chan struct{}) {
for {
scalingMu.Lock()
scaledThreadCount := len(autoScaledThreads)
Expand All @@ -171,7 +171,7 @@ func startUpscalingThreads(done chan struct{}, maxScaledThreads int) {
}

select {
case fc := <-scaleChan:
case fc := <-scale:
timeSinceStalled := time.Since(fc.startedAt)

// if the request has not been stalled long enough, wait and repeat
Expand Down

0 comments on commit 69597ef

Please sign in to comment.