From c15bcd487f65464eb7dd3be550d4e65682d8998d Mon Sep 17 00:00:00 2001 From: Benjamin Bollen Date: Fri, 17 Jun 2016 13:47:15 +0200 Subject: [PATCH] fixes #1; events.go: claim full lock on delete listener --- events.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/events.go b/events.go index 04c9a9b2e..4c8604a25 100644 --- a/events.go +++ b/events.go @@ -74,13 +74,15 @@ func (evsw *EventSwitch) RemoveListener(listenerID string) { // Get and remove listener evsw.mtx.RLock() listener := evsw.listeners[listenerID] - delete(evsw.listeners, listenerID) evsw.mtx.RUnlock() - if listener == nil { return } + evsw.mtx.Lock() + delete(evsw.listeners, listenerID) + evsw.mtx.Unlock() + // Remove callback for each event. listener.SetRemoved() for _, event := range listener.GetEvents() {