1
0
Fork 0

Fix race condition in Matterbridge sender

This commit is contained in:
Michał Rudowicz 2025-01-02 14:08:39 +01:00
parent 15f6e8bc24
commit 64780e249c
1 changed files with 3 additions and 2 deletions

View File

@ -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