diff options
author | 2018-05-18 09:46:14 +0300 | |
---|---|---|
committer | 2018-05-18 07:46:14 +0100 | |
commit | 7ac507d9ffd19e03737345408b62a732ec706c73 (patch) | |
tree | 3c096e5b9f5e3ba3ef752f017cf5d6f57dd42a22 /plugin | |
parent | 38e27fd9ade9650191673fe8b8b4fd028eeb609b (diff) | |
download | coredns-7ac507d9ffd19e03737345408b62a732ec706c73.tar.gz coredns-7ac507d9ffd19e03737345408b62a732ec706c73.tar.zst coredns-7ac507d9ffd19e03737345408b62a732ec706c73.zip |
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
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/forward/proxy.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/plugin/forward/proxy.go b/plugin/forward/proxy.go index 588b21510..a162ace1b 100644 --- a/plugin/forward/proxy.go +++ b/plugin/forward/proxy.go @@ -2,6 +2,7 @@ package forward import ( "crypto/tls" + "runtime" "sync/atomic" "time" @@ -36,6 +37,7 @@ func NewProxy(addr string, tlsConfig *tls.Config) *Proxy { avgRtt: int64(timeout / 2), } p.client = dnsClient(tlsConfig) + runtime.SetFinalizer(p, (*Proxy).finalizer) return p } @@ -91,6 +93,9 @@ func (p *Proxy) Down(maxfails uint32) bool { // close stops the health checking goroutine. func (p *Proxy) close() { p.probe.Stop() +} + +func (p *Proxy) finalizer() { p.transport.Stop() } |