mirror of
https://github.com/minio/minio.git
synced 2025-01-12 15:33:22 -05:00
decrement requests inqueue correctly after the request is processed (#19918)
This commit is contained in:
parent
d21b6daa49
commit
e3ac4035b9
@ -323,10 +323,9 @@ func maxClients(f http.HandlerFunc) http.HandlerFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
globalHTTPStats.addRequestsInQueue(1)
|
globalHTTPStats.addRequestsInQueue(1)
|
||||||
defer globalHTTPStats.addRequestsInQueue(-1)
|
|
||||||
|
|
||||||
pool, deadline := globalAPIConfig.getRequestsPool()
|
pool, deadline := globalAPIConfig.getRequestsPool()
|
||||||
if pool == nil {
|
if pool == nil {
|
||||||
|
globalHTTPStats.addRequestsInQueue(-1)
|
||||||
f.ServeHTTP(w, r)
|
f.ServeHTTP(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -334,6 +333,7 @@ func maxClients(f http.HandlerFunc) http.HandlerFunc {
|
|||||||
// No deadline to wait, there is nothing to queue
|
// No deadline to wait, there is nothing to queue
|
||||||
// perform the API call immediately.
|
// perform the API call immediately.
|
||||||
if deadline <= 0 {
|
if deadline <= 0 {
|
||||||
|
globalHTTPStats.addRequestsInQueue(-1)
|
||||||
f.ServeHTTP(w, r)
|
f.ServeHTTP(w, r)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -349,12 +349,14 @@ func maxClients(f http.HandlerFunc) http.HandlerFunc {
|
|||||||
select {
|
select {
|
||||||
case pool <- struct{}{}:
|
case pool <- struct{}{}:
|
||||||
defer func() { <-pool }()
|
defer func() { <-pool }()
|
||||||
|
globalHTTPStats.addRequestsInQueue(-1)
|
||||||
if contextCanceled(ctx) {
|
if contextCanceled(ctx) {
|
||||||
w.WriteHeader(499)
|
w.WriteHeader(499)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
f.ServeHTTP(w, r)
|
f.ServeHTTP(w, r)
|
||||||
case <-deadlineTimer.C:
|
case <-deadlineTimer.C:
|
||||||
|
globalHTTPStats.addRequestsInQueue(-1)
|
||||||
if contextCanceled(ctx) {
|
if contextCanceled(ctx) {
|
||||||
w.WriteHeader(499)
|
w.WriteHeader(499)
|
||||||
return
|
return
|
||||||
@ -364,6 +366,7 @@ func maxClients(f http.HandlerFunc) http.HandlerFunc {
|
|||||||
errorCodes.ToAPIErr(ErrTooManyRequests),
|
errorCodes.ToAPIErr(ErrTooManyRequests),
|
||||||
r.URL)
|
r.URL)
|
||||||
case <-r.Context().Done():
|
case <-r.Context().Done():
|
||||||
|
globalHTTPStats.addRequestsInQueue(-1)
|
||||||
// When the client disconnects before getting the S3 handler
|
// When the client disconnects before getting the S3 handler
|
||||||
// status code response, set the status code to 499 so this request
|
// status code response, set the status code to 499 so this request
|
||||||
// will be properly audited and traced.
|
// will be properly audited and traced.
|
||||||
|
Loading…
Reference in New Issue
Block a user