aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugin/forward/proxy.go5
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()
}