]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
lock access to fctx->nqueries
authorMark Andrews <marka@isc.org>
Mon, 2 Dec 2019 05:58:57 +0000 (16:58 +1100)
committerMark Andrews <marka@isc.org>
Wed, 11 Dec 2019 00:01:59 +0000 (11:01 +1100)
(cherry picked from commit 5589748ecac0b016c2221ba74249fbfbddf412b6)

lib/dns/resolver.c

index 7890407f6637d5f4de8bca4f0706f6cd6c45ac5e..6f672a13a85ea7fb8aae62d1c5f3443b4f1daec1 100644 (file)
@@ -1136,9 +1136,8 @@ resquery_destroy(resquery_t **queryp) {
        res = fctx->res;
        bucket = fctx->bucketnum;
 
-       fctx->nqueries--;
-
        LOCK(&res->buckets[bucket].lock);
+       fctx->nqueries--;
        empty = fctx_decreference(query->fctx);
        UNLOCK(&res->buckets[bucket].lock);
 
@@ -1937,6 +1936,7 @@ fctx_query(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo,
        bool have_addr = false;
        unsigned int srtt;
        isc_dscp_t dscp = -1;
+       unsigned int bucketnum;
 
        FCTXTRACE("query");
 
@@ -2162,7 +2162,10 @@ fctx_query(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo,
        fctx->querysent++;
 
        ISC_LIST_APPEND(fctx->queries, query, link);
-       query->fctx->nqueries++;
+       bucketnum = fctx->bucketnum;
+       LOCK(&res->buckets[bucketnum].lock);
+       fctx->nqueries++;
+       UNLOCK(&res->buckets[bucketnum].lock);
        if (isc_sockaddr_pf(&addrinfo->sockaddr) == PF_INET)
                inc_stats(res, dns_resstatscounter_queryv4);
        else