From: Christopher Faulet Date: Wed, 10 Mar 2021 19:31:40 +0000 (+0100) Subject: BUG/MINOR: resolvers: Reset server address on DNS error only on status change X-Git-Tag: v2.1.12~5 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=a91170cff48299c390bda6723c71ff9426b1d707;p=haproxy-2.1.git 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 (cherry picked from commit 7c9201e08f03367db74f2fca795cb1eb35d14554) Signed-off-by: Christopher Faulet (cherry picked from commit 06623af1dc7088a2f48a3aeb53e252edfea66ec6) Signed-off-by: Christopher Faulet --- diff --git a/src/server.c b/src/server.c index ea28f8a..4f14d6b 100644 --- a/src/server.c +++ b/src/server.c @@ -4256,8 +4256,8 @@ int snr_resolution_error_cb(struct dns_requester *requester, int error_code) 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; }