From 63f01d202bf6fa06007d0399beaffe3a639e98ac Mon Sep 17 00:00:00 2001 From: Noah Hilverling Date: Wed, 2 Oct 2019 12:00:40 +0200 Subject: [PATCH] HA: Fix notificationListeners not getting messages in order --- ha/ha.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ha/ha.go b/ha/ha.go index 73ffaf64..7b9ad533 100644 --- a/ha/ha.go +++ b/ha/ha.go @@ -263,7 +263,7 @@ func (h *HA) runEventListener() { } func (h *HA) RegisterNotificationListener(listenerType string) chan int { - ch := make(chan int) + ch := make(chan int, 10) h.notificationListenersMutex.Lock() h.notificationListeners[listenerType] = append(h.notificationListeners[listenerType], ch) h.notificationListenersMutex.Unlock() @@ -274,9 +274,7 @@ func (h *HA) notifyNotificationListener(listenerType string, msg int) { for t, chs := range h.notificationListeners { if t == listenerType || listenerType == "*" { for _, c := range chs { - go func(ch chan int) { - ch <- msg - }(c) + c <- msg } } }