forked from TrueCloudLab/frostfs-sdk-go
[#324] rpc: Fix mem leak
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
00cebd297f
commit
d195cb5104
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)
|
||||
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
|
||||
|
@ -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,
|
||||
// which is not desired for the stream's lifecycle management.
|
||||
dialTimeoutTimer := time.NewTimer(c.dialTimeout)
|
||||
defer dialTimeoutTimer.Stop()
|
||||
defer func() {
|
||||
dialTimeoutTimer.Stop()
|
||||
select {
|
||||
case <-dialTimeoutTimer.C:
|
||||
default:
|
||||
}
|
||||
}()
|
||||
|
||||
type newStreamRes struct {
|
||||
stream grpc.ClientStream
|
||||
|
|
Loading…
Add table
Reference in a new issue