]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Make prefetch code use the 'recursions' array
authorMichał Kępień <michal@isc.org>
Tue, 14 Jun 2022 11:13:32 +0000 (13:13 +0200)
committerMichał Kępień <michal@isc.org>
Tue, 14 Jun 2022 11:13:32 +0000 (13:13 +0200)
Replace:

  - client->prefetchhandle with HANDLE_RECTYPE_PREFETCH(client)
  - client->query.prefetch with FETCH_RECTYPE_PREFETCH(client)

This is preparatory work for separating prefetch code from RPZ code.

lib/ns/client.c
lib/ns/include/ns/client.h
lib/ns/include/ns/query.h
lib/ns/query.c

index 627dfeb14f411534985cf6ca2f39ae08e143fe33..c40f40572c9ac67cd33d30fe7e6b82ac46969488 100644 (file)
@@ -62,6 +62,7 @@
 #include <ns/interfacemgr.h>
 #include <ns/log.h>
 #include <ns/notify.h>
+#include <ns/query.h>
 #include <ns/server.h>
 #include <ns/stats.h>
 #include <ns/update.h>
@@ -269,7 +270,7 @@ ns_client_endrequest(ns_client_t *client) {
         */
        if (client->recursionquota != NULL) {
                isc_quota_detach(&client->recursionquota);
-               if (client->query.prefetch == NULL) {
+               if (FETCH_RECTYPE_PREFETCH(client) == NULL) {
                        ns_stats_decrement(client->manager->sctx->nsstats,
                                           ns_statscounter_recursclients);
                }
index 71c223847b9129fa3c054da0d9e20051b25cf11d..67c641b7cc3de953ecaa81a89eadd72429a7182c 100644 (file)
@@ -170,13 +170,12 @@ struct ns_client {
        unsigned int     attributes;
        dns_view_t         *view;
        dns_dispatch_t  *dispatch;
-       isc_nmhandle_t  *handle;        /* Permanent pointer to handle */
-       isc_nmhandle_t  *sendhandle;    /* Waiting for send callback */
-       isc_nmhandle_t  *reqhandle;     /* Waiting for request callback
-                                          (query, update, notify) */
-       isc_nmhandle_t *fetchhandle;    /* Waiting for recursive fetch */
-       isc_nmhandle_t *prefetchhandle; /* Waiting for prefetch / rpzfetch */
-       isc_nmhandle_t *updatehandle;   /* Waiting for update callback */
+       isc_nmhandle_t  *handle;      /* Permanent pointer to handle */
+       isc_nmhandle_t  *sendhandle;  /* Waiting for send callback */
+       isc_nmhandle_t  *reqhandle;   /* Waiting for request callback
+                                        (query, update, notify) */
+       isc_nmhandle_t *fetchhandle;  /* Waiting for recursive fetch */
+       isc_nmhandle_t *updatehandle; /* Waiting for update callback */
        unsigned char  *tcpbuf;
        dns_message_t  *message;
        unsigned char  *sendbuf;
index 8476705386ad8e136013f98e5de3c1232f09cce4..a2f77d35f0677e51f373e61cbb6ddc9c28e1fb49 100644 (file)
@@ -95,7 +95,6 @@ struct ns_query {
        bool             isreferral;
        isc_mutex_t      fetchlock;
        dns_fetch_t         *fetch;
-       dns_fetch_t         *prefetch;
        ns_hookasync_t  *hookactx;
        dns_rpz_st_t    *rpz_st;
        isc_bufferlist_t namebufs;
index e63eb956ecf30d1d5affdfebda1c833aeac12570..6a7ebee0f0fc2663c18b27a8df3f0359b02fa062 100644 (file)
@@ -2525,9 +2525,9 @@ prefetch_done(isc_task_t *task, isc_event_t *event) {
        CTRACE(ISC_LOG_DEBUG(3), "prefetch_done");
 
        LOCK(&client->query.fetchlock);
-       if (client->query.prefetch != NULL) {
-               INSIST(devent->fetch == client->query.prefetch);
-               client->query.prefetch = NULL;
+       if (FETCH_RECTYPE_PREFETCH(client) != NULL) {
+               INSIST(devent->fetch == FETCH_RECTYPE_PREFETCH(client));
+               FETCH_RECTYPE_PREFETCH(client) = NULL;
        }
        UNLOCK(&client->query.fetchlock);
 
@@ -2537,7 +2537,7 @@ prefetch_done(isc_task_t *task, isc_event_t *event) {
        recursionquota_detach(client);
 
        free_devent(client, &event, &devent);
-       isc_nmhandle_detach(&client->prefetchhandle);
+       isc_nmhandle_detach(&HANDLE_RECTYPE_PREFETCH(client));
 }
 
 /*
@@ -2569,16 +2569,16 @@ fetch_and_forget(ns_client_t *client, dns_name_t *qname, dns_rdatatype_t qtype,
                peeraddr = NULL;
        }
 
-       isc_nmhandle_attach(client->handle, &client->prefetchhandle);
+       isc_nmhandle_attach(client->handle, &HANDLE_RECTYPE_PREFETCH(client));
        options = client->query.fetchoptions | extra_fetch_options;
        result = dns_resolver_createfetch(
                client->view->resolver, qname, qtype, NULL, NULL, NULL,
                peeraddr, client->message->id, options, 0, NULL,
                client->manager->task, prefetch_done, client, tmprdataset, NULL,
-               &client->query.prefetch);
+               &FETCH_RECTYPE_PREFETCH(client));
        if (result != ISC_R_SUCCESS) {
                ns_client_putrdataset(client, &tmprdataset);
-               isc_nmhandle_detach(&client->prefetchhandle);
+               isc_nmhandle_detach(&HANDLE_RECTYPE_PREFETCH(client));
        }
 }
 
@@ -2587,7 +2587,7 @@ query_prefetch(ns_client_t *client, dns_name_t *qname,
               dns_rdataset_t *rdataset) {
        CTRACE(ISC_LOG_DEBUG(3), "query_prefetch");
 
-       if (client->query.prefetch != NULL ||
+       if (FETCH_RECTYPE_PREFETCH(client) != NULL ||
            client->view->prefetch_trigger == 0U ||
            rdataset->ttl > client->view->prefetch_trigger ||
            (rdataset->attributes & DNS_RDATASETATTR_PREFETCH) == 0)
@@ -2762,7 +2762,7 @@ static void
 query_rpzfetch(ns_client_t *client, dns_name_t *qname, dns_rdatatype_t type) {
        CTRACE(ISC_LOG_DEBUG(3), "query_rpzfetch");
 
-       if (client->query.prefetch != NULL) {
+       if (FETCH_RECTYPE_PREFETCH(client) != NULL) {
                return;
        }