BUG/MINOR: resolvers: Reset server address on DNS error only on status change
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 10 Mar 2021 19:31:40 +0000 (20:31 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 12 Mar 2021 15:43:37 +0000 (16:43 +0100)
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.

src/server.c

index 18996a0..c577dc8 100644 (file)
@@ -3293,8 +3293,8 @@ int snr_resolution_error_cb(struct resolv_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;
 }