Skip to content
Snippets Groups Projects
Commit 82566525 authored by scott's avatar scott
Browse files

Add double check for RWMutex

parent 72c11d42
No related branches found
No related tags found
No related merge requests found
...@@ -166,6 +166,12 @@ func (l *EventListener) ListenServiceEvent(key string, listener remoting.DataLis ...@@ -166,6 +166,12 @@ func (l *EventListener) ListenServiceEvent(key string, listener remoting.DataLis
} }
l.keyMapLock.Lock() l.keyMapLock.Lock()
// double check
if _, ok := l.keyMap[key]; ok {
// another goroutine already set it
l.keyMapLock.Unlock()
return
}
l.keyMap[key] = struct{}{} l.keyMap[key] = struct{}{}
l.keyMapLock.Unlock() l.keyMapLock.Unlock()
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment