]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
4629. [bug] dns_client_startupdate could not be called with a
authorMark Andrews <marka@isc.org>
Mon, 29 May 2017 23:47:41 +0000 (09:47 +1000)
committerMark Andrews <marka@isc.org>
Mon, 29 May 2017 23:51:34 +0000 (09:51 +1000)
                        running client. [RT #45277]

(cherry picked from commit e51d62ecaee0b0171ca47cbf63cc082d2ad98ce5)

CHANGES
bin/tests/system/nsupdate/tests.sh
lib/dns/client.c
lib/dns/include/dns/events.h
lib/isc/unix/app.c
lib/samples/sample-update.c

diff --git a/CHANGES b/CHANGES
index 38580540f0838e1b66a738573c707777711461ff..f3c93a99745bf51eb2d653ce516a438a6eba9282 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+4629.  [bug]           dns_client_startupdate could not be called with a
+                       running client. [RT #45277]
+
 4628.  [bug]           Fixed a potential reference leak in query_getdb().
                        [RT #45247]
 
index dee35332779b7f3429e5f25b9a70df0c96ffae40..f634234f6ebf58dc2247c05eb2b763097445fe5f 100755 (executable)
@@ -688,7 +688,8 @@ grep "status: NOERROR" check.out.ns2.test$n > /dev/null || ret=1
 
 n=`expr $n + 1`
 echo "I:check that dns_client_update handles prerequisite YXRRSET failure ($n)"
-$SAMPLEUPDATE -P 5300 -a 10.53.0.1 -a 10.53.0.2 -p "yxrrset no-txt.sample TXT" \
+$SAMPLEUPDATE -s -P 5300 -a 10.53.0.1 -a 10.53.0.2 \
+       -p "yxrrset no-txt.sample TXT" \
        add "yxrrset-nxrrset.sample 0 in a 1.2.3.4" > update.out.test$n 2>&1
 $SAMPLEUPDATE -P 5300 -a 10.53.0.2 -p "yxrrset no-txt.sample TXT" \
        add "check-yxrrset-nxrrset.sample 0 in a 1.2.3.4" > update.out.check$n 2>&1
@@ -700,6 +701,7 @@ grep "update succeeded" update.out.check$n > /dev/null || ret=1
 grep "status: NXDOMAIN" dig.out.ns1.test$n > /dev/null || ret=1
 grep "status: NXDOMAIN" dig.out.ns2.test$n > /dev/null || ret=1
 grep "status: NOERROR" check.out.ns2.test$n > /dev/null || ret=1
+grep "2nd update failed: NXRRSET" update.out.test$n > /dev/null || ret=1
 [ $ret = 0 ] || { echo I:failed; status=1; }
 
 #
index 8fd0efe02122f99f1345aaffa30d0f95528f8544..893798768ca65df98943f7b1a1ff4736e087c9fe 100644 (file)
@@ -2940,6 +2940,17 @@ dns_client_startupdate(dns_client_t *client, dns_rdataclass_t rdclass,
        *transp = (dns_clientupdatetrans_t *)uctx;
        result = isc_app_ctxonrun(client->actx, client->mctx, client->task,
                                  startupdate, uctx);
+       if (result == ISC_R_ALREADYRUNNING) {
+               isc_event_t *event;
+               event = isc_event_allocate(client->mctx, dns_client_startupdate,
+                                          DNS_EVENT_STARTUPDATE, startupdate,
+                                          uctx, sizeof(*event));
+               if (event != NULL) {
+                       result = ISC_R_SUCCESS;
+                       isc_task_send(task, &event);
+               } else
+                       result = ISC_R_NOMEMORY;
+       }
        if (result == ISC_R_SUCCESS)
                return (result);
        *transp = NULL;
index fecf5f5b57ae1fc8d0ea36fa47c2af0ddb113ee6..87447dff942af1a1696a41dbfb93a807ee33a4d3 100644 (file)
@@ -80,6 +80,7 @@
 #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_STARTUPDATE                  (ISC_EVENTCLASS_DNS + 58)
 
 #define DNS_EVENT_FIRSTEVENT                   (ISC_EVENTCLASS_DNS + 0)
 #define DNS_EVENT_LASTEVENT                    (ISC_EVENTCLASS_DNS + 65535)
index edd0745db506e356e09c7f93ff2f06e02941a558..1e87af3c338f7e16d27526d394679dc570eed1e3 100644 (file)
@@ -425,6 +425,7 @@ isc__app_ctxonrun(isc_appctx_t *ctx0, isc_mem_t *mctx, isc_task_t *task,
        event = isc_event_allocate(mctx, cloned_task, ISC_APPEVENT_SHUTDOWN,
                                   action, arg, sizeof(*event));
        if (event == NULL) {
+               isc_task_detach(&cloned_task);
                result = ISC_R_NOMEMORY;
                goto unlock;
        }
index 2f63c9c92cb8b414f1a87a1ac7f3fa4e00372cb8..5f24f8b71fb0ff243109652e58bda01c100a60bd 100644 (file)
@@ -81,6 +81,7 @@ usage(void) ISC_PLATFORM_NORETURN_POST;
 static void
 usage(void) {
        fprintf(stderr, "sample-update "
+               "-s "
                "[-a auth_server] "
                "[-k keyfile] "
                "[-p prerequisite] "
@@ -132,7 +133,7 @@ main(int argc, char *argv[]) {
        isc_sockaddr_t sa_auth[10], sa_recursive[10];
        unsigned int nsa_auth = 0, nsa_recursive = 0;
        isc_sockaddrlist_t rec_servers;
-       isc_sockaddrlist_t auth_servers;
+       isc_sockaddrlist_t auth_servers, *auth_serversp = &auth_servers;
        isc_result_t result;
        isc_boolean_t isdelete;
        isc_buffer_t b, *buf;
@@ -144,11 +145,12 @@ main(int argc, char *argv[]) {
        dns_rdata_t *rdata;
        dns_namelist_t updatelist, prereqlist, *prereqlistp = NULL;
        isc_mem_t *umctx = NULL;
+       isc_boolean_t sendtwice;
 
        ISC_LIST_INIT(auth_servers);
        ISC_LIST_INIT(rec_servers);
 
-       while ((ch = isc_commandline_parse(argc, argv, "a:k:p:P:r:z:")) != EOF) {
+       while ((ch = isc_commandline_parse(argc, argv, "a:k:p:P:r:sz:")) != EOF) {
                switch (ch) {
                case 'k':
                        keyfilename = isc_commandline_argument;
@@ -172,6 +174,9 @@ main(int argc, char *argv[]) {
                                      &sa_recursive[nsa_recursive]))
                                nsa_recursive++;
                        break;
+               case 's':
+                       sendtwice = ISC_TRUE;
+                       break;
                case 'z':
                        zonenamestr = isc_commandline_argument;
                        break;
@@ -258,18 +263,33 @@ main(int argc, char *argv[]) {
        if (keyfilename != NULL)
                setup_tsec(keyfilename, umctx);
 
+       if (ISC_LIST_HEAD(auth_servers) == NULL)
+               auth_serversp = NULL;
+
        /* Perform update */
        result = dns_client_update(client,
                                   default_rdataclass, /* XXX: fixed */
                                   zname, prereqlistp, &updatelist,
-                                  (ISC_LIST_HEAD(auth_servers) == NULL) ?
-                                   NULL : &auth_servers, tsec, 0);
+                                  auth_serversp, tsec, 0);
        if (result != ISC_R_SUCCESS) {
                fprintf(stderr,
                        "update failed: %s\n", dns_result_totext(result));
        } else
                fprintf(stderr, "update succeeded\n");
 
+       if (sendtwice) {
+               /* Perform 2nd update */
+               result = dns_client_update(client,
+                                          default_rdataclass, /* XXX: fixed */
+                                          zname, prereqlistp, &updatelist,
+                                          auth_serversp, tsec, 0);
+               if (result != ISC_R_SUCCESS) {
+                       fprintf(stderr, "2nd update failed: %s\n",
+                               dns_result_totext(result));
+               } else
+                       fprintf(stderr, "2nd update succeeded\n");
+       }
+
        /* Cleanup */
        while ((pname = ISC_LIST_HEAD(prereqlist)) != NULL) {
                while ((rdataset = ISC_LIST_HEAD(pname->list)) != NULL) {