mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-28 04:34:54 -04:00
Merge branch 'each-isc-loop' into 'main'
use a thread-local variable to get the current running loop See merge request isc-projects/bind9!8911
This commit is contained in:
commit
424cb59a43
30 changed files with 110 additions and 131 deletions
|
|
@ -2103,9 +2103,8 @@ sendquery(void *arg) {
|
|||
|
||||
dns_view_attach(view, &(dns_view_t *){ NULL });
|
||||
CHECK(dns_request_create(requestmgr, message, NULL, &peer, NULL, NULL,
|
||||
DNS_REQUESTOPT_TCP, NULL, 1, 0, 0,
|
||||
isc_loop_current(loopmgr), recvresponse,
|
||||
message, &request));
|
||||
DNS_REQUESTOPT_TCP, NULL, 1, 0, 0, isc_loop(),
|
||||
recvresponse, message, &request));
|
||||
return;
|
||||
|
||||
cleanup:
|
||||
|
|
@ -2167,8 +2166,8 @@ run_server(void *arg) {
|
|||
dns_view_initsecroots(view);
|
||||
CHECK(setup_dnsseckeys(NULL, view));
|
||||
|
||||
CHECK(dns_view_createresolver(view, loopmgr, netmgr, 0,
|
||||
tlsctx_client_cache, dispatch, NULL));
|
||||
CHECK(dns_view_createresolver(view, netmgr, 0, tlsctx_client_cache,
|
||||
dispatch, NULL));
|
||||
|
||||
isc_stats_create(mctx, &resstats, dns_resstatscounter_max);
|
||||
dns_resolver_setstats(view->resolver, resstats);
|
||||
|
|
@ -2187,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);
|
||||
}
|
||||
|
||||
/*%
|
||||
|
|
|
|||
|
|
@ -4701,9 +4701,9 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
CHECK(dns_view_createresolver(
|
||||
view, named_g_loopmgr, named_g_netmgr, resopts,
|
||||
named_g_server->tlsctx_client_cache, dispatch4, dispatch6));
|
||||
CHECK(dns_view_createresolver(view, named_g_netmgr, resopts,
|
||||
named_g_server->tlsctx_client_cache,
|
||||
dispatch4, dispatch6));
|
||||
|
||||
if (resstats == NULL) {
|
||||
isc_stats_create(mctx, &resstats, dns_resstatscounter_max);
|
||||
|
|
@ -8187,7 +8187,7 @@ load_configuration(const char *filename, named_server_t *server,
|
|||
/*
|
||||
* Require the reconfiguration to happen always on the main loop
|
||||
*/
|
||||
REQUIRE(isc_loop_current(named_g_loopmgr) == named_g_mainloop);
|
||||
REQUIRE(isc_loop() == named_g_mainloop);
|
||||
|
||||
ISC_LIST_INIT(kasplist);
|
||||
ISC_LIST_INIT(keystorelist);
|
||||
|
|
@ -9838,8 +9838,7 @@ run_server(void *arg) {
|
|||
named_server_t *server = (named_server_t *)arg;
|
||||
dns_geoip_databases_t *geoip = NULL;
|
||||
|
||||
dns_zonemgr_create(named_g_mctx, named_g_loopmgr, named_g_netmgr,
|
||||
&server->zonemgr);
|
||||
dns_zonemgr_create(named_g_mctx, named_g_netmgr, &server->zonemgr);
|
||||
|
||||
CHECKFATAL(dns_dispatchmgr_create(named_g_mctx, named_g_loopmgr,
|
||||
named_g_netmgr, &named_g_dispatchmgr),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -99,8 +99,6 @@ struct dns_adb {
|
|||
dns_view_t *view;
|
||||
dns_resolver_t *res;
|
||||
|
||||
isc_loopmgr_t *loopmgr;
|
||||
|
||||
isc_refcount_t references;
|
||||
|
||||
dns_adbnamelist_t names_lru;
|
||||
|
|
@ -1843,8 +1841,7 @@ ISC_REFCOUNT_IMPL(dns_adb, destroy);
|
|||
*/
|
||||
|
||||
void
|
||||
dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_loopmgr_t *loopmgr,
|
||||
dns_adb_t **newadb) {
|
||||
dns_adb_create(isc_mem_t *mem, dns_view_t *view, dns_adb_t **newadb) {
|
||||
dns_adb_t *adb = NULL;
|
||||
|
||||
REQUIRE(mem != NULL);
|
||||
|
|
@ -1853,7 +1850,6 @@ dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_loopmgr_t *loopmgr,
|
|||
|
||||
adb = isc_mem_get(mem, sizeof(dns_adb_t));
|
||||
*adb = (dns_adb_t){
|
||||
.loopmgr = loopmgr,
|
||||
.names_lru = ISC_LIST_INITIALIZER,
|
||||
.entries_lru = ISC_LIST_INITIALIZER,
|
||||
};
|
||||
|
|
@ -2994,8 +2990,8 @@ fetch_name(dns_adbname_t *adbname, bool start_at_zone, unsigned int depth,
|
|||
*/
|
||||
result = dns_resolver_createfetch(
|
||||
adb->res, adbname->name, type, name, nameservers, NULL, NULL, 0,
|
||||
options, depth, qc, isc_loop_current(adb->loopmgr),
|
||||
fetch_callback, adbname, &fetch->rdataset, NULL, &fetch->fetch);
|
||||
options, depth, qc, isc_loop(), fetch_callback, adbname,
|
||||
&fetch->rdataset, NULL, &fetch->fetch);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
DP(ENTER_LEVEL, "fetch_name: createfetch failed with %s",
|
||||
isc_result_totext(result));
|
||||
|
|
|
|||
|
|
@ -861,7 +861,7 @@ dns__catz_timer_start(dns_catz_zone_t *catz) {
|
|||
isc_interval_set(&interval, 0, 0);
|
||||
}
|
||||
|
||||
catz->loop = isc_loop_current(catz->catzs->loopmgr);
|
||||
catz->loop = isc_loop();
|
||||
|
||||
isc_timer_create(catz->loop, dns__catz_timer_cb, catz,
|
||||
&catz->updatetimer);
|
||||
|
|
|
|||
|
|
@ -198,8 +198,8 @@ getudpdispatch(int family, dns_dispatchmgr_t *dispatchmgr,
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
createview(isc_mem_t *mctx, dns_rdataclass_t rdclass, isc_loopmgr_t *loopmgr,
|
||||
isc_nm_t *nm, isc_tlsctx_cache_t *tlsctx_client_cache,
|
||||
createview(isc_mem_t *mctx, dns_rdataclass_t rdclass, isc_nm_t *nm,
|
||||
isc_tlsctx_cache_t *tlsctx_client_cache,
|
||||
dns_dispatchmgr_t *dispatchmgr, dns_dispatch_t *dispatchv4,
|
||||
dns_dispatch_t *dispatchv6, dns_view_t **viewp) {
|
||||
isc_result_t result;
|
||||
|
|
@ -214,7 +214,7 @@ createview(isc_mem_t *mctx, dns_rdataclass_t rdclass, isc_loopmgr_t *loopmgr,
|
|||
/* Initialize view security roots */
|
||||
dns_view_initsecroots(view);
|
||||
|
||||
CHECK(dns_view_createresolver(view, loopmgr, nm, 0, tlsctx_client_cache,
|
||||
CHECK(dns_view_createresolver(view, nm, 0, tlsctx_client_cache,
|
||||
dispatchv4, dispatchv6));
|
||||
CHECK(dns_db_create(mctx, CACHEDB_DEFAULT, dns_rootname,
|
||||
dns_dbtype_cache, rdclass, 0, NULL,
|
||||
|
|
@ -290,9 +290,8 @@ dns_client_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t *nm,
|
|||
isc_refcount_init(&client->references, 1);
|
||||
|
||||
/* Create the default view for class IN */
|
||||
result = createview(mctx, dns_rdataclass_in, loopmgr, nm,
|
||||
tlsctx_client_cache, client->dispatchmgr,
|
||||
dispatchv4, dispatchv6, &view);
|
||||
result = createview(mctx, dns_rdataclass_in, nm, tlsctx_client_cache,
|
||||
client->dispatchmgr, dispatchv4, dispatchv6, &view);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_references;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -225,12 +225,11 @@ struct dns_adbaddrinfo {
|
|||
*/
|
||||
|
||||
/****
|
||||
**** FUNCTIONS
|
||||
****/
|
||||
**** FUNCTIONS
|
||||
****/
|
||||
|
||||
void
|
||||
dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_loopmgr_t *loopmgr,
|
||||
dns_adb_t **newadb);
|
||||
dns_adb_create(isc_mem_t *mem, dns_view_t *view, dns_adb_t **newadb);
|
||||
/*%<
|
||||
* Create a new ADB.
|
||||
*
|
||||
|
|
@ -245,8 +244,6 @@ dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_loopmgr_t *loopmgr,
|
|||
*
|
||||
*\li 'view' be a pointer to a valid view.
|
||||
*
|
||||
*\li 'loopmgr' be a valid loop manager.
|
||||
*
|
||||
*\li 'newadb' != NULL && '*newadb' == NULL.
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -366,9 +366,8 @@ dns_view_weakdetach(dns_view_t **targetp);
|
|||
*/
|
||||
|
||||
isc_result_t
|
||||
dns_view_createresolver(dns_view_t *view, isc_loopmgr_t *loopmgr,
|
||||
isc_nm_t *netmgr, unsigned int options,
|
||||
isc_tlsctx_cache_t *tlsctx_cache,
|
||||
dns_view_createresolver(dns_view_t *view, isc_nm_t *netmgr,
|
||||
unsigned int options, isc_tlsctx_cache_t *tlsctx_cache,
|
||||
dns_dispatch_t *dispatchv4, dns_dispatch_t *dispatchv6);
|
||||
/*%<
|
||||
* Create a resolver and address database for the view.
|
||||
|
|
|
|||
|
|
@ -1684,8 +1684,7 @@ dns_zone_findkeys(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver,
|
|||
*/
|
||||
|
||||
void
|
||||
dns_zonemgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t *netmgr,
|
||||
dns_zonemgr_t **zmgrp);
|
||||
dns_zonemgr_create(isc_mem_t *mctx, isc_nm_t *netmgr, dns_zonemgr_t **zmgrp);
|
||||
/*%<
|
||||
* Create a zone manager.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ nta_create(dns_ntatable_t *ntatable, const dns_name_t *name,
|
|||
.magic = NTA_MAGIC,
|
||||
};
|
||||
isc_mem_attach(ntatable->mctx, &nta->mctx);
|
||||
isc_loop_attach(isc_loop_current(ntatable->loopmgr), &nta->loop);
|
||||
isc_loop_attach(isc_loop(), &nta->loop);
|
||||
|
||||
dns_rdataset_init(&nta->rdataset);
|
||||
dns_rdataset_init(&nta->sigrdataset);
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1616,9 +1616,8 @@ fctx_sendevents(fetchctx_t *fctx, isc_result_t result) {
|
|||
isc_interval_t i;
|
||||
|
||||
isc_timer_create(
|
||||
isc_loop_current(fctx->res->loopmgr),
|
||||
spillattimer_countdown, fctx->res,
|
||||
&fctx->res->spillattimer);
|
||||
isc_loop(), spillattimer_countdown,
|
||||
fctx->res, &fctx->res->spillattimer);
|
||||
|
||||
isc_interval_set(&i, 20 * 60, 0);
|
||||
isc_timer_start(fctx->res->spillattimer,
|
||||
|
|
@ -10016,9 +10015,8 @@ dns_resolver_prime(dns_resolver_t *res) {
|
|||
LOCK(&res->primelock);
|
||||
result = dns_resolver_createfetch(
|
||||
res, dns_rootname, dns_rdatatype_ns, NULL, NULL, NULL,
|
||||
NULL, 0, DNS_FETCHOPT_NOFORWARD, 0, NULL,
|
||||
isc_loop_current(res->loopmgr), prime_done, res,
|
||||
rdataset, NULL, &res->primefetch);
|
||||
NULL, 0, DNS_FETCHOPT_NOFORWARD, 0, NULL, isc_loop(),
|
||||
prime_done, res, rdataset, NULL, &res->primefetch);
|
||||
UNLOCK(&res->primelock);
|
||||
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
|
|
|
|||
|
|
@ -1704,7 +1704,7 @@ dns__rpz_timer_start(dns_rpz_zone_t *rpz) {
|
|||
isc_interval_set(&interval, 0, 0);
|
||||
}
|
||||
|
||||
rpz->loop = isc_loop_current(rpz->rpzs->loopmgr);
|
||||
rpz->loop = isc_loop();
|
||||
|
||||
isc_timer_create(rpz->loop, dns__rpz_timer_cb, rpz, &rpz->updatetimer);
|
||||
isc_timer_start(rpz->updatetimer, isc_timertype_once, &interval);
|
||||
|
|
|
|||
|
|
@ -586,13 +586,13 @@ dns_view_weakdetach(dns_view_t **viewp) {
|
|||
}
|
||||
|
||||
isc_result_t
|
||||
dns_view_createresolver(dns_view_t *view, isc_loopmgr_t *loopmgr,
|
||||
isc_nm_t *netmgr, unsigned int options,
|
||||
isc_tlsctx_cache_t *tlsctx_cache,
|
||||
dns_view_createresolver(dns_view_t *view, isc_nm_t *netmgr,
|
||||
unsigned int options, isc_tlsctx_cache_t *tlsctx_cache,
|
||||
dns_dispatch_t *dispatchv4,
|
||||
dns_dispatch_t *dispatchv6) {
|
||||
isc_result_t result;
|
||||
isc_mem_t *mctx = NULL;
|
||||
isc_loopmgr_t *loopmgr = isc_loop_getloopmgr(isc_loop());
|
||||
|
||||
REQUIRE(DNS_VIEW_VALID(view));
|
||||
REQUIRE(!view->frozen);
|
||||
|
|
@ -608,7 +608,7 @@ dns_view_createresolver(dns_view_t *view, isc_loopmgr_t *loopmgr,
|
|||
|
||||
isc_mem_create(&mctx);
|
||||
isc_mem_setname(mctx, "ADB");
|
||||
dns_adb_create(mctx, view, loopmgr, &view->adb);
|
||||
dns_adb_create(mctx, view, &view->adb);
|
||||
isc_mem_detach(&mctx);
|
||||
|
||||
result = dns_requestmgr_create(view->mctx, loopmgr, view->dispatchmgr,
|
||||
|
|
|
|||
|
|
@ -18764,13 +18764,12 @@ zonemgr_keymgmt_delete(dns_zonemgr_t *zmgr, dns_keyfileio_t **deleted) {
|
|||
}
|
||||
|
||||
void
|
||||
dns_zonemgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t *netmgr,
|
||||
dns_zonemgr_t **zmgrp) {
|
||||
dns_zonemgr_create(isc_mem_t *mctx, isc_nm_t *netmgr, dns_zonemgr_t **zmgrp) {
|
||||
dns_zonemgr_t *zmgr = NULL;
|
||||
isc_loop_t *loop = isc_loop_current(loopmgr);
|
||||
isc_loop_t *loop = isc_loop();
|
||||
isc_loopmgr_t *loopmgr = isc_loop_getloopmgr(loop);
|
||||
|
||||
REQUIRE(mctx != NULL);
|
||||
REQUIRE(loopmgr != NULL);
|
||||
REQUIRE(netmgr != NULL);
|
||||
REQUIRE(zmgrp != NULL && *zmgrp == NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -27,6 +27,16 @@ typedef void (*isc_job_cb)(void *);
|
|||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
/*%<
|
||||
* Returns the current running loop.
|
||||
*/
|
||||
|
||||
extern thread_local isc_loop_t *isc__loop_local;
|
||||
|
||||
static inline isc_loop_t *
|
||||
isc_loop(void) {
|
||||
return (isc__loop_local);
|
||||
}
|
||||
void
|
||||
isc_loopmgr_create(isc_mem_t *mctx, uint32_t nloops, isc_loopmgr_t **loopmgrp);
|
||||
/*%<
|
||||
|
|
@ -147,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);
|
||||
/*%<
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@
|
|||
* Private
|
||||
*/
|
||||
|
||||
thread_local isc_loop_t *isc__loop_local = NULL;
|
||||
|
||||
static void
|
||||
ignore_signal(int sig, void (*handler)(int)) {
|
||||
struct sigaction sa = { .sa_handler = handler };
|
||||
|
|
@ -263,8 +265,10 @@ loop_close(isc_loop_t *loop) {
|
|||
static void *
|
||||
loop_thread(void *arg) {
|
||||
isc_loop_t *loop = (isc_loop_t *)arg;
|
||||
/* Initialize the thread_local variables*/
|
||||
|
||||
/* Initialize the thread_local variable */
|
||||
REQUIRE(isc__loop_local == NULL || isc__loop_local == loop);
|
||||
isc__loop_local = loop;
|
||||
|
||||
isc__tid_init(loop->tid);
|
||||
|
||||
|
|
@ -284,6 +288,8 @@ loop_thread(void *arg) {
|
|||
r = uv_run(&loop->loop, UV_RUN_DEFAULT);
|
||||
UV_RUNTIME_CHECK(uv_run, r);
|
||||
|
||||
isc__loop_local = NULL;
|
||||
|
||||
/* Invalidate the loop early */
|
||||
loop->magic = 0;
|
||||
|
||||
|
|
@ -567,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));
|
||||
|
|
|
|||
|
|
@ -61,8 +61,7 @@ isc_timer_create(isc_loop_t *loop, isc_job_cb cb, void *cbarg,
|
|||
loopmgr = loop->loopmgr;
|
||||
|
||||
REQUIRE(VALID_LOOPMGR(loopmgr));
|
||||
|
||||
REQUIRE(loop == isc_loop_current(loopmgr));
|
||||
REQUIRE(loop == isc_loop());
|
||||
|
||||
timer = isc_mem_get(loop->mctx, sizeof(*timer));
|
||||
*timer = (isc_timer_t){
|
||||
|
|
@ -92,7 +91,7 @@ isc_timer_stop(isc_timer_t *timer) {
|
|||
}
|
||||
|
||||
/* Stop the timer, if the loops are matching */
|
||||
if (timer->loop == isc_loop_current(timer->loop->loopmgr)) {
|
||||
if (timer->loop == isc_loop()) {
|
||||
uv_timer_stop(&timer->timer);
|
||||
}
|
||||
}
|
||||
|
|
@ -120,7 +119,7 @@ isc_timer_start(isc_timer_t *timer, isc_timertype_t type,
|
|||
|
||||
REQUIRE(VALID_TIMER(timer));
|
||||
REQUIRE(type == isc_timertype_ticker || type == isc_timertype_once);
|
||||
REQUIRE(timer->loop == isc_loop_current(timer->loop->loopmgr));
|
||||
REQUIRE(timer->loop == isc_loop());
|
||||
|
||||
loop = timer->loop;
|
||||
|
||||
|
|
@ -180,7 +179,7 @@ isc_timer_destroy(isc_timer_t **timerp) {
|
|||
timer = *timerp;
|
||||
*timerp = NULL;
|
||||
|
||||
REQUIRE(timer->loop == isc_loop_current(timer->loop->loopmgr));
|
||||
REQUIRE(timer->loop == isc_loop());
|
||||
|
||||
timer_destroy(timer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ struct thread_args {
|
|||
static void
|
||||
first_loop(void *varg) {
|
||||
struct thread_args *args = varg;
|
||||
isc_loop_t *loop = isc_loop_current(args->loopmgr);
|
||||
isc_loop_t *loop = isc_loop();
|
||||
|
||||
isc_job_run(loop, &args->job, args->cb, args);
|
||||
|
||||
|
|
@ -222,8 +222,7 @@ next_loop(struct thread_args *args, isc_nanosecs_t start) {
|
|||
args->worked += stop - start;
|
||||
args->stop = stop;
|
||||
if (args->stop - args->start < RUNTIME) {
|
||||
isc_job_run(isc_loop_current(args->loopmgr), &args->job,
|
||||
args->cb, args);
|
||||
isc_job_run(isc_loop(), &args->job, args->cb, args);
|
||||
return;
|
||||
}
|
||||
isc_async_run(isc_loop_main(args->loopmgr), collect, args);
|
||||
|
|
@ -809,7 +808,7 @@ collect(void *varg) {
|
|||
static void
|
||||
startup(void *arg) {
|
||||
isc_loopmgr_t *loopmgr = arg;
|
||||
isc_loop_t *loop = isc_loop_current(loopmgr);
|
||||
isc_loop_t *loop = isc_loop();
|
||||
isc_mem_t *mctx = isc_loop_getmctx(loop);
|
||||
uint32_t nloops = isc_loopmgr_nloops(loopmgr);
|
||||
size_t bytes = sizeof(struct bench_state) +
|
||||
|
|
@ -841,7 +840,7 @@ tick(void *varg) {
|
|||
static void
|
||||
start_ticker(void *varg) {
|
||||
struct ticker *ticker = varg;
|
||||
isc_loop_t *loop = isc_loop_current(ticker->loopmgr);
|
||||
isc_loop_t *loop = isc_loop();
|
||||
|
||||
isc_timer_create(loop, tick, NULL, &ticker->timer);
|
||||
isc_timer_start(ticker->timer, isc_timertype_ticker,
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ ISC_LOOP_TEST_IMPL(zonemgr_create) {
|
|||
|
||||
UNUSED(arg);
|
||||
|
||||
dns_zonemgr_create(mctx, loopmgr, netmgr, &myzonemgr);
|
||||
dns_zonemgr_create(mctx, netmgr, &myzonemgr);
|
||||
|
||||
dns_zonemgr_shutdown(myzonemgr);
|
||||
dns_zonemgr_detach(&myzonemgr);
|
||||
|
|
@ -72,7 +72,7 @@ ISC_LOOP_TEST_IMPL(zonemgr_managezone) {
|
|||
|
||||
UNUSED(arg);
|
||||
|
||||
dns_zonemgr_create(mctx, loopmgr, netmgr, &myzonemgr);
|
||||
dns_zonemgr_create(mctx, netmgr, &myzonemgr);
|
||||
|
||||
result = dns_test_makezone("foo", &zone, NULL, false);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
|
@ -105,7 +105,7 @@ ISC_LOOP_TEST_IMPL(zonemgr_createzone) {
|
|||
|
||||
UNUSED(arg);
|
||||
|
||||
dns_zonemgr_create(mctx, loopmgr, netmgr, &myzonemgr);
|
||||
dns_zonemgr_create(mctx, netmgr, &myzonemgr);
|
||||
|
||||
result = dns_zonemgr_createzone(myzonemgr, &zone);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
|
@ -136,7 +136,7 @@ ISC_LOOP_TEST_IMPL(zonemgr_unreachable) {
|
|||
|
||||
now = isc_time_now();
|
||||
|
||||
dns_zonemgr_create(mctx, loopmgr, netmgr, &myzonemgr);
|
||||
dns_zonemgr_create(mctx, netmgr, &myzonemgr);
|
||||
|
||||
result = dns_test_makezone("foo", &zone, NULL, false);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ append(void *arg) {
|
|||
|
||||
static void
|
||||
async_multiple(void *arg) {
|
||||
isc_loop_t *loop = isc_loop_current(loopmgr);
|
||||
isc_loop_t *loop = isc_loop();
|
||||
|
||||
UNUSED(arg);
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -62,10 +62,9 @@ job_cb(void *arg) {
|
|||
|
||||
if (n <= MAX_EXECUTED) {
|
||||
atomic_fetch_add(&scheduled, 1);
|
||||
isc_job_run(isc_loop_current(loopmgr), &ta->job, job_cb, ta);
|
||||
isc_job_run(isc_loop(), &ta->job, job_cb, ta);
|
||||
} else {
|
||||
isc_job_run(isc_loop_current(loopmgr), &ta->job, shutdown_cb,
|
||||
ta);
|
||||
isc_job_run(isc_loop(), &ta->job, shutdown_cb, ta);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -79,7 +78,7 @@ job_run_cb(void *arg) {
|
|||
*ta = (struct test_arg){ .job = ISC_JOB_INITIALIZER };
|
||||
}
|
||||
|
||||
isc_job_run(isc_loop_current(loopmgr), &ta->job, job_cb, ta);
|
||||
isc_job_run(isc_loop(), &ta->job, job_cb, ta);
|
||||
}
|
||||
|
||||
ISC_RUN_TEST_IMPL(isc_job_run) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
@ -424,14 +424,14 @@ timer_event(void *arg ISC_ATTR_UNUSED) {
|
|||
if (--timer_ticks == 0) {
|
||||
isc_timer_destroy(&timer);
|
||||
isc_loopmgr_shutdown(loopmgr);
|
||||
timer_stop = isc_loop_now(isc_loop_current(loopmgr));
|
||||
timer_stop = isc_loop_now(isc_loop());
|
||||
} else {
|
||||
isc_timer_start(timer, timer_type, &timer_interval);
|
||||
}
|
||||
}
|
||||
|
||||
ISC_LOOP_SETUP_IMPL(reschedule_up) {
|
||||
timer_start = isc_loop_now(isc_loop_current(loopmgr));
|
||||
timer_start = isc_loop_now(isc_loop());
|
||||
timer_expect = 1;
|
||||
timer_ticks = 1;
|
||||
timer_type = isc_timertype_once;
|
||||
|
|
@ -451,7 +451,7 @@ ISC_LOOP_TEST_CUSTOM_IMPL(reschedule_up, setup_loop_reschedule_up,
|
|||
}
|
||||
|
||||
ISC_LOOP_SETUP_IMPL(reschedule_down) {
|
||||
timer_start = isc_loop_now(isc_loop_current(loopmgr));
|
||||
timer_start = isc_loop_now(isc_loop());
|
||||
timer_expect = 0;
|
||||
timer_ticks = 1;
|
||||
timer_type = isc_timertype_once;
|
||||
|
|
@ -471,7 +471,7 @@ ISC_LOOP_TEST_CUSTOM_IMPL(reschedule_down, setup_loop_reschedule_down,
|
|||
}
|
||||
|
||||
ISC_LOOP_SETUP_IMPL(reschedule_from_callback) {
|
||||
timer_start = isc_loop_now(isc_loop_current(loopmgr));
|
||||
timer_start = isc_loop_now(isc_loop());
|
||||
timer_expect = 1;
|
||||
timer_ticks = 2;
|
||||
timer_type = isc_timertype_once;
|
||||
|
|
@ -487,7 +487,7 @@ ISC_LOOP_TEST_CUSTOM_IMPL(reschedule_from_callback,
|
|||
}
|
||||
|
||||
ISC_LOOP_SETUP_IMPL(zero) {
|
||||
timer_start = isc_loop_now(isc_loop_current(loopmgr));
|
||||
timer_start = isc_loop_now(isc_loop());
|
||||
timer_expect = 0;
|
||||
timer_ticks = 1;
|
||||
timer_type = isc_timertype_once;
|
||||
|
|
@ -502,7 +502,7 @@ ISC_LOOP_TEST_CUSTOM_IMPL(zero, setup_loop_zero, teardown_loop_timer_expect) {
|
|||
}
|
||||
|
||||
ISC_LOOP_SETUP_IMPL(reschedule_ticker) {
|
||||
timer_start = isc_loop_now(isc_loop_current(loopmgr));
|
||||
timer_start = isc_loop_now(isc_loop());
|
||||
timer_expect = 1;
|
||||
timer_ticks = 5;
|
||||
timer_type = isc_timertype_ticker;
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ void
|
|||
dns_test_setupzonemgr(void) {
|
||||
REQUIRE(zonemgr == NULL);
|
||||
|
||||
dns_zonemgr_create(mctx, loopmgr, netmgr, &zonemgr);
|
||||
dns_zonemgr_create(mctx, netmgr, &zonemgr);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
|
|
|
|||
Loading…
Reference in a new issue