]> 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:02:21 +0000 (11:02 +1100)
(cherry picked from commit 5589748ecac0b016c2221ba74249fbfbddf412b6)

lib/dns/resolver.c

index a17ba0dc4e063e015173e87ad32bdbb51a13cde7..7d7798058c3b0c30b35ba194268e9762772533b9 100644 (file)
@@ -877,9 +877,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);
 
@@ -1670,6 +1669,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");
 
@@ -1895,7 +1895,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