From d5191c7b165031fcc8e8edc979a373c98531fccc Mon Sep 17 00:00:00 2001 From: qydysky Date: Wed, 9 Aug 2023 02:49:37 +0800 Subject: [PATCH] =?utf8?q?Fix=20=E6=97=A0=E6=95=88=E7=9A=84=E8=AF=B7?= =?utf8?q?=E6=B1=82=E6=B1=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- CV/Var.go | 5 ++--- F/api.go | 12 ++++++------ Reply/stream.go | 1 - go.mod | 2 +- go.sum | 4 ++-- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/CV/Var.go b/CV/Var.go index 561c9f3..1be3085 100644 --- a/CV/Var.go +++ b/CV/Var.go @@ -379,8 +379,7 @@ func (t *Common) Init() *Common { "currentTime": time.Now().Format(time.DateTime), "state": map[string]any{ "base": map[string]any{ - "reqPoolInUse": t.ReqPool.PoolInUse(), - "reqPoolSum": t.ReqPool.PoolSum(), + "reqPoolState": fmt.Sprintf("pooled(%d), nopooled(%d), inuse(%d), nouse(%d), sum(%d)", t.ReqPool.PoolState()...), "numGoroutine": runtime.NumGoroutine(), "goVersion": runtime.Version(), }, @@ -484,6 +483,7 @@ func (t *Common) loadConf(customConf string) error { if strings.Contains(customConf, "http:") || strings.Contains(customConf, "https:") { //从网址读取 req := t.ReqPool.Get() + defer t.ReqPool.Put(req) if e := req.Reqf(reqf.Rval{ Url: customConf, Header: map[string]string{ @@ -510,7 +510,6 @@ func (t *Common) loadConf(customConf string) error { data[k] = v } } - t.ReqPool.Put(req) } else { //从文件读取 if bb, err := file.New(customConf, 0, true).ReadAll(100, 1<<16); err != nil { diff --git a/F/api.go b/F/api.go index 7129fb0..c39228d 100644 --- a/F/api.go +++ b/F/api.go @@ -1404,6 +1404,8 @@ func (t *GetFunc) Get_cookie() (missKey []string) { return true }) + r := t.ReqPool.Get() + defer t.ReqPool.Put(r) for { //3s刷新查看是否通过 time.Sleep(time.Duration(3) * time.Second) @@ -1413,8 +1415,6 @@ func (t *GetFunc) Get_cookie() (missKey []string) { return } - r := t.ReqPool.Get() - defer t.ReqPool.Put(r) if e := r.Reqf(reqf.Rval{ Url: `https://passport.bilibili.com/qrcode/getLoginInfo`, PostStr: `oauthKey=` + oauth, @@ -1522,9 +1522,9 @@ func Get_list_in_room() (array []FansMedalI) { { //获取牌子列表 var medalList []FansMedalI + r := c.C.ReqPool.Get() + defer c.C.ReqPool.Put(r) for pageNum := 1; true; pageNum += 1 { - r := c.C.ReqPool.Get() - defer c.C.ReqPool.Put(r) if e := r.Reqf(reqf.Rval{ Url: `https://api.live.bilibili.com/xlive/app-ucenter/v1/fansMedal/panel?page=` + strconv.Itoa(pageNum) + `&page_size=10`, Header: map[string]string{ @@ -1882,9 +1882,9 @@ func (t *GetFunc) Get_LIVE_BUVID() (missKey []string) { "1", //哔哩哔哩直播 } + req := t.ReqPool.Get() + defer t.ReqPool.Put(req) for _, roomid := range roomIdList { //获取 - req := t.ReqPool.Get() - defer t.ReqPool.Put(req) if err := req.Reqf(reqf.Rval{ Url: `https://api.live.bilibili.com/live/getRoomKanBanModel?roomid=` + roomid, Header: map[string]string{ diff --git a/Reply/stream.go b/Reply/stream.go index 00f72c9..5d1793e 100644 --- a/Reply/stream.go +++ b/Reply/stream.go @@ -701,7 +701,6 @@ func (t *M4SStream) saveStreamFlv() (e error) { `Cookie`: reqf.Map_2_Cookies_String(CookieM), }, }); e != nil && reqf.IsTimeout(e) { - t.reqPool.Put(r) v.DisableAuto() continue } diff --git a/go.mod b/go.mod index 20a1d80..af9ef46 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.20 require ( github.com/gotk3/gotk3 v0.6.2 github.com/mdp/qrterminal/v3 v3.1.1 - github.com/qydysky/part v0.28.1-0.20230731082841-7681ef24197f + github.com/qydysky/part v0.28.1-0.20230808184121-9caa5514df96 github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 golang.org/x/text v0.12.0 diff --git a/go.sum b/go.sum index 6781758..57c6e5f 100644 --- a/go.sum +++ b/go.sum @@ -30,8 +30,8 @@ github.com/mdp/qrterminal/v3 v3.1.1/go.mod h1:5lJlXe7Jdr8wlPDdcsJttv1/knsRgzXASy github.com/miekg/dns v1.1.55 h1:GoQ4hpsj0nFLYe+bWiCToyrBEJXkQfOOIvFGFy0lEgo= github.com/miekg/dns v1.1.55/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/qydysky/part v0.28.1-0.20230731082841-7681ef24197f h1:yq1Ke7QQZLmoOaQ8pJcAcc3ihLtqBhlY6Ji7BB9TjNk= -github.com/qydysky/part v0.28.1-0.20230731082841-7681ef24197f/go.mod h1:CdkAHZ+OxieG1sI4M6UowP9j0QQDnhtDtN4tWsylCPU= +github.com/qydysky/part v0.28.1-0.20230808184121-9caa5514df96 h1:W60WfxVZfoFEUjfK/czwUouoYgmfjoB9o4CJXosa7AU= +github.com/qydysky/part v0.28.1-0.20230808184121-9caa5514df96/go.mod h1:CdkAHZ+OxieG1sI4M6UowP9j0QQDnhtDtN4tWsylCPU= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI= -- 2.39.2