From ba18abcd35eb6afc9ec5841d5d385ff4e3faf130 Mon Sep 17 00:00:00 2001 From: "W.C.A. Wijngaards" Date: Wed, 2 Apr 2025 16:25:58 +0200 Subject: [PATCH] - Fix that ub_event has the facility to deal with callbacks for fast reload, doq, windows-stop and dnstap. - Fix fast reload test to check if pid exists before acting on it. --- Makefile.in | 2 +- doc/Changelog | 3 + .../fast_reload_fwd.tdir/fast_reload_fwd.post | 4 +- util/ub_event.c | 55 ++++++++++++++++++- 4 files changed, 61 insertions(+), 3 deletions(-) diff --git a/Makefile.in b/Makefile.in index 0cdff8ac1..463cdac28 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1064,7 +1064,7 @@ tube.lo tube.o: $(srcdir)/util/tube.c config.h $(srcdir)/util/tube.h $(srcdir)/u $(srcdir)/libunbound/unbound.h $(srcdir)/respip/respip.h $(srcdir)/util/ub_event.h ub_event.lo ub_event.o: $(srcdir)/util/ub_event.c config.h $(srcdir)/util/ub_event.h $(srcdir)/util/log.h \ $(srcdir)/util/netevent.h $(srcdir)/dnscrypt/dnscrypt.h \ - $(srcdir)/util/tube.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h + $(srcdir)/util/tube.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/daemon/remote.h ub_event_pluggable.lo ub_event_pluggable.o: $(srcdir)/util/ub_event_pluggable.c config.h $(srcdir)/util/ub_event.h \ $(srcdir)/libunbound/unbound-event.h $(srcdir)/util/netevent.h $(srcdir)/dnscrypt/dnscrypt.h \ $(srcdir)/util/log.h $(srcdir)/util/fptr_wlist.h \ diff --git a/doc/Changelog b/doc/Changelog index fff1cc51d..167a2ce42 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -7,6 +7,9 @@ - Fix unbound-control test so it counts the new flush_negative output, also answers the _ta probe from testns and prints command output and skip a thread specific test when no threads are available. + - Fix that ub_event has the facility to deal with callbacks for + fast reload, doq, windows-stop and dnstap. + - Fix fast reload test to check if pid exists before acting on it. 1 April 2025: Wouter - Fix escape more characters when printing an RR type with an unquoted diff --git a/testdata/fast_reload_fwd.tdir/fast_reload_fwd.post b/testdata/fast_reload_fwd.tdir/fast_reload_fwd.post index e7e644b7a..969d0080d 100644 --- a/testdata/fast_reload_fwd.tdir/fast_reload_fwd.post +++ b/testdata/fast_reload_fwd.tdir/fast_reload_fwd.post @@ -10,7 +10,9 @@ PRE="../.." kill_pid $NS1_PID kill_pid $NS2_PID if test -f unbound.pid; then - kill_pid $UNBOUND_PID + if kill -0 $UNBOUND_PID >/dev/null 2>&1; then + kill_pid $UNBOUND_PID + fi fi rm -f $CONTROL_PATH/controlpipe.$CONTROL_PID echo diff --git a/util/ub_event.c b/util/ub_event.c index 8cd87ec4e..93fbaec17 100644 --- a/util/ub_event.c +++ b/util/ub_event.c @@ -46,6 +46,7 @@ #include "util/log.h" #include "util/netevent.h" #include "util/tube.h" +#include "daemon/remote.h" /* We define libevent structures here to hide the libevent stuff. */ @@ -95,9 +96,29 @@ UB_EV_BITS_CB(comm_timer_callback) UB_EV_BITS_CB(comm_signal_callback) UB_EV_BITS_CB(comm_point_local_handle_callback) UB_EV_BITS_CB(comm_point_raw_handle_callback) -UB_EV_BITS_CB(comm_point_http_handle_callback) UB_EV_BITS_CB(tube_handle_signal) UB_EV_BITS_CB(comm_base_handle_slow_accept) +UB_EV_BITS_CB(comm_point_http_handle_callback) +#ifdef HAVE_NGTCP2 +UB_EV_BITS_CB(comm_point_doq_callback) +#endif +UB_EV_BITS_CB(fast_reload_service_cb) +#ifdef USE_DNSTAP +UB_EV_BITS_CB(dtio_output_cb) +UB_EV_BITS_CB(dtio_cmd_cb) +UB_EV_BITS_CB(dtio_reconnect_timeout_cb) +UB_EV_BITS_CB(dtio_stop_timer_cb) +UB_EV_BITS_CB(dtio_stop_ev_cb) +UB_EV_BITS_CB(dtio_tap_callback) +UB_EV_BITS_CB(dtio_mainfdcallback) +#endif +#ifdef HAVE_NGTCP2 +UB_EV_BITS_CB(doq_client_event_cb) +UB_EV_BITS_CB(doq_client_timer_cb) +#endif +#ifdef UB_ON_WINDOWS +UB_EV_BITS_CB(worker_win_stop_cb) +#endif static void (*NATIVE_BITS_CB(void (*cb)(int, short, void*)))(int, short, void*) { @@ -123,6 +144,38 @@ static void (*NATIVE_BITS_CB(void (*cb)(int, short, void*)))(int, short, void*) return my_tube_handle_signal; else if(cb == comm_base_handle_slow_accept) return my_comm_base_handle_slow_accept; +#ifdef HAVE_NGTCP2 + else if(cb == comm_point_doq_callback) + return my_comm_point_doq_callback; +#endif + else if(cb == fast_reload_service_cb) + return my_fast_reload_service_cb; +#ifdef USE_DNSTAP + else if(cb == dtio_output_cb) + return my_dtio_output_cb; + else if(cb == dtio_cmd_cb) + return my_dtio_cmd_cb; + else if(cb == dtio_reconnect_timeout_cb) + return my_dtio_reconnect_timeout_cb; + else if(cb == dtio_stop_timer_cb) + return my_dtio_stop_timer_cb; + else if(cb == dtio_stop_ev_cb) + return my_dtio_stop_ev_cb; + else if(cb == dtio_tap_callback) + return my_dtio_tap_callback; + else if(cb == dtio_mainfdcallback) + return my_dtio_mainfdcallback; +#endif +#ifdef HAVE_NGTCP2 + else if(cb == doq_client_event_cb) + return my_doq_client_event_cb; + else if(cb == doq_client_timer_cb) + return my_doq_client_timer_cb; +#endif +#ifdef UB_ON_WINDOWS + else if(cb == worker_win_stop_cb) + return my_worker_win_stop_cb; +#endif else { log_assert(0); /* this NULL callback pointer should not happen, we should have the necessary routine listed above */ -- 2.47.3