Skip to content

Commit

Permalink
caddyconfig: Fix httploader leak from unused responses (#5159)
Browse files Browse the repository at this point in the history
fixes #5158

Signed-off-by: Chris Lahaye <mail@chrislahaye.com>

Signed-off-by: Chris Lahaye <mail@chrislahaye.com>
  • Loading branch information
ChrisLahaye committed Oct 24, 2022
1 parent ed50311 commit bbe3663
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions caddyconfig/httploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,16 @@ func doHttpCallWithRetries(ctx caddy.Context, client *http.Client, request *http
var err error
const maxAttempts = 10

// attempt up to 10 times
for i := 0; i < maxAttempts; i++ {
resp, err = attemptHttpCall(client, request)
if err != nil && i < maxAttempts-1 {
// wait 500ms before reattempting, or until context is done
select {
case <-time.After(time.Millisecond * 500):
case <-ctx.Done():
return resp, ctx.Err()
}
} else {
break
}
}

Expand Down

0 comments on commit bbe3663

Please sign in to comment.