mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #7103 from heyitsanthony/proxy-watch-close
grpcproxy: tear down watch when client context is done
This commit is contained in:
commit
5feb4e1027
@ -122,23 +122,23 @@ func (wp *watchProxy) Watch(stream pb.Watch_WatchServer) (err error) {
|
||||
defer func() { stopc <- struct{}{} }()
|
||||
wps.sendLoop()
|
||||
}()
|
||||
if leaderc != nil {
|
||||
go func() {
|
||||
defer func() { stopc <- struct{}{} }()
|
||||
select {
|
||||
case <-leaderc:
|
||||
case <-ctx.Done():
|
||||
}
|
||||
}()
|
||||
}
|
||||
// tear down watch if leader goes down or entire watch proxy is terminated
|
||||
go func() {
|
||||
defer func() { stopc <- struct{}{} }()
|
||||
select {
|
||||
case <-leaderc:
|
||||
case <-ctx.Done():
|
||||
case <-wp.ctx.Done():
|
||||
}
|
||||
}()
|
||||
|
||||
<-stopc
|
||||
cancel()
|
||||
|
||||
// recv/send may only shutdown after function exits;
|
||||
// goroutine notifies proxy that stream is through
|
||||
go func() {
|
||||
if leaderc != nil {
|
||||
<-stopc
|
||||
}
|
||||
<-stopc
|
||||
<-stopc
|
||||
wps.close()
|
||||
wp.wg.Done()
|
||||
|
Loading…
x
Reference in New Issue
Block a user