mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
grpcproxy: fix deadlock in watchbroadcast
Calling empty() in watchbroadcast methods was trying to lock the rwmutex when it was already held. Fixes #6937
This commit is contained in:
parent
2509e7ad2c
commit
91ff6f30b5
@ -89,8 +89,8 @@ func (wb *watchBroadcast) bcast(wr clientv3.WatchResponse) {
|
|||||||
for r := range wb.receivers {
|
for r := range wb.receivers {
|
||||||
r.send(wr)
|
r.send(wr)
|
||||||
}
|
}
|
||||||
if wb.size() > 0 {
|
if len(wb.receivers) > 0 {
|
||||||
eventsCoalescing.Add(float64(wb.size() - 1))
|
eventsCoalescing.Add(float64(len(wb.receivers) - 1))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ func (wb *watchBroadcast) delete(w *watcher) {
|
|||||||
panic("deleting missing watcher from broadcast")
|
panic("deleting missing watcher from broadcast")
|
||||||
}
|
}
|
||||||
delete(wb.receivers, w)
|
delete(wb.receivers, w)
|
||||||
if !wb.empty() {
|
if len(wb.receivers) > 0 {
|
||||||
// do not dec the only left watcher for coalescing.
|
// do not dec the only left watcher for coalescing.
|
||||||
watchersCoalescing.Dec()
|
watchersCoalescing.Dec()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user