Browse Source

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

grpcproxy: fix deadlock in watchbroadcast
Anthony Romano 9 years ago
parent
commit
cbee2b74a3
1 changed files with 3 additions and 3 deletions
  1. 3 3
      proxy/grpcproxy/watch_broadcast.go

+ 3 - 3
proxy/grpcproxy/watch_broadcast.go

@@ -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()
 	}