From: W.C.A. Wijngaards Date: Tue, 28 Jan 2020 14:09:21 +0000 (+0100) Subject: dnstap io, fix exit when compiled without threads. X-Git-Tag: 1.11.0rc1~120^2~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=989922631ae7f6d31a93ba454b6f4364bac64694;p=thirdparty%2Funbound.git dnstap io, fix exit when compiled without threads. --- diff --git a/dnstap/dnstap.c b/dnstap/dnstap.c index c06644eae..810f3200a 100644 --- a/dnstap/dnstap.c +++ b/dnstap/dnstap.c @@ -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); diff --git a/dnstap/dtstream.c b/dnstap/dtstream.c index 47f4473be..f21641049 100644 --- a/dnstap/dtstream.c +++ b/dnstap/dtstream.c @@ -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]); diff --git a/dnstap/dtstream.h b/dnstap/dtstream.h index 3386a1897..473479d8f 100644 --- a/dnstap/dtstream.h +++ b/dnstap/dtstream.h @@ -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;