plugin/forward: gracefull stop (#1701)

* plugin/forward: gracefull stop

 - stop connection manager only when no queries in progress

* minor improvement

* prevent healthcheck on stopped proxy

* revert closing channels

* use standard context
This commit is contained in:
Ruslan Drozhdzh
2018-04-20 17:47:46 +03:00
committed by GitHub
parent ad13d88346
commit 135377bf77
4 changed files with 100 additions and 5 deletions

View File

@@ -120,7 +120,7 @@ func (f *Forward) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg
if err != nil {
// Kick off health check to see if *our* upstream is broken.
if f.maxfails != 0 {
if f.maxfails != 0 && err != errStopped {
proxy.Healthcheck()
}
@@ -186,6 +186,7 @@ var (
errNoHealthy = errors.New("no healthy proxies")
errNoForward = errors.New("no forwarder defined")
errCachedClosed = errors.New("cached connection was closed by peer")
errStopped = errors.New("proxy has been stopped")
)
// policy tells forward what policy for selecting upstream it uses.