mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-09 14:20:00 -04:00
complete removal of isc_loop_current()
isc_loop() can now take its place. This also requires changes to the test harness - instead of running the setup and teardown outside of th main loop, we now schedule the setup and teardown to run on the loop (via isc_loop_setup() and isc_loop_teardown()) - this is needed because the new the isc_loop() call has to be run on the active event loop, but previously the isc_loop_current() (and the variants like isc_loop_main()) would work even outside of the loop because it needed just isc_tid() to work, but not the full loop (which was mainly true for the main thread).
This commit is contained in:
parent
c47fa689d4
commit
63659e2e3a
13 changed files with 33 additions and 52 deletions
|
|
@ -2186,7 +2186,7 @@ run_server(void *arg) {
|
|||
NULL, NULL, ISC_NM_PROXY_NONE,
|
||||
&ifp->tcplistensocket));
|
||||
ifp->flags |= NS_INTERFACEFLAG_LISTENING;
|
||||
isc_async_current(loopmgr, sendquery, ifp->tcplistensocket);
|
||||
isc_async_current(sendquery, ifp->tcplistensocket);
|
||||
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -1674,7 +1674,7 @@ assignwork(void *arg) {
|
|||
lock_and_dumpnode(dns_fixedname_name(&fname), node);
|
||||
dns_db_detachnode(gdb, &node);
|
||||
|
||||
isc_async_current(loopmgr, assignwork, NULL);
|
||||
isc_async_current(assignwork, NULL);
|
||||
}
|
||||
|
||||
/*%
|
||||
|
|
|
|||
|
|
@ -2484,7 +2484,7 @@ static void
|
|||
done_update(void) {
|
||||
ddebug("done_update()");
|
||||
|
||||
isc_async_current(loopmgr, getinput, NULL);
|
||||
isc_async_current(getinput, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -439,7 +439,7 @@ dns_ntatable_covered(dns_ntatable_t *ntatable, isc_stdtime_t now,
|
|||
/* NTA is expired */
|
||||
dns__nta_ref(nta);
|
||||
dns_ntatable_ref(nta->ntatable);
|
||||
isc_async_current(nta->ntatable->loopmgr, delete_expired, nta);
|
||||
isc_async_current(delete_expired, nta);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,8 +45,7 @@ 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)
|
||||
#define isc_async_current(cb, cbarg) isc_async_run(isc_loop(), cb, cbarg)
|
||||
/*%<
|
||||
* Helper macro to run the job on the current loop
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -157,16 +157,6 @@ isc_loop_main(isc_loopmgr_t *loopmgr);
|
|||
*\li 'loopmgr' is a valid loop manager.
|
||||
*/
|
||||
|
||||
isc_loop_t *
|
||||
isc_loop_current(isc_loopmgr_t *loopmgr);
|
||||
/*%<
|
||||
* Returns the loop object from which the function has been called,
|
||||
* or NULL if not called from a loop.
|
||||
*
|
||||
* Requires:
|
||||
*\li 'loopmgr' is a valid loop manager.
|
||||
*/
|
||||
|
||||
isc_loop_t *
|
||||
isc_loop_get(isc_loopmgr_t *loopmgr, uint32_t tid);
|
||||
/*%<
|
||||
|
|
|
|||
|
|
@ -573,13 +573,6 @@ isc_loop_main(isc_loopmgr_t *loopmgr) {
|
|||
return (DEFAULT_LOOP(loopmgr));
|
||||
}
|
||||
|
||||
isc_loop_t *
|
||||
isc_loop_current(isc_loopmgr_t *loopmgr) {
|
||||
REQUIRE(VALID_LOOPMGR(loopmgr));
|
||||
|
||||
return (CURRENT_LOOP(loopmgr));
|
||||
}
|
||||
|
||||
isc_loop_t *
|
||||
isc_loop_get(isc_loopmgr_t *loopmgr, uint32_t tid) {
|
||||
REQUIRE(VALID_LOOPMGR(loopmgr));
|
||||
|
|
|
|||
|
|
@ -124,21 +124,21 @@ teardown_managers(void **state);
|
|||
} \
|
||||
;
|
||||
|
||||
#define ISC_LOOP_TEST_CUSTOM_IMPL(name, setup, teardown) \
|
||||
void run_test_##name(void **state ISC_ATTR_UNUSED); \
|
||||
void loop_test_##name(void *arg ISC_ATTR_UNUSED); \
|
||||
void run_test_##name(void **state ISC_ATTR_UNUSED) { \
|
||||
isc_job_cb setup_loop = setup; \
|
||||
isc_job_cb teardown_loop = teardown; \
|
||||
if (setup_loop != NULL) { \
|
||||
setup_loop(state); \
|
||||
} \
|
||||
isc_loop_setup(mainloop, loop_test_##name, state); \
|
||||
isc_loopmgr_run(loopmgr); \
|
||||
if (teardown_loop != NULL) { \
|
||||
teardown_loop(state); \
|
||||
} \
|
||||
} \
|
||||
#define ISC_LOOP_TEST_CUSTOM_IMPL(name, setup, teardown) \
|
||||
void run_test_##name(void **state ISC_ATTR_UNUSED); \
|
||||
void loop_test_##name(void *arg ISC_ATTR_UNUSED); \
|
||||
void run_test_##name(void **state ISC_ATTR_UNUSED) { \
|
||||
isc_job_cb setup_loop = setup; \
|
||||
isc_job_cb teardown_loop = teardown; \
|
||||
if (setup_loop != NULL) { \
|
||||
isc_loop_setup(mainloop, setup_loop, state); \
|
||||
} \
|
||||
if (teardown_loop != NULL) { \
|
||||
isc_loop_teardown(mainloop, teardown_loop, state); \
|
||||
} \
|
||||
isc_loop_setup(mainloop, loop_test_##name, state); \
|
||||
isc_loopmgr_run(loopmgr); \
|
||||
} \
|
||||
void loop_test_##name(void *arg ISC_ATTR_UNUSED)
|
||||
|
||||
#define ISC_LOOP_TEST_IMPL(name) ISC_LOOP_TEST_CUSTOM_IMPL(name, NULL, NULL)
|
||||
|
|
|
|||
|
|
@ -751,7 +751,7 @@ doh_receive_send_reply_cb(isc_nmhandle_t *handle, isc_result_t eresult,
|
|||
assert_true(eresult == ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
isc_async_current(loopmgr, doh_connect_thread, connect_nm);
|
||||
isc_async_current(doh_connect_thread, connect_nm);
|
||||
}
|
||||
if (sends <= 0) {
|
||||
isc_loopmgr_shutdown(loopmgr);
|
||||
|
|
|
|||
|
|
@ -67,9 +67,9 @@ ISC_RUN_TEST_IMPL(isc_loopmgr) {
|
|||
|
||||
static void
|
||||
runjob(void *arg ISC_ATTR_UNUSED) {
|
||||
isc_async_current(loopmgr, count, loopmgr);
|
||||
isc_async_current(count, loopmgr);
|
||||
if (isc_tid() == 0) {
|
||||
isc_async_current(loopmgr, shutdown_loopmgr, loopmgr);
|
||||
isc_async_current(shutdown_loopmgr, loopmgr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -388,7 +388,7 @@ 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_current(loopmgr, stream_recv_send_connect,
|
||||
isc_async_current(stream_recv_send_connect,
|
||||
(cbarg == NULL
|
||||
? get_stream_connect_function()
|
||||
: (stream_connect_function)cbarg));
|
||||
|
|
@ -1477,7 +1477,7 @@ udp__connect_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) {
|
|||
{
|
||||
do_cconnects_shutdown(loopmgr);
|
||||
} else if (do_send) {
|
||||
isc_async_current(loopmgr, udp_enqueue_connect, cbarg);
|
||||
isc_async_current(udp_enqueue_connect, cbarg);
|
||||
}
|
||||
|
||||
isc_refcount_increment0(&active_creads);
|
||||
|
|
@ -1819,8 +1819,7 @@ udp_shutdown_connect_connect_cb(isc_nmhandle_t *handle, isc_result_t eresult,
|
|||
*/
|
||||
if (atomic_fetch_add(&cconnects, 1) == 0) {
|
||||
assert_int_equal(eresult, ISC_R_SUCCESS);
|
||||
isc_async_current(loopmgr, udp_shutdown_connect_async_cb,
|
||||
netmgr);
|
||||
isc_async_current(udp_shutdown_connect_async_cb, netmgr);
|
||||
} else {
|
||||
assert_int_equal(eresult, ISC_R_SHUTTINGDOWN);
|
||||
}
|
||||
|
|
@ -1853,7 +1852,7 @@ udp_shutdown_connect(void **arg ISC_ATTR_UNUSED) {
|
|||
* isc_nm_udpconnect() is synchronous, so we need to launch this on the
|
||||
* async loop.
|
||||
*/
|
||||
isc_async_current(loopmgr, udp_shutdown_connect_async_cb, netmgr);
|
||||
isc_async_current(udp_shutdown_connect_async_cb, netmgr);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
|||
|
|
@ -101,21 +101,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_current(loopmgr, stream_recv_send_connect, tcpdns_connect);
|
||||
isc_async_current(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_current(loopmgr, stream_recv_send_connect, tcpdns_connect);
|
||||
isc_async_current(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_current(loopmgr, stream_recv_send_connect, tcpdns_connect);
|
||||
isc_async_current(stream_recv_send_connect, tcpdns_connect);
|
||||
|
||||
isc_async_current(loopmgr, stream_recv_send_connect, tcpdns_connect);
|
||||
isc_async_current(stream_recv_send_connect, tcpdns_connect);
|
||||
}
|
||||
|
||||
ISC_LOOP_TEST_IMPL(tcpdns_recv_send) {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
#include <tests/isc.h>
|
||||
|
||||
/* Set to true (or use -v option) for verbose output */
|
||||
static bool verbose = false;
|
||||
static bool verbose = true;
|
||||
|
||||
#define FUDGE_SECONDS 0 /* in absence of clock_getres() */
|
||||
#define FUDGE_NANOSECONDS 500000000 /* in absence of clock_getres() */
|
||||
|
|
@ -345,6 +345,7 @@ tick_event(void *arg) {
|
|||
*/
|
||||
if (tick == 0) {
|
||||
isc_timer_destroy(&tickertimer);
|
||||
isc_loopmgr_shutdown(loopmgr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -361,7 +362,6 @@ once_event(void *arg) {
|
|||
*/
|
||||
atomic_store(&startflag, true);
|
||||
|
||||
isc_loopmgr_shutdown(loopmgr);
|
||||
isc_timer_destroy(&oncetimer);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue