1
0
Эх сурвалжийг харах

Drop cancelled requests in queue

DarthSim 4 жил өмнө
parent
commit
3b83fb04b2
2 өөрчлөгдсөн 6 нэмэгдсэн , 1 устгасан
  1. 1 0
      CHANGELOG.md
  2. 5 1
      processing_handler.go

+ 1 - 0
CHANGELOG.md

@@ -11,6 +11,7 @@
 ### Fix
 - Fix `dpr` option.
 - Fix non-strict SVG detection.
+- Fix checking of connections in queue.
 
 ## [2.15.0] - 2020-09-03
 ### Added

+ 5 - 1
processing_handler.go

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