From d4fc3099ec33164400efd4690be6a0d415746e0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Sun, 14 Nov 2021 15:28:42 +0100 Subject: [PATCH] handle more cases --- subscriber.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/subscriber.go b/subscriber.go index 2603ccc5..97d7d918 100644 --- a/subscriber.go +++ b/subscriber.go @@ -68,8 +68,8 @@ func (s *Subscriber) Dispatch(u *Update, fromHistory bool) bool { s.liveMutex.Unlock() } - s.outMutex.RLock() - defer s.outMutex.RUnlock() + s.outMutex.Lock() + defer s.outMutex.Unlock() if atomic.LoadInt32(&s.disconnected) > 0 { return false } @@ -83,6 +83,8 @@ func (s *Subscriber) Dispatch(u *Update, fromHistory bool) bool { func (s *Subscriber) Ready() int { s.liveMutex.Lock() defer s.liveMutex.Unlock() + s.outMutex.Lock() + defer s.outMutex.Unlock() n := len(s.liveQueue) for _, u := range s.liveQueue {