Skip to content

Commit

Permalink
Stop timer to free up resources when its no longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
ash2k committed Oct 15, 2021
1 parent 23b650d commit 2467a3e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,11 +658,13 @@ func (c *Client) Do(req *Request) (*http.Response, error) {
v.Printf("[DEBUG] %s: retrying in %s (%d left)", desc, wait, remain)
}
}
timer := time.NewTimer(wait)
select {
case <-req.Context().Done():
timer.Stop()
c.HTTPClient.CloseIdleConnections()
return nil, req.Context().Err()
case <-time.After(wait):
case <-timer.C:
}

// Make shallow copy of http Request so that we can modify its body
Expand Down

0 comments on commit 2467a3e

Please sign in to comment.