mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-28 04:34:54 -04:00
Add isc_async_current() macro to run job on current loop
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.
This commit is contained in:
parent
1844590ad9
commit
f5fc224af3
9 changed files with 22 additions and 25 deletions
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
/*%
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue