Compare commits
1 commit
2352156ee9
...
a5a399f748
Author | SHA1 | Date | |
---|---|---|---|
a5a399f748 |
1 changed files with 6 additions and 3 deletions
|
@ -52,6 +52,7 @@ func (c *Client) Init(info common.CallMethodInfo, opts ...CallOption) (MessageRe
|
|||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(prm.ctx)
|
||||
defer cancel()
|
||||
|
||||
// `conn.NewStream` doesn't check if `conn` may turn up invalidated right before this invocation.
|
||||
// In such cases, the operation can hang indefinitely, with the context timeout being the only
|
||||
|
@ -76,13 +77,15 @@ func (c *Client) Init(info common.CallMethodInfo, opts ...CallOption) (MessageRe
|
|||
}()
|
||||
select {
|
||||
case <-dialTimeoutTimer.C:
|
||||
cancel()
|
||||
return nil, context.Canceled
|
||||
select {
|
||||
case <-newStreamCh:
|
||||
default:
|
||||
return nil, context.Canceled
|
||||
}
|
||||
case <-newStreamCh:
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
cancel()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue