Fix race condition in Matterbridge sender
This commit is contained in:
parent
15f6e8bc24
commit
64780e249c
|
@ -121,9 +121,11 @@ type MatterbridgeMessage struct {
|
|||
func SendToMatterbridge(events <-chan GenericMessage, s SatelNameGetter, config AppConfig, wg *sync.WaitGroup, logger *log.Logger, tpl *template.Template) <-chan GenericMessage {
|
||||
returnEvents := make(chan GenericMessage)
|
||||
|
||||
go func() {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
defer close(returnEvents)
|
||||
|
||||
for e := range events {
|
||||
returnEvents <- e
|
||||
for _, matterbridgeConfig := range config.Matterbridge {
|
||||
|
@ -145,7 +147,6 @@ func SendToMatterbridge(events <-chan GenericMessage, s SatelNameGetter, config
|
|||
logger.Print("Notified via Matterbridge with result ", res.StatusCode)
|
||||
}
|
||||
}
|
||||
close(returnEvents)
|
||||
}()
|
||||
|
||||
return returnEvents
|
||||
|
|
Loading…
Reference in New Issue