rearrange poll, lock, notify

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
Kristoffer Dalby 2023-07-26 17:54:19 +02:00 committed by Kristoffer Dalby
parent 593b3ad981
commit a8079a2096
2 changed files with 35 additions and 50 deletions

View file

@ -9,7 +9,7 @@ import (
)
type Notifier struct {
l sync.RWMutex
l sync.Mutex
nodes map[string]chan<- types.StateUpdate
}
@ -54,8 +54,8 @@ func (n *Notifier) NotifyAll(update types.StateUpdate) {
}
func (n *Notifier) NotifyWithIgnore(update types.StateUpdate, ignore ...string) {
n.l.RLock()
defer n.l.RUnlock()
n.l.Lock()
defer n.l.Unlock()
for key, c := range n.nodes {
if util.IsStringInSlice(ignore, key) {