mirror of
https://github.com/Monibuca/engine.git
synced 2025-10-08 01:50:03 +08:00
fix: 订阅不存在的流时没有resolve导致卡死
This commit is contained in:
11
main.go
11
main.go
@@ -76,15 +76,9 @@ func Run(ctx context.Context, configFile string) (err error) {
|
|||||||
contentBuf := bytes.NewBuffer(nil)
|
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, _ := 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")
|
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)
|
content := fmt.Sprintf(`{"uuid":"%s","version":"%s","os":"%s","arch":"%s"`, UUID, Engine.Version, runtime.GOOS, runtime.GOARCH)
|
||||||
var c http.Client
|
var c http.Client
|
||||||
for {
|
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 {
|
select {
|
||||||
case event := <-EventBus:
|
case event := <-EventBus:
|
||||||
for _, plugin := range Plugins {
|
for _, plugin := range Plugins {
|
||||||
@@ -93,6 +87,11 @@ func Run(ctx context.Context, configFile string) (err error) {
|
|||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
case <-reportTimer.C:
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -308,10 +308,10 @@ func (s *Stream) run() {
|
|||||||
}
|
}
|
||||||
suber.OnEvent(t) // 把现有的Track发给订阅者
|
suber.OnEvent(t) // 把现有的Track发给订阅者
|
||||||
}
|
}
|
||||||
v.Resolve(util.Null)
|
|
||||||
} else {
|
} else {
|
||||||
waitP = append(waitP, v)
|
waitP = append(waitP, v)
|
||||||
}
|
}
|
||||||
|
v.Resolve(util.Null)
|
||||||
if len(s.Subscribers) == 1 {
|
if len(s.Subscribers) == 1 {
|
||||||
s.action(ACTION_FIRSTENTER)
|
s.action(ACTION_FIRSTENTER)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user