1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-12-01 23:11:31 +02:00

Drop cancelled requests in queue

This commit is contained in:
DarthSim
2020-10-08 17:56:39 +06:00
parent 1dc0c8c9a3
commit 3b83fb04b2
2 changed files with 6 additions and 1 deletions

View File

@@ -139,7 +139,11 @@ func handleProcessing(reqID string, rw http.ResponseWriter, r *http.Request) {
defer startPrometheusDuration(prometheusRequestDuration)()
}
processingSem <- struct{}{}
select {
case processingSem <- struct{}{}:
case <-ctx.Done():
panic(newError(499, "Request was cancelled before processing", "Cancelled"))
}
defer func() { <-processingSem }()
ctx, timeoutCancel := context.WithTimeout(ctx, time.Duration(conf.WriteTimeout)*time.Second)