]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add isc_async_current() macro to run job on current loop
authorOndřej Surý <ondrej@isc.org>
Wed, 29 Mar 2023 07:02:22 +0000 (09:02 +0200)
committerOndřej Surý <ondrej@isc.org>
Thu, 30 Mar 2023 14:07:41 +0000 (16:07 +0200)
Previously, isc_job_run() could have been used to run the job on the
current loop and the isc_job_run() would take care of allocating and
deallocating the job.  After the change in this MR, the isc_job_run()
is more complicated to use, so we introduce the isc_async_current()
macro to suplement isc_async_run() when we need to run the job on the
current loop.

bin/delv/delv.c
bin/dnssec/dnssec-signzone.c
bin/nsupdate/nsupdate.c
lib/isc/include/isc/async.h
tests/isc/doh_test.c
tests/isc/loop_test.c
tests/isc/netmgr_common.c
tests/isc/tcpdns_test.c
tests/isc/udp_test.c

index e42af92dd7eb8783ef368048ea8c1f6b40cbe13e..110d4210d7f3a405555b1195b82f717566d3a231 100644 (file)
@@ -2169,8 +2169,7 @@ run_server(void *arg) {
                                     ns_client_request, ifp, accept_cb, ifp, 10,
                                     NULL, NULL, &ifp->tcplistensocket));
        ifp->flags |= NS_INTERFACEFLAG_LISTENING;
-       isc_async_run(isc_loop_current(loopmgr), sendquery,
-                     ifp->tcplistensocket);
+       isc_async_current(loopmgr, sendquery, ifp->tcplistensocket);
 
        return;
 
index a8bb5785320a08d824316834a77410c057d51845..1a5b3b40fea03d222443554afb8403d8a2874127 100644 (file)
@@ -1667,7 +1667,7 @@ assignwork(void *arg) {
        lock_and_dumpnode(dns_fixedname_name(&fname), node);
        dns_db_detachnode(gdb, &node);
 
-       isc_async_run(isc_loop_current(loopmgr), assignwork, NULL);
+       isc_async_current(loopmgr, assignwork, NULL);
 }
 
 /*%
index 46eb03d423fd776ed68dbbd27a81ec6d76f27b11..9c38a6ed68c227191ceb5498ac30c21b2613406d 100644 (file)
@@ -2424,7 +2424,7 @@ static void
 done_update(void) {
        ddebug("done_update()");
 
-       isc_async_run(isc_loop_main(loopmgr), getinput, NULL);
+       isc_async_current(loopmgr, getinput, NULL);
 }
 
 static void
index ea36a150dd7cf9a418a9be4908bf12214971f526..c3785fa0f7746f2fcbbf78cf663206253d75e125 100644 (file)
@@ -45,4 +45,10 @@ isc_async_run(isc_loop_t *loop, isc_job_cb cb, void *cbarg);
  *\li  'cbarg' is passed to the 'cb' as the only argument, may be NULL
  */
 
+#define isc_async_current(loopmgr, cb, cbarg) \
+       isc_async_run(isc_loop_current(loopmgr), cb, cbarg)
+/*%<
+ * Helper macro to run the job on the current loop
+ */
+
 ISC_LANG_ENDDECLS
index 2c770ef0fce4bf6c80c5495592106fdedae805c2..43c0f98191ef2828612b9011b96d37bd059a2229 100644 (file)
@@ -702,8 +702,7 @@ doh_receive_send_reply_cb(isc_nmhandle_t *handle, isc_result_t eresult,
                        assert_true(eresult == ISC_R_SUCCESS);
                }
 
-               isc_async_run(isc_loop_current(loopmgr), doh_connect_thread,
-                             connect_nm);
+               isc_async_current(loopmgr, doh_connect_thread, connect_nm);
        }
        if (sends <= 0) {
                isc_loopmgr_shutdown(loopmgr);
index d863309c51130679684194e2914b2f96c859d458..cf13a4a586dc8370e74391835fa4772e1a459dfd 100644 (file)
@@ -66,11 +66,10 @@ ISC_RUN_TEST_IMPL(isc_loopmgr) {
 
 static void
 runjob(void *arg __attribute__((__unused__))) {
-       isc_async_run(isc_loop_current(loopmgr), count, loopmgr);
+       isc_async_current(loopmgr, count, loopmgr);
 
        if (isc_tid() == 0) {
-               isc_async_run(isc_loop_current(loopmgr), shutdown_loopmgr,
-                             loopmgr);
+               isc_async_current(loopmgr, shutdown_loopmgr, loopmgr);
        }
 }
 
index ad44777918ae1a12b03663459ef6c7e9a0f9e0bb..62bd912a1f710b3c4b974ec94b7094e031fd99d0 100644 (file)
@@ -368,10 +368,10 @@ connect_connect_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) {
        if (have_expected_cconnects(atomic_fetch_add(&cconnects, 1) + 1)) {
                do_cconnects_shutdown(loopmgr);
        } else if (do_send) {
-               isc_async_run(isc_loop_current(loopmgr),
-                             stream_recv_send_connect,
-                             (cbarg == NULL ? get_stream_connect_function()
-                                            : (stream_connect_function)cbarg));
+               isc_async_current(loopmgr, stream_recv_send_connect,
+                                 (cbarg == NULL
+                                          ? get_stream_connect_function()
+                                          : (stream_connect_function)cbarg));
        }
 
        isc_refcount_increment0(&active_creads);
index dabd0e84e4a3f3591b9991848abe95269207f2c9..4747f4ad20a9e9d70883f5e98be5be0d37cfeb2e 100644 (file)
@@ -100,25 +100,21 @@ ISC_LOOP_TEST_IMPL(tcpdns_timeout_recovery) {
        connect_readcb = timeout_retry_cb;
        isc_nm_settimeouts(connect_nm, T_SOFT, T_SOFT, T_SOFT, T_SOFT);
 
-       isc_async_run(isc_loop_current(loopmgr), stream_recv_send_connect,
-                     tcpdns_connect);
+       isc_async_current(loopmgr, stream_recv_send_connect, tcpdns_connect);
 }
 
 ISC_LOOP_TEST_IMPL(tcpdns_recv_one) {
        start_listening(ISC_NM_LISTEN_ONE, listen_accept_cb, listen_read_cb);
 
-       isc_async_run(isc_loop_current(loopmgr), stream_recv_send_connect,
-                     tcpdns_connect);
+       isc_async_current(loopmgr, stream_recv_send_connect, tcpdns_connect);
 }
 
 ISC_LOOP_TEST_IMPL(tcpdns_recv_two) {
        start_listening(ISC_NM_LISTEN_ONE, listen_accept_cb, listen_read_cb);
 
-       isc_async_run(isc_loop_current(loopmgr), stream_recv_send_connect,
-                     tcpdns_connect);
+       isc_async_current(loopmgr, stream_recv_send_connect, tcpdns_connect);
 
-       isc_async_run(isc_loop_current(loopmgr), stream_recv_send_connect,
-                     tcpdns_connect);
+       isc_async_current(loopmgr, stream_recv_send_connect, tcpdns_connect);
 }
 
 ISC_LOOP_TEST_IMPL(tcpdns_recv_send) {
index 54d4489a8a1e56520e8941f92b21d7888ae168d3..17221a1fb989dbc84faa4caa7ce5d9699aafbfc9 100644 (file)
@@ -540,8 +540,7 @@ ISC_TEARDOWN_TEST_IMPL(udp_shutdown_connect) {
 ISC_LOOP_TEST_IMPL(udp_shutdown_connect) {
        isc_loopmgr_shutdown(loopmgr);
        isc_refcount_increment0(&active_cconnects);
-       isc_async_run(isc_loop_current(loopmgr), udp_connect_udpconnect,
-                     netmgr);
+       isc_async_current(loopmgr, udp_connect_udpconnect, netmgr);
 }
 
 static void
@@ -865,8 +864,7 @@ udp__connect_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) {
                {
                        do_cconnects_shutdown(loopmgr);
                } else if (do_send) {
-                       isc_async_run(isc_loop_current(loopmgr), udp__connect,
-                                     cbarg);
+                       isc_async_current(loopmgr, udp__connect, cbarg);
                }
 
                isc_refcount_increment0(&active_creads);