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 {
|
func SendToMatterbridge(events <-chan GenericMessage, s SatelNameGetter, config AppConfig, wg *sync.WaitGroup, logger *log.Logger, tpl *template.Template) <-chan GenericMessage {
|
||||||
returnEvents := make(chan GenericMessage)
|
returnEvents := make(chan GenericMessage)
|
||||||
|
|
||||||
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
wg.Add(1)
|
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
defer close(returnEvents)
|
||||||
|
|
||||||
for e := range events {
|
for e := range events {
|
||||||
returnEvents <- e
|
returnEvents <- e
|
||||||
for _, matterbridgeConfig := range config.Matterbridge {
|
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)
|
logger.Print("Notified via Matterbridge with result ", res.StatusCode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
close(returnEvents)
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return returnEvents
|
return returnEvents
|
||||||
|
|
Loading…
Reference in New Issue