Use MarkLongPolling instead of hard-coded route path (#37427)
This commit is contained in:
@@ -14,6 +14,7 @@ import (
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/templates"
|
||||
"code.gitea.io/gitea/modules/web/middleware"
|
||||
"code.gitea.io/gitea/modules/web/routing"
|
||||
|
||||
"github.com/bohde/codel"
|
||||
"github.com/go-chi/chi/v5"
|
||||
@@ -68,7 +69,7 @@ func QoS() func(next http.Handler) http.Handler {
|
||||
return func(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
ctx := req.Context()
|
||||
|
||||
reqRecordInfo := routing.GetRequestRecordInfo(ctx)
|
||||
priority := requestPriority(ctx)
|
||||
|
||||
// Check if the request can begin processing.
|
||||
@@ -79,9 +80,8 @@ func QoS() func(next http.Handler) http.Handler {
|
||||
return
|
||||
}
|
||||
|
||||
// Release long-polling immediately, so they don't always
|
||||
// take up an in-flight request
|
||||
if strings.Contains(req.URL.Path, "/user/events") {
|
||||
// Release long-polling immediately, so they don't always take up an in-flight request
|
||||
if reqRecordInfo.IsLongPolling {
|
||||
c.Release()
|
||||
} else {
|
||||
defer c.Release()
|
||||
|
||||
Reference in New Issue
Block a user