]> 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>
Tue, 10 Dec 2019 22:16:15 +0000 (22:16 +0000)
lib/dns/resolver.c

index 1ca37a8dc7fff4557d0fb78ef521085143be3366..9e625e79d5374b4e14b80957db783b8cb09c8a4b 100644 (file)
@@ -1137,9 +1137,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");
 
@@ -2158,7 +2158,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