BUG/MINOR: resolvers: Use resolver's lock in resolv_srvrq_expire_task()
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 18 Jun 2021 07:05:49 +0000 (09:05 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 6 Jul 2021 16:14:20 +0000 (18:14 +0200)
The commit dcac41806 ("BUG/MEDIUM: resolvers: Add a task on servers to check
SRV resolution status") introduced a type. In resolv_srvrq_expire_task()
function, the resolver's lock must be used instead of the resolver itself.

This patch must be backported with the patch above (at least as far as 2.2).

(cherry picked from commit e886dd5c32aa1bc99acf48c5bb1826f80d96923d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 152b50c38ab7ef1829d9a0115c393f518860314f)
[cf: Changes applied in src/dns.c instead of src/resolvers.c]
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

src/dns.c

index 2394db5..d00288d 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -668,9 +668,9 @@ static struct task *dns_srvrq_expire_task(struct task *t, void *context, unsigne
        if (!tick_is_expired(t->expire, now_ms))
                goto end;
 
-       HA_SPIN_LOCK(DNS_LOCK, &srv->srvrq->resolvers);
+       HA_SPIN_LOCK(DNS_LOCK, &srv->srvrq->resolvers->lock);
        dns_srvrq_cleanup_srv(srv);
-       HA_SPIN_UNLOCK(DNS_LOCK, &srv->srvrq->resolvers);
+       HA_SPIN_UNLOCK(DNS_LOCK, &srv->srvrq->resolvers->lock);
 
  end:
        return t;