mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 10:13:14 -04:00 
			
		
		
		
	plugin/forward: close connection manager in proxy finalizer (#1768)
- connManager() goroutine will stop when Proxy is about to be garbage collected. This means that no queries are in progress, and no queries are going to come
This commit is contained in:
		
				
					committed by
					
						 Miek Gieben
						Miek Gieben
					
				
			
			
				
	
			
			
			
						parent
						
							38e27fd9ad
						
					
				
				
					commit
					7ac507d9ff
				
			| @@ -2,6 +2,7 @@ package forward | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"crypto/tls" | 	"crypto/tls" | ||||||
|  | 	"runtime" | ||||||
| 	"sync/atomic" | 	"sync/atomic" | ||||||
| 	"time" | 	"time" | ||||||
|  |  | ||||||
| @@ -36,6 +37,7 @@ func NewProxy(addr string, tlsConfig *tls.Config) *Proxy { | |||||||
| 		avgRtt:    int64(timeout / 2), | 		avgRtt:    int64(timeout / 2), | ||||||
| 	} | 	} | ||||||
| 	p.client = dnsClient(tlsConfig) | 	p.client = dnsClient(tlsConfig) | ||||||
|  | 	runtime.SetFinalizer(p, (*Proxy).finalizer) | ||||||
| 	return p | 	return p | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -91,6 +93,9 @@ func (p *Proxy) Down(maxfails uint32) bool { | |||||||
| // close stops the health checking goroutine. | // close stops the health checking goroutine. | ||||||
| func (p *Proxy) close() { | func (p *Proxy) close() { | ||||||
| 	p.probe.Stop() | 	p.probe.Stop() | ||||||
|  | } | ||||||
|  |  | ||||||
|  | func (p *Proxy) finalizer() { | ||||||
| 	p.transport.Stop() | 	p.transport.Stop() | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user