From acfa032f33f5442c15e0165ddeb6eb317062e6d4 Mon Sep 17 00:00:00 2001 From: dexter <178529795@qq.com> Date: Thu, 10 Mar 2022 09:01:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=AE=A2=E9=98=85=E4=B8=8D=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E7=9A=84=E6=B5=81=E6=97=B6=E6=B2=A1=E6=9C=89resolve?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E5=8D=A1=E6=AD=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 11 +++++------ stream.go | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index 65c04fe..d795d2f 100644 --- a/main.go +++ b/main.go @@ -76,15 +76,9 @@ func Run(ctx context.Context, configFile string) (err error) { contentBuf := bytes.NewBuffer(nil) req, _ := http.NewRequestWithContext(ctx, http.MethodPost, "https://logs-01.loggly.com/inputs/758a662d-f630-40cb-95ed-2502a5e9c872/tag/monibuca/", nil) req.Header.Set("Content-Type", "application/json") - content := fmt.Sprintf(`{"uuid":"%s","version":"%s","os":"%s","arch":"%s"`, UUID, Engine.Version, runtime.GOOS, runtime.GOARCH) var c http.Client for { - contentBuf.Reset() - postJson := fmt.Sprintf(`%s,"streams":%d}`, content, len(Streams.Map)) - contentBuf.WriteString(postJson) - req.Body = ioutil.NopCloser(contentBuf) - c.Do(req) select { case event := <-EventBus: for _, plugin := range Plugins { @@ -93,6 +87,11 @@ func Run(ctx context.Context, configFile string) (err error) { case <-ctx.Done(): return case <-reportTimer.C: + contentBuf.Reset() + postJson := fmt.Sprintf(`%s,"streams":%d}`, content, len(Streams.Map)) + contentBuf.WriteString(postJson) + req.Body = ioutil.NopCloser(contentBuf) + c.Do(req) } } } diff --git a/stream.go b/stream.go index b692957..a0058c6 100644 --- a/stream.go +++ b/stream.go @@ -308,10 +308,10 @@ func (s *Stream) run() { } suber.OnEvent(t) // 把现有的Track发给订阅者 } - v.Resolve(util.Null) } else { waitP = append(waitP, v) } + v.Resolve(util.Null) if len(s.Subscribers) == 1 { s.action(ACTION_FIRSTENTER) }