mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-11-04 03:27:23 -05:00 
			
		
		
		
	caddyconfig: Fix httploader leak from unused responses (#5159)
fixes #5158 Signed-off-by: Chris Lahaye <mail@chrislahaye.com> Signed-off-by: Chris Lahaye <mail@chrislahaye.com>
This commit is contained in:
		
							parent
							
								
									ed503118dd
								
							
						
					
					
						commit
						bbe3663167
					
				@ -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
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user