revert usage of context

Signed-off-by: Robert Landers <landers.robert@gmail.com>
This commit is contained in:
Robert Landers
2025-11-25 17:53:28 +01:00
parent c2124e806f
commit 0a56469fd8
3 changed files with 8 additions and 9 deletions

View File

@@ -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
}

View File

@@ -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

View File

@@ -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))