Skip to content

Commit

Permalink
clientv3: close open watch channel if substream is closing on reconnect
Browse files Browse the repository at this point in the history
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 etcd-io#7503
  • Loading branch information
Anthony Romano committed Mar 15, 2017
1 parent 781196f commit a087325
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions clientv3/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a087325

Please sign in to comment.