plugin/forward: move Dial goroutine out (#1738)

Rework the TestProxyClose - close the proxy in the *same* goroutine
as where we started it. Close channels as long as we don't get dataraces
(this may need another fix).

Move the Dial goroutine out of the connManager - this simplifies things
*and* makes another goroutine go away and removes the need for connErr
channels - can now just be dns.Conn.

Also:

Revert "plugin/forward: gracefull stop (#1701)"
This reverts commit 135377bf77.

Revert "rework TestProxyClose (#1735)"
This reverts commit 9e8893a0b5.
This commit is contained in:
Miek Gieben
2018-04-26 09:34:58 +01:00
committed by GitHub
parent 4c7ae4ea95
commit 270da82995
5 changed files with 36 additions and 117 deletions

View File

@@ -34,16 +34,6 @@ 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()
@@ -55,6 +45,7 @@ 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 {