mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-10-31 02:27:19 -04:00 
			
		
		
		
	reverseproxy: Fix round robin data race (#4038)
This commit is contained in:
		
							parent
							
								
									b54fa41239
								
							
						
					
					
						commit
						ce5a0934a8
					
				| @ -368,8 +368,8 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyht | |||||||
| 	reqHost := r.Host | 	reqHost := r.Host | ||||||
| 	reqHeader := r.Header | 	reqHeader := r.Header | ||||||
| 	defer func() { | 	defer func() { | ||||||
| 		r.Host = reqHost | 		r.Host = reqHost     // TODO: data race, see #4038 | ||||||
| 		r.Header = reqHeader | 		r.Header = reqHeader // TODO: data race, see #4038 | ||||||
| 	}() | 	}() | ||||||
| 
 | 
 | ||||||
| 	start := time.Now() | 	start := time.Now() | ||||||
|  | |||||||
| @ -221,8 +221,8 @@ func (r *RoundRobinSelection) Select(pool UpstreamPool, _ *http.Request, _ http. | |||||||
| 		return nil | 		return nil | ||||||
| 	} | 	} | ||||||
| 	for i := uint32(0); i < n; i++ { | 	for i := uint32(0); i < n; i++ { | ||||||
| 		atomic.AddUint32(&r.robin, 1) | 		robin := atomic.AddUint32(&r.robin, 1) | ||||||
| 		host := pool[r.robin%n] | 		host := pool[robin%n] | ||||||
| 		if host.Available() { | 		if host.Available() { | ||||||
| 			return host | 			return host | ||||||
| 		} | 		} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user