mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 16:24:19 -04:00
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 commit135377bf77. Revert "rework TestProxyClose (#1735)" This reverts commit9e8893a0b5.
This commit is contained in:
@@ -24,9 +24,6 @@ type Proxy struct {
|
||||
fails uint32
|
||||
|
||||
avgRtt int64
|
||||
|
||||
state uint32
|
||||
inProgress int32
|
||||
}
|
||||
|
||||
// NewProxy returns a new proxy.
|
||||
@@ -85,26 +82,15 @@ func (p *Proxy) Down(maxfails uint32) bool {
|
||||
return fails > maxfails
|
||||
}
|
||||
|
||||
// close stops the health checking goroutine and connection manager.
|
||||
// close stops the health checking goroutine.
|
||||
func (p *Proxy) close() {
|
||||
if atomic.CompareAndSwapUint32(&p.state, running, stopping) {
|
||||
p.probe.Stop()
|
||||
}
|
||||
if atomic.LoadInt32(&p.inProgress) == 0 {
|
||||
p.checkStopTransport()
|
||||
}
|
||||
p.probe.Stop()
|
||||
p.transport.Stop()
|
||||
}
|
||||
|
||||
// start starts the proxy's healthchecking.
|
||||
func (p *Proxy) start(duration time.Duration) { p.probe.Start(duration) }
|
||||
|
||||
// checkStopTransport checks if stop was requested and stops connection manager
|
||||
func (p *Proxy) checkStopTransport() {
|
||||
if atomic.CompareAndSwapUint32(&p.state, stopping, stopped) {
|
||||
p.transport.Stop()
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
dialTimeout = 4 * time.Second
|
||||
timeout = 2 * time.Second
|
||||
@@ -112,9 +98,3 @@ const (
|
||||
minTimeout = 10 * time.Millisecond
|
||||
hcDuration = 500 * time.Millisecond
|
||||
)
|
||||
|
||||
const (
|
||||
running = iota
|
||||
stopping
|
||||
stopped
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user