]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
dnstap io, move setup with nothreads into its own routine.
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Wed, 29 Jan 2020 15:31:33 +0000 (16:31 +0100)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Wed, 29 Jan 2020 15:31:33 +0000 (16:31 +0100)
dnstap/dtstream.c

index 2fd99a05cf0d3473eb47073c522dbc4ffc631707..8d98c559d4f1daf7123993d9f54752c38808a849 100644 (file)
@@ -1253,6 +1253,15 @@ static void dtio_open_output(struct dt_io_thread* dtio)
 #endif /* HAVE_SYS_UN_H */
 }
 
+/** perform the setup of the writer thread on the established event_base */
+static void dtio_setup_on_base(struct dt_io_thread* dtio)
+{
+       dtio_setup_cmd(dtio);
+       dtio_setup_reconnect(dtio);
+       dtio_open_output(dtio);
+       dtio_add_output_event_write(dtio);
+}
+
 #ifndef THREADS_DISABLED
 /** the IO thread function for the DNSTAP IO */
 static void* dnstap_io(void* arg)
@@ -1264,10 +1273,7 @@ static void* dnstap_io(void* arg)
        /* setup */
        verbose(VERB_ALGO, "start dnstap io thread");
        dtio_setup_base(dtio, &secs, &now);
-       dtio_setup_cmd(dtio);
-       dtio_setup_reconnect(dtio);
-       dtio_open_output(dtio);
-       dtio_add_output_event_write(dtio);
+       dtio_setup_on_base(dtio);
 
        /* run */
        if(ub_event_base_dispatch(dtio->event_base) < 0) {
@@ -1305,10 +1311,7 @@ int dt_io_thread_start(struct dt_io_thread* dtio, void* event_base_nothr)
        (void)event_base_nothr;
 #else
        dtio->event_base = event_base_nothr;
-       dtio_setup_cmd(dtio);
-       dtio_setup_reconnect(dtio);
-       dtio_open_output(dtio);
-       dtio_add_output_event_write(dtio);
+       dtio_setup_on_base(dtio);
 #endif
        return 1;
 }