[#324] rpc: Fix mem leak
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
82e48c8a63
commit
1b8bd20fa0
1 changed files with 8 additions and 1 deletions
|
@ -52,6 +52,7 @@ func (c *Client) Init(info common.CallMethodInfo, opts ...CallOption) (MessageRe
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(prm.ctx)
|
ctx, cancel := context.WithCancel(prm.ctx)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
// `conn.NewStream` doesn't check if `conn` may turn up invalidated right before this invocation.
|
// `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
|
// In such cases, the operation can hang indefinitely, with the context timeout being the only
|
||||||
|
@ -61,7 +62,13 @@ func (c *Client) Init(info common.CallMethodInfo, opts ...CallOption) (MessageRe
|
||||||
// would propagate to all subsequent read/write operations on the opened stream,
|
// would propagate to all subsequent read/write operations on the opened stream,
|
||||||
// which is not desired for the stream's lifecycle management.
|
// which is not desired for the stream's lifecycle management.
|
||||||
dialTimeoutTimer := time.NewTimer(c.dialTimeout)
|
dialTimeoutTimer := time.NewTimer(c.dialTimeout)
|
||||||
defer dialTimeoutTimer.Stop()
|
defer func() {
|
||||||
|
dialTimeoutTimer.Stop()
|
||||||
|
select {
|
||||||
|
case <-dialTimeoutTimer.C:
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
type newStreamRes struct {
|
type newStreamRes struct {
|
||||||
stream grpc.ClientStream
|
stream grpc.ClientStream
|
||||||
|
|
Loading…
Add table
Reference in a new issue