]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
4538. [bug] Call dns_client_startresolve from client->task.
authorMark Andrews <marka@isc.org>
Mon, 26 Dec 2016 20:02:33 +0000 (07:02 +1100)
committerMark Andrews <marka@isc.org>
Mon, 26 Dec 2016 20:14:56 +0000 (07:14 +1100)
                        [RT #43896]

(cherry picked from commit aceabacdb8de37c84dd18a12f40a09c1daa04b62)

CHANGES
lib/dns/client.c
lib/dns/include/dns/events.h

diff --git a/CHANGES b/CHANGES
index 329390f1828c05a22bbc87242ee11450df084b42..209acb29b9f6934e77193abd73c742141d648bf1 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+4538.  [bug]           Call dns_client_startresolve from client->task.
+                       [RT #43896]
+
 4537.  [bug]           Handle timouts better in dig/host/nslookup. [RT #43576]
 
 4536.  [bug]           ISC_SOCKEVENTATTR_USEMINMTU was not being cleared
index f1e483b4b2028bcd51910e8decf89a45059bd1de..f4504eeec130980edb56720707c0ff07cb01a6b5 100644 (file)
@@ -2743,6 +2743,46 @@ dns_client_update(dns_client_t *client, dns_rdataclass_t rdclass,
        return (result);
 }
 
+static void
+runintask(isc_task_t *task, isc_event_t *event) {
+       updatectx_t *uctx;
+       isc_result_t result;
+       unsigned int resoptions;
+
+       REQUIRE(event != NULL);
+
+       UNUSED(task);
+
+       uctx = event->ev_arg;
+
+       if (uctx->zonename != NULL && uctx->currentserver != NULL) {
+               result = send_update(uctx);
+               if (result != ISC_R_SUCCESS)
+                       goto fail;
+       } else if (uctx->currentserver != NULL) {
+               result = request_soa(uctx);
+               if (result != ISC_R_SUCCESS)
+                       goto fail;
+       } else {
+               resoptions = 0;
+               dns_name_clone(uctx->firstname, &uctx->soaqname);
+               result = dns_client_startresolve(uctx->client, &uctx->soaqname,
+                                                uctx->rdclass,
+                                                dns_rdatatype_soa, resoptions,
+                                                uctx->client->task,
+                                                resolvesoa_done, uctx,
+                                                &uctx->restrans);
+               if (result != ISC_R_SUCCESS)
+                       goto fail;
+       }
+
+       isc_event_free(&event);
+
+fail:
+       if (result != ISC_R_SUCCESS)
+               update_sendevent(uctx, result);
+}
+
 isc_result_t
 dns_client_startupdate(dns_client_t *client, dns_rdataclass_t rdclass,
                       dns_name_t *zonename, dns_namelist_t *prerequisites,
@@ -2759,6 +2799,7 @@ dns_client_startupdate(dns_client_t *client, dns_rdataclass_t rdclass,
        dns_section_t section = DNS_SECTION_UPDATE;
        isc_sockaddr_t *server, *sa = NULL;
        dns_tsectype_t tsectype = dns_tsectype_none;
+       isc_event_t *runinevent;
 
        UNUSED(options);
 
@@ -2780,18 +2821,33 @@ dns_client_startupdate(dns_client_t *client, dns_rdataclass_t rdclass,
        if (result != ISC_R_SUCCESS)
                return (result);
 
-       /* Create a context and prepare some resources */
+       /*
+        * Create a context and prepare some resources.
+        */
+
        uctx = isc_mem_get(client->mctx, sizeof(*uctx));
        if (uctx == NULL) {
                dns_view_detach(&view);
                return (ISC_R_NOMEMORY);
        }
+
+       runinevent = isc_event_allocate(client->mctx, client->task,
+                                       DNS_EVENT_RUNIN, runintask,
+                                       uctx, sizeof(*runinevent));
+       if (runinevent == NULL) { 
+               dns_view_detach(&view);
+               isc_mem_put(client->mctx, uctx, sizeof(*uctx));
+               return (ISC_R_NOMEMORY);
+       }
+
        result = isc_mutex_init(&uctx->lock);
        if (result != ISC_R_SUCCESS) {
                dns_view_detach(&view);
+               isc_event_free(&runinevent);
                isc_mem_put(client->mctx, uctx, sizeof(*uctx));
                return (ISC_R_NOMEMORY);
        }
+
        tclone = NULL;
        isc_task_attach(task, &tclone);
        uctx->client = client;
@@ -2892,30 +2948,14 @@ dns_client_startupdate(dns_client_t *client, dns_rdataclass_t rdclass,
        ISC_LIST_APPEND(client->updatectxs, uctx, link);
        UNLOCK(&client->lock);
 
-       if (uctx->zonename != NULL && uctx->currentserver != NULL) {
-               result = send_update(uctx);
-               if (result != ISC_R_SUCCESS)
-                       goto fail;
-       } else if (uctx->currentserver != NULL) {
-               result = request_soa(uctx);
-               if (result != ISC_R_SUCCESS)
-                       goto fail;
-       } else {
-               dns_name_clone(uctx->firstname, &uctx->soaqname);
-               result = dns_client_startresolve(uctx->client, &uctx->soaqname,
-                                                uctx->rdclass,
-                                                dns_rdatatype_soa, 0,
-                                                client->task, resolvesoa_done,
-                                                uctx, &uctx->restrans);
-               if (result != ISC_R_SUCCESS)
-                       goto fail;
-       }
-
        *transp = (dns_clientupdatetrans_t *)uctx;
+       isc_task_send(client->task, &runinevent);
 
        return (ISC_R_SUCCESS);
 
  fail:
+       if (runinevent != NULL)
+               isc_event_free(&runinevent);
        if (ISC_LINK_LINKED(uctx, link)) {
                LOCK(&client->lock);
                ISC_LIST_UNLINK(client->updatectxs, uctx, link);
index fd2144f64937850a40c6c0ad88be359efd60e91e..d7728762c3481cda0fb12ba9786f14b7025ba9ef 100644 (file)
 #define DNS_EVENT_ZONELOAD                     (ISC_EVENTCLASS_DNS + 49)
 #define DNS_EVENT_KEYDONE                      (ISC_EVENTCLASS_DNS + 50)
 #define DNS_EVENT_SETNSEC3PARAM                        (ISC_EVENTCLASS_DNS + 51)
+#define DNS_EVENT_SETSERIAL                    (ISC_EVENTCLASS_DNS + 52)
+#define DNS_EVENT_CATZUPDATED                  (ISC_EVENTCLASS_DNS + 53)
+#define DNS_EVENT_CATZADDZONE                  (ISC_EVENTCLASS_DNS + 54)
+#define DNS_EVENT_CATZMODZONE                  (ISC_EVENTCLASS_DNS + 55)
+#define DNS_EVENT_CATZDELZONE                  (ISC_EVENTCLASS_DNS + 56)
+#define DNS_EVENT_RUNIN                                (ISC_EVENTCLASS_DNS + 57)
 
 #define DNS_EVENT_FIRSTEVENT                   (ISC_EVENTCLASS_DNS + 0)
 #define DNS_EVENT_LASTEVENT                    (ISC_EVENTCLASS_DNS + 65535)