aboutsummaryrefslogtreecommitdiff
path: root/middleware/proxy/proxy.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2017-04-13 16:26:05 +0100
committerGravatar GitHub <noreply@github.com> 2017-04-13 16:26:05 +0100
commitacbf522cebdcd53c26d153c1d9267d709ba75f64 (patch)
tree9c2e3e31041a1ef2a49bd7118a0b1c56813a82d5 /middleware/proxy/proxy.go
parentef4fa66e670fabe5c4dcfecc319c0f99d02bfd07 (diff)
downloadcoredns-acbf522cebdcd53c26d153c1d9267d709ba75f64.tar.gz
coredns-acbf522cebdcd53c26d153c1d9267d709ba75f64.tar.zst
coredns-acbf522cebdcd53c26d153c1d9267d709ba75f64.zip
middleware/proxy: Make Unhealthy a pointer (#615)
Pointer updates are atomic so drop the sync.RWMutex as it is not needed anymore. This also fixes the race introduced with dfc71df (although I believe this is the first time we properly tested that code path).
Diffstat (limited to 'middleware/proxy/proxy.go')
-rw-r--r--middleware/proxy/proxy.go6
1 files changed, 2 insertions, 4 deletions
diff --git a/middleware/proxy/proxy.go b/middleware/proxy/proxy.go
index ce8b99d83..ca7b8daa0 100644
--- a/middleware/proxy/proxy.go
+++ b/middleware/proxy/proxy.go
@@ -3,7 +3,6 @@ package proxy
import (
"errors"
- "sync"
"sync/atomic"
"time"
@@ -57,10 +56,9 @@ type UpstreamHost struct {
Name string // IP address (and port) of this upstream host
Fails int32
FailTimeout time.Duration
- Unhealthy bool
+ Unhealthy *bool
CheckDown UpstreamHostDownFunc
WithoutPathPrefix string
- checkMu sync.Mutex
}
// Down checks whether the upstream host is down or not.
@@ -70,7 +68,7 @@ func (uh *UpstreamHost) Down() bool {
if uh.CheckDown == nil {
// Default settings
fails := atomic.LoadInt32(&uh.Fails)
- return uh.Unhealthy || fails > 0
+ return *uh.Unhealthy || fails > 0
}
return uh.CheckDown(uh)
}