]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
dnstap io, fix exit when compiled without threads.
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Tue, 28 Jan 2020 14:09:21 +0000 (15:09 +0100)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Tue, 28 Jan 2020 14:09:21 +0000 (15:09 +0100)
dnstap/dnstap.c
dnstap/dtstream.c
dnstap/dtstream.h

index c06644eaecfb5fbe20d5212bdbe21dd224574c49..810f3200ad741619e0fe1e0b52a15f697fcac030 100644 (file)
@@ -262,7 +262,6 @@ dt_delete(struct dt_env *env)
 {
        if (!env)
                return;
-       verbose(VERB_OPS, "closing dnstap socket");
        dt_io_thread_delete(env->dtio);
        free(env->identity);
        free(env->version);
index 47f4473beba832f9e8bbacb80d18c0743125c83a..f21641049ae2fc17f3b224b0fe703054b64cadc0 100644 (file)
@@ -162,7 +162,7 @@ static void dtio_wakeup(struct dt_io_thread* dtio)
 {
        uint8_t cmd = DTIO_COMMAND_WAKEUP;
        if(!dtio) return;
-       if(!dtio->event_base) return; /* not started */
+       if(!dtio->started) return;
 
        while(1) {
                ssize_t r = write(dtio->commandpipe[1], &cmd, sizeof(cmd));
@@ -1292,6 +1292,7 @@ int dt_io_thread_start(struct dt_io_thread* dtio)
 #endif
 
        /* start the thread */
+       dtio->started = 1;
        ub_thread_create(&dtio->tid, dnstap_io, dtio);
        return 1;
 }
@@ -1300,7 +1301,8 @@ void dt_io_thread_stop(struct dt_io_thread* dtio)
 {
        uint8_t cmd = DTIO_COMMAND_STOP;
        if(!dtio) return;
-       if(!dtio->event_base) return; /* not started */
+       if(!dtio->started) return;
+       verbose(VERB_ALGO, "dnstap io: send stop cmd");
 
        while(1) {
                ssize_t r = write(dtio->commandpipe[1], &cmd, sizeof(cmd));
@@ -1321,6 +1323,7 @@ void dt_io_thread_stop(struct dt_io_thread* dtio)
                }
                break;
        }
+       dtio->started = 0;
 
 #ifndef USE_WINSOCK
        close(dtio->commandpipe[1]);
index 3386a1897508800e5fd7add034745e74a92a3780..473479d8f68abb3a4679f9e151862b4a93806c23 100644 (file)
@@ -102,6 +102,8 @@ struct dt_io_thread {
        struct dt_io_list_item* io_list_iter;
        /** thread id, of the io thread */
        ub_thread_type tid;
+       /** if the io processing has started */
+       int started;
 
        /** file descriptor that the thread writes to */
        int fd;