mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
client: fix goroutine leak in unreleased context
If headerTimeout is not zero then two context are created but only one is released. cancelCtx in this case is never released which leads to goroutine leak inside it.
This commit is contained in:
parent
fc61fc7c7a
commit
0fb2d5d4d3
@ -378,9 +378,12 @@ func (c *simpleHTTPClient) Do(ctx context.Context, act httpAction) (*http.Respon
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
hctx, hcancel := context.WithCancel(ctx)
|
||||
var hctx context.Context
|
||||
var hcancel context.CancelFunc
|
||||
if c.headerTimeout > 0 {
|
||||
hctx, hcancel = context.WithTimeout(ctx, c.headerTimeout)
|
||||
} else {
|
||||
hctx, hcancel = context.WithCancel(ctx)
|
||||
}
|
||||
defer hcancel()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user