diff options
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 { |