From 7618fdd1d642e47cac70c03f637b0fd798a53a6e Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Fri, 18 Nov 2016 16:55:26 -0800 Subject: [PATCH] grpcproxy: fix deadlock on watch broadcasts stop Holding the WatchBroadcasts lock and waiting on donec was causing a deadlock with the coalesce loop. Was causing TestV3WatchSyncCancel to hang. --- proxy/grpcproxy/watch_broadcasts.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/proxy/grpcproxy/watch_broadcasts.go b/proxy/grpcproxy/watch_broadcasts.go index fc18b7425..3ca6fa2db 100644 --- a/proxy/grpcproxy/watch_broadcasts.go +++ b/proxy/grpcproxy/watch_broadcasts.go @@ -116,13 +116,12 @@ func (wbs *watchBroadcasts) empty() bool { return len(wbs.bcasts) == 0 } func (wbs *watchBroadcasts) stop() { wbs.mu.Lock() - defer wbs.mu.Unlock() - for wb := range wbs.bcasts { wb.stop() } wbs.bcasts = nil close(wbs.updatec) + wbs.mu.Unlock() <-wbs.donec }