diff options
author | 2018-04-20 17:47:46 +0300 | |
---|---|---|
committer | 2018-04-20 17:47:46 +0300 | |
commit | 135377bf776295d8ef86081c1ef581e7b41d26f0 (patch) | |
tree | e09807cdfedfb7b8a6181ad660c42dd6ea0d1f78 /plugin/forward/connect.go | |
parent | ad13d88346d3e4686d92df20efb65af8f97dd7e1 (diff) | |
download | coredns-135377bf776295d8ef86081c1ef581e7b41d26f0.tar.gz coredns-135377bf776295d8ef86081c1ef581e7b41d26f0.tar.zst coredns-135377bf776295d8ef86081c1ef581e7b41d26f0.zip |
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
Diffstat (limited to 'plugin/forward/connect.go')
-rw-r--r-- | plugin/forward/connect.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/plugin/forward/connect.go b/plugin/forward/connect.go index 0a66f2752..6ea7913e5 100644 --- a/plugin/forward/connect.go +++ b/plugin/forward/connect.go @@ -35,6 +35,16 @@ func (p *Proxy) updateRtt(newRtt time.Duration) { } func (p *Proxy) connect(ctx context.Context, state request.Request, forceTCP, metric bool) (*dns.Msg, error) { + atomic.AddInt32(&p.inProgress, 1) + defer func() { + if atomic.AddInt32(&p.inProgress, -1) == 0 { + p.checkStopTransport() + } + }() + if atomic.LoadUint32(&p.state) != running { + return nil, errStopped + } + start := time.Now() proto := state.Proto() @@ -46,7 +56,6 @@ func (p *Proxy) connect(ctx context.Context, state request.Request, forceTCP, me if err != nil { return nil, err } - // Set buffer size correctly for this client. conn.UDPSize = uint16(state.Size()) if conn.UDPSize < 512 { |