BUG/MINOR: resolvers: Reset server address on DNS error only on status change
When a DNS resolution error is detected, in snr_resolution_error_cb(), the
server address must be reset only if the server status has changed. It this
case, it means the server is set to RMAINT. Thus the server address may by
reset.
This patch fixes a bug introduced by commit d127ffa9f ("BUG/MEDIUM:
resolvers: Reset address for unresolved servers"). It must be backported as
far as 2.0.
(cherry picked from commit 5130c21fbb806a28ab4e535b700df872a80798d8)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/src/server.c b/src/server.c
index f721254..a90e568 100644
--- a/src/server.c
+++ b/src/server.c
@@ -3995,8 +3995,8 @@
if (!s)
return 1;
HA_SPIN_LOCK(SERVER_LOCK, &s->lock);
- snr_update_srv_status(s, 1);
- memset(&s->addr, 0, sizeof(s->addr));
+ if (!snr_update_srv_status(s, 1))
+ memset(&s->addr, 0, sizeof(s->addr));
HA_SPIN_UNLOCK(SERVER_LOCK, &s->lock);
return 1;
}