mirror of
https://github.com/coredns/coredns.git
synced 2025-10-30 01:34:21 -04:00
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).
This commit is contained in:
@@ -28,13 +28,16 @@ func (r *customPolicy) Select(pool HostPool) *UpstreamHost {
|
||||
func testPool() HostPool {
|
||||
pool := []*UpstreamHost{
|
||||
{
|
||||
Name: workableServer.URL, // this should resolve (healthcheck test)
|
||||
Name: workableServer.URL, // this should resolve (healthcheck test)
|
||||
Unhealthy: newBool(),
|
||||
},
|
||||
{
|
||||
Name: "http://shouldnot.resolve", // this shouldn't
|
||||
Name: "http://shouldnot.resolve", // this shouldn't
|
||||
Unhealthy: newBool(),
|
||||
},
|
||||
{
|
||||
Name: "http://C",
|
||||
Name: "http://C",
|
||||
Unhealthy: newBool(),
|
||||
},
|
||||
}
|
||||
return HostPool(pool)
|
||||
@@ -54,7 +57,7 @@ func TestRoundRobinPolicy(t *testing.T) {
|
||||
t.Error("Expected second round robin host to be third host in the pool.")
|
||||
}
|
||||
// mark host as down
|
||||
pool[0].Unhealthy = true
|
||||
*pool[0].Unhealthy = true
|
||||
h = rrPolicy.Select(pool)
|
||||
if h != pool[1] {
|
||||
t.Error("Expected third round robin host to be first host in the pool.")
|
||||
|
||||
Reference in New Issue
Block a user