Merge pull request #6948 from heyitsanthony/fix-metric-deadlock

grpcproxy: fix deadlock in watchbroadcast
This commit is contained in:
Anthony Romano
2016-12-05 16:17:26 -08:00
committed by GitHub

View File

@@ -89,8 +89,8 @@ func (wb *watchBroadcast) bcast(wr clientv3.WatchResponse) {
for r := range wb.receivers {
r.send(wr)
}
if wb.size() > 0 {
eventsCoalescing.Add(float64(wb.size() - 1))
if len(wb.receivers) > 0 {
eventsCoalescing.Add(float64(len(wb.receivers) - 1))
}
}
@@ -135,7 +135,7 @@ func (wb *watchBroadcast) delete(w *watcher) {
panic("deleting missing watcher from broadcast")
}
delete(wb.receivers, w)
if !wb.empty() {
if len(wb.receivers) > 0 {
// do not dec the only left watcher for coalescing.
watchersCoalescing.Dec()
}