From c2e7bc8306a098b83d0b03f92696ddd518662a05 Mon Sep 17 00:00:00 2001 From: qydysky Date: Sun, 21 May 2023 09:29:53 +0800 Subject: [PATCH] =?utf8?q?Fix=20=E7=9B=B4=E6=92=AD=E6=B5=81=E5=9B=9E?= =?utf8?q?=E6=94=BE=E8=BF=9E=E6=8E=A5=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Reply/F.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/Reply/F.go b/Reply/F.go index 2b70284..58f3f09 100644 --- a/Reply/F.go +++ b/Reply/F.go @@ -1239,15 +1239,10 @@ func init() { // 直播流播放器 c.C.SerF.Store(path+"player/", func(w http.ResponseWriter, r *http.Request) { // 直播流回放连接限制 - if maxCon > 0 { - if limitCon.Add(1) > maxCon { - limitCon.Add(-1) - w.WriteHeader(http.StatusTooManyRequests) - _, _ = w.Write([]byte("已达到设定最大连接数")) - return - } else { - defer limitCon.Add(-1) - } + if maxCon > 0 && limitCon.Load() >= maxCon { + w.WriteHeader(http.StatusTooManyRequests) + _, _ = w.Write([]byte("已达到设定最大连接数")) + return } p := strings.TrimPrefix(r.URL.Path, path+"player/") @@ -1277,7 +1272,6 @@ func init() { if limitCon.Add(1) > maxCon { limitCon.Add(-1) w.WriteHeader(http.StatusTooManyRequests) - _, _ = w.Write([]byte("已达到设定最大连接数")) return } else { defer limitCon.Add(-1) -- 2.39.2