Merge pull request #3927 from nordligulv/patch-1

client: fix goroutine leak in unreleased context
release-2.3
Xiang Li 2015-11-27 10:38:40 -08:00
commit e8eb3d7744
1 changed files with 4 additions and 1 deletions

View File

@ -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()