mirror of https://github.com/grpc/grpc-go.git
Specialize connection error handling to avoid goroutine leaking in some cases
This commit is contained in:
parent
7ed4629849
commit
47fc4a2936
|
|
@ -133,8 +133,12 @@ func NewClientStream(ctx context.Context, desc *StreamDesc, cc *ClientConn, meth
|
|||
// Listen on ctx.Done() to detect cancellation when there is no pending
|
||||
// I/O operations on this stream.
|
||||
go func() {
|
||||
<-s.Context().Done()
|
||||
cs.closeTransportStream(transport.ContextErr(s.Context().Err()))
|
||||
select {
|
||||
case <-t.Error():
|
||||
// Incur transport error, simply exit.
|
||||
case <-s.Context().Done():
|
||||
cs.closeTransportStream(transport.ContextErr(s.Context().Err()))
|
||||
}
|
||||
}()
|
||||
return cs, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue