From a087325452242c32028fce0539443ba03c61d54b Mon Sep 17 00:00:00 2001 From: Anthony Romano Date: Tue, 14 Mar 2017 17:00:22 -0700 Subject: [PATCH] clientv3: close open watch channel if substream is closing on reconnect If substream is closing but outc is still open while reconnecting, then outc would only be closed once the watch client would connect or once the watch client is closed. This was leading to deadlocks in the proxy tests. Instead, close immediately if the context is canceled. Fixes #7503 --- clientv3/watch.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/clientv3/watch.go b/clientv3/watch.go index 08f7d56da..489eba6a8 100644 --- a/clientv3/watch.go +++ b/clientv3/watch.go @@ -694,6 +694,10 @@ func (w *watchGrpcStream) waitCancelSubstreams(stopc <-chan struct{}) <-chan str go func(ws *watcherStream) { defer wg.Done() if ws.closing { + if ws.initReq.ctx.Err() != nil && ws.outc != nil { + close(ws.outc) + ws.outc = nil + } return } select {