Specialize connection error handling to avoid goroutine leaking in some cases
This commit is contained in:
Родитель
7ed4629849
Коммит
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
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче