]> 127.0.0.1 Git - bili_danmu/.git/commitdiff
Fix 直播流回放连接限制
authorqydysky <qydysky@foxmail.com>
Sun, 21 May 2023 01:57:26 +0000 (09:57 +0800)
committerqydysky <qydysky@foxmail.com>
Sun, 21 May 2023 01:57:26 +0000 (09:57 +0800)
Reply/F.go

index 58f3f09099353f78a472e9e7bec863fe3f5a41b6..087c924a0b6683236735f57e158887e154ae02e1 100644 (file)
@@ -1274,7 +1274,11 @@ func init() {
                                        w.WriteHeader(http.StatusTooManyRequests)
                                        return
                                } else {
-                                       defer limitCon.Add(-1)
+                                       // 连接退出
+                                       go func() {
+                                               <-r.Context().Done()
+                                               limitCon.Add(-1)
+                                       }()
                                }
                        }
 
@@ -1348,7 +1352,6 @@ func init() {
                                                        speed = s
                                                }
                                        }
-
                                        if e := f.CopyToIoWriter(w, int64(speed), true); e != nil {
                                                flog.L(`E: `, e)
                                        }