From 0a56469fd800765d5b3d1775d478a10e9301d35e Mon Sep 17 00:00:00 2001 From: Robert Landers Date: Tue, 25 Nov 2025 17:53:28 +0100 Subject: [PATCH] revert usage of context Signed-off-by: Robert Landers --- semaphore-admission.go | 13 ++++++------- threadregular.go | 2 +- worker.go | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/semaphore-admission.go b/semaphore-admission.go index 26e95f8e..43d6af1d 100644 --- a/semaphore-admission.go +++ b/semaphore-admission.go @@ -7,7 +7,6 @@ import ( ) func acquireSemaphoreWithAdmissionControl( - ctx context.Context, sem *semaphore.Weighted, scaleChan chan *frankenPHPContext, fc *frankenPHPContext, @@ -17,7 +16,7 @@ func acquireSemaphoreWithAdmissionControl( } if maxWaitTime > 0 && scaleChan != nil { - ct, cancel := context.WithTimeout(ctx, minStallTime) + ct, cancel := context.WithTimeout(context.Background(), minStallTime) err := sem.Acquire(ct, 1) cancel() @@ -27,7 +26,7 @@ func acquireSemaphoreWithAdmissionControl( default: } - ctx, cancel := context.WithTimeout(ctx, maxWaitTime) + ctx, cancel := context.WithTimeout(context.Background(), maxWaitTime) defer cancel() if err := sem.Acquire(ctx, 1); err != nil { @@ -39,7 +38,7 @@ func acquireSemaphoreWithAdmissionControl( } if maxWaitTime > 0 { - ctx, cancel := context.WithTimeout(ctx, maxWaitTime) + ctx, cancel := context.WithTimeout(context.Background(), maxWaitTime) defer cancel() if err := sem.Acquire(ctx, 1); err != nil { @@ -50,7 +49,7 @@ func acquireSemaphoreWithAdmissionControl( } if scaleChan != nil { - ctx, cancel := context.WithTimeout(ctx, minStallTime) + ctx, cancel := context.WithTimeout(context.Background(), minStallTime) err := sem.Acquire(ctx, 1) cancel() @@ -60,14 +59,14 @@ func acquireSemaphoreWithAdmissionControl( default: } - if err := sem.Acquire(ctx, 1); err != nil { + if err := sem.Acquire(context.Background(), 1); err != nil { return ErrMaxWaitTimeExceeded } } return nil } - if err := sem.Acquire(ctx, 1); err != nil { + if err := sem.Acquire(context.Background(), 1); err != nil { return ErrMaxWaitTimeExceeded } diff --git a/threadregular.go b/threadregular.go index 1580b47e..141e68a9 100644 --- a/threadregular.go +++ b/threadregular.go @@ -113,7 +113,7 @@ func handleRequestWithRegularPHPThreads(ch contextHolder) error { metrics.StartRequest() metrics.QueuedRequest() - if err := acquireSemaphoreWithAdmissionControl(ch.ctx, regularSemaphore, scaleChan, ch.frankenPHPContext); err != nil { + if err := acquireSemaphoreWithAdmissionControl(regularSemaphore, scaleChan, ch.frankenPHPContext); err != nil { ch.frankenPHPContext.reject(err) metrics.StopRequest() return err diff --git a/worker.go b/worker.go index 1efdab76..13e655a6 100644 --- a/worker.go +++ b/worker.go @@ -258,7 +258,7 @@ func (worker *worker) handleRequest(ch contextHolder) error { workerScaleChan = nil } - if err := acquireSemaphoreWithAdmissionControl(ch.ctx, worker.semaphore, workerScaleChan, ch.frankenPHPContext); err != nil { + if err := acquireSemaphoreWithAdmissionControl(worker.semaphore, workerScaleChan, ch.frankenPHPContext); err != nil { metrics.DequeuedWorkerRequest(worker.name) ch.frankenPHPContext.reject(err) metrics.StopWorkerRequest(worker.name, time.Since(ch.frankenPHPContext.startedAt))