2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 13:38:26 +00:00

chg: dev: Change the loopmgr to be singleton

All the applications built on top of the loop manager were required to
create a single instance of the loop manager.  Refactor the loop
manager not to expose this instance to the callers, and keep the loop
manager object internal to the `isc_loop` compilation unit.

This significantly simplifies a number of data structures and calls to
the `isc_loop` API.

Merge branch 'ondrej/refactor-isc_loopmgr-to-be-singleton' into 'main'

See merge request isc-projects/bind9!10733
This commit is contained in:
Ondřej Surý 2025-07-23 22:44:50 +02:00
commit a1b8fe45b0
102 changed files with 883 additions and 1047 deletions

View File

@ -110,7 +110,6 @@ static FILE *logfp = NULL;
/* Managers */
static isc_nm_t *netmgr = NULL;
static isc_loopmgr_t *loopmgr = NULL;
static dns_dispatchmgr_t *dispatchmgr = NULL;
static dns_requestmgr_t *requestmgr = NULL;
static ns_interfacemgr_t *interfacemgr = NULL;
@ -1845,7 +1844,7 @@ resolve_cb(dns_client_t *client, const dns_name_t *query_name,
dns_client_detach(&client);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
static void
@ -1880,8 +1879,8 @@ run_resolve(void *arg) {
}
/* Create client */
CHECK(dns_client_create(mctx, loopmgr, netmgr, 0, tlsctx_client_cache,
&client, srcaddr4, srcaddr6));
CHECK(dns_client_create(mctx, netmgr, 0, tlsctx_client_cache, &client,
srcaddr4, srcaddr6));
dns_client_setmaxrestarts(client, restarts);
dns_client_setmaxqueries(client, maxtotal);
@ -1905,7 +1904,7 @@ cleanup:
}
isc_mem_put(mctx, namelist, sizeof(*namelist));
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
dns_client_detach(&client);
}
@ -1933,7 +1932,7 @@ shutdown_server(void) {
ns_server_detach(&sctx);
}
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
static void
@ -2078,7 +2077,7 @@ sendquery(void *arg) {
NULL, 0));
CHECK(dns_message_setopt(message, opt));
CHECK(dns_requestmgr_create(mctx, loopmgr, dispatchmgr, NULL, NULL,
CHECK(dns_requestmgr_create(mctx, dispatchmgr, NULL, NULL,
&requestmgr));
dns_view_attach(view, &(dns_view_t *){ NULL });
@ -2134,7 +2133,7 @@ run_server(void *arg) {
ns_server_create(mctx, matchview, &sctx);
CHECK(dns_dispatchmgr_create(mctx, loopmgr, netmgr, &dispatchmgr));
CHECK(dns_dispatchmgr_create(mctx, netmgr, &dispatchmgr));
if (use_ipv4) {
isc_sockaddr_any(&any);
@ -2148,12 +2147,12 @@ run_server(void *arg) {
CHECK(dns_dispatch_createudp(dispatchmgr, a, &dispatch6));
}
CHECK(ns_interfacemgr_create(mctx, sctx, loopmgr, netmgr, dispatchmgr,
NULL, &interfacemgr));
CHECK(ns_interfacemgr_create(mctx, sctx, netmgr, dispatchmgr, NULL,
&interfacemgr));
dns_view_create(mctx, loopmgr, dispatchmgr, dns_rdataclass_in,
"_default", &view);
CHECK(dns_cache_create(loopmgr, dns_rdataclass_in, "", mctx, &cache));
dns_view_create(mctx, dispatchmgr, dns_rdataclass_in, "_default",
&view);
CHECK(dns_cache_create(dns_rdataclass_in, "", mctx, &cache));
dns_view_setcache(view, cache, false);
dns_cache_detach(&cache);
dns_view_setdstport(view, destport);
@ -2216,8 +2215,8 @@ main(int argc, char *argv[]) {
argc--;
argv++;
isc_managers_create(&mctx, 1, &loopmgr, &netmgr);
loop = isc_loop_main(loopmgr);
isc_managers_create(&mctx, 1, &netmgr);
loop = isc_loop_main();
parse_args(argc, argv);
@ -2241,7 +2240,7 @@ main(int argc, char *argv[]) {
isc_tlsctx_cache_create(mctx, &tlsctx_client_cache);
isc_loop_setup(loop, fulltrace ? run_server : run_resolve, NULL);
isc_loopmgr_run(loopmgr);
isc_loopmgr_run();
cleanup:
if (tlsctx_client_cache != NULL) {
@ -2260,7 +2259,7 @@ cleanup:
dns_master_styledestroy(&style, mctx);
}
isc_managers_destroy(&mctx, &loopmgr, &netmgr);
isc_managers_destroy(&mctx, &netmgr);
return 0;
}

View File

@ -3356,7 +3356,7 @@ query_finished(void) {
}
batchname = NULL;
}
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
static void
@ -3457,8 +3457,8 @@ void
dig_startup(void) {
debug("dig_startup()");
isc_loopmgr_setup(loopmgr, run_loop, NULL);
isc_loopmgr_run(loopmgr);
isc_loopmgr_setup(run_loop, NULL);
isc_loopmgr_run();
}
void

View File

@ -101,7 +101,6 @@ unsigned int timeout = 0;
unsigned int extrabytes;
isc_mem_t *mctx = NULL;
isc_nm_t *netmgr = NULL;
isc_loopmgr_t *loopmgr = NULL;
isc_loop_t *mainloop = NULL;
isc_sockaddr_t localaddr;
isc_refcount_t sendcount = 0;
@ -521,9 +520,9 @@ set_nameserver(char *opt) {
return;
}
isc_loopmgr_blocking(loopmgr);
isc_loopmgr_blocking();
result = isc_getaddresses(opt, 0, sockaddrs, DIG_MAX_ADDRESSES, &count);
isc_loopmgr_nonblocking(loopmgr);
isc_loopmgr_nonblocking();
if (result != ISC_R_SUCCESS) {
fatal("couldn't get address for '%s': %s", opt,
isc_result_totext(result));
@ -1346,7 +1345,7 @@ setup_libs(int argc, char **argv) {
fatal("can't find either v4 or v6 networking");
}
isc_managers_create(&mctx, 1, &loopmgr, &netmgr);
isc_managers_create(&mctx, 1, &netmgr);
logconfig = isc_logconfig_get();
isc_log_createandusechannel(logconfig, "debug", ISC_LOG_TOFILEDESC,
@ -1355,7 +1354,7 @@ setup_libs(int argc, char **argv) {
ISC_LOGMODULE_DEFAULT);
isc_log_setdebuglevel(0);
mainloop = isc_loop_main(loopmgr);
mainloop = isc_loop_main();
}
typedef struct dig_ednsoptname {
@ -4541,9 +4540,9 @@ get_address(char *host, in_port_t myport, isc_sockaddr_t *sockaddr) {
int count;
isc_result_t result;
isc_loopmgr_blocking(loopmgr);
isc_loopmgr_blocking();
result = isc_getaddresses(host, myport, sockaddr, 1, &count);
isc_loopmgr_nonblocking(loopmgr);
isc_loopmgr_nonblocking();
if (result != ISC_R_SUCCESS) {
return result;
}
@ -4562,10 +4561,10 @@ getaddresses(dig_lookup_t *lookup, const char *host, isc_result_t *resultp) {
dig_server_t *srv;
char tmp[ISC_NETADDR_FORMATSIZE];
isc_loopmgr_blocking(loopmgr);
isc_loopmgr_blocking();
result = isc_getaddresses(host, 0, sockaddrs, DIG_MAX_ADDRESSES,
&count);
isc_loopmgr_nonblocking(loopmgr);
isc_loopmgr_nonblocking();
SET_IF_NOT_NULL(resultp, result);
if (result != ISC_R_SUCCESS) {
if (resultp == NULL) {
@ -4710,7 +4709,7 @@ destroy_libs(void) {
isc_mem_stats(mctx, stderr);
}
isc_managers_destroy(&mctx, &loopmgr, &netmgr);
isc_managers_destroy(&mctx, &netmgr);
#if ENABLE_LEAK_DETECTION
isc__crypto_setdestroycheck(true);

View File

@ -30,6 +30,7 @@
#include <isc/sockaddr.h>
#include <isc/time.h>
#include <dns/fixedname.h>
#include <dns/rdatalist.h>
#include <dst/dst.h>
@ -265,7 +266,6 @@ extern dst_algorithm_t hmac_alg;
extern unsigned int digestbits;
extern dns_tsigkey_t *tsigkey;
extern bool validated;
extern isc_loopmgr_t *loopmgr;
extern isc_loop_t *mainloop;
extern bool free_now;
extern bool debugging, debugtiming, memdebugging;

View File

@ -140,7 +140,7 @@ show_usage(void) {
static void
host_shutdown(void) {
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
static void
@ -898,8 +898,8 @@ main(int argc, char **argv) {
setup_text_key();
}
isc_loopmgr_setup(loopmgr, run_loop, NULL);
isc_loopmgr_run(loopmgr);
isc_loopmgr_setup(run_loop, NULL);
isc_loopmgr_run();
cancel_all();
destroy_libs();

View File

@ -764,9 +764,9 @@ readline_next_command(void *arg) {
UNUSED(arg);
isc_loopmgr_blocking(loopmgr);
isc_loopmgr_blocking();
ptr = readline("> ");
isc_loopmgr_nonblocking(loopmgr);
isc_loopmgr_nonblocking();
if (ptr == NULL) {
return;
}
@ -840,7 +840,7 @@ start_next_command(void);
static void
process_next_command(void *arg ISC_ATTR_UNUSED) {
isc_loop_t *loop = isc_loop_main(loopmgr);
isc_loop_t *loop = isc_loop_main();
if (cmdline == NULL) {
in_use = false;
} else {
@ -856,15 +856,15 @@ process_next_command(void *arg ISC_ATTR_UNUSED) {
static void
start_next_command(void) {
isc_loop_t *loop = isc_loop_main(loopmgr);
isc_loop_t *loop = isc_loop_main();
if (!in_use) {
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
return;
}
cmdline = NULL;
isc_loopmgr_pause(loopmgr);
isc_loopmgr_pause();
if (interactive) {
isc_work_enqueue(loop, readline_next_command,
process_next_command, loop);
@ -872,7 +872,7 @@ start_next_command(void) {
isc_work_enqueue(loop, fgets_next_command, process_next_command,
loop);
}
isc_loopmgr_resume(loopmgr);
isc_loopmgr_resume();
}
static void
@ -911,13 +911,13 @@ main(int argc, char **argv) {
set_search_domain(domainopt);
}
if (in_use) {
isc_loopmgr_setup(loopmgr, run_loop, NULL);
isc_loopmgr_setup(run_loop, NULL);
} else {
isc_loopmgr_setup(loopmgr, read_loop, NULL);
isc_loopmgr_setup(read_loop, NULL);
}
in_use = !in_use;
isc_loopmgr_run(loopmgr);
isc_loopmgr_run();
puts("");
debug("done, and starting to shut down");

View File

@ -140,7 +140,6 @@ static atomic_uint_fast32_t nverified = 0, nverifyfailed = 0;
static const char *directory = NULL, *dsdir = NULL;
static isc_mutex_t namelock;
static isc_nm_t *netmgr = NULL;
static isc_loopmgr_t *loopmgr = NULL;
static dns_db_t *gdb; /* The database */
static dns_dbversion_t *gversion; /* The database version */
static dns_dbiterator_t *gdbiter; /* The database iterator */
@ -1543,7 +1542,7 @@ assignwork(void *arg) {
if (atomic_load(&finished)) {
ended++;
if (ended == nloops) {
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
UNLOCK(&namelock);
return;
@ -1619,7 +1618,7 @@ assignwork(void *arg) {
if (!found) {
ended++;
if (ended == nloops) {
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
UNLOCK(&namelock);
return;
@ -3637,7 +3636,7 @@ main(int argc, char *argv[]) {
directory = ".";
}
isc_managers_create(&mctx, nloops, &loopmgr, &netmgr);
isc_managers_create(&mctx, nloops, &netmgr);
setup_logging();
@ -3927,9 +3926,9 @@ main(int argc, char *argv[]) {
* There is more work to do. Spread it out over multiple
* processors if possible.
*/
isc_loopmgr_setup(loopmgr, assignwork, NULL);
isc_loopmgr_teardown(loopmgr, abortwork, NULL);
isc_loopmgr_run(loopmgr);
isc_loopmgr_setup(assignwork, NULL);
isc_loopmgr_teardown(abortwork, NULL);
isc_loopmgr_run();
if (!atomic_load(&finished)) {
fatal("process aborted by user");
@ -4007,7 +4006,7 @@ main(int argc, char *argv[]) {
isc_mem_stats(mctx, stdout);
}
isc_managers_destroy(&mctx, &loopmgr, &netmgr);
isc_managers_destroy(&mctx, &netmgr);
if (printstats) {
timer_finish = isc_time_now();

View File

@ -178,7 +178,7 @@ named_control_docommand(isccc_sexpr_t *message, bool readonly,
/* Do not flush master files */
named_server_flushonshutdown(named_g_server, false);
named_os_shutdownmsg(cmdline, *text);
isc_loopmgr_shutdown(named_g_loopmgr);
isc_loopmgr_shutdown();
result = ISC_R_SHUTTINGDOWN;
} else if (command_compare(command, NAMED_COMMAND_STOP)) {
/*
@ -196,7 +196,7 @@ named_control_docommand(isccc_sexpr_t *message, bool readonly,
#endif /* ifdef HAVE_LIBSCF */
named_server_flushonshutdown(named_g_server, true);
named_os_shutdownmsg(cmdline, *text);
isc_loopmgr_shutdown(named_g_loopmgr);
isc_loopmgr_shutdown();
result = ISC_R_SHUTTINGDOWN;
} else if (command_compare(command, NAMED_COMMAND_ADDZONE) ||
command_compare(command, NAMED_COMMAND_MODZONE))

View File

@ -538,7 +538,7 @@ control_recvmessage(isc_nmhandle_t *handle ISC_ATTR_UNUSED, isc_result_t result,
controlconnection_ref(conn);
/* Trigger the command asynchronously. */
isc_async_run(named_g_mainloop, control_command, conn);
isc_async_run(isc_loop_main(), control_command, conn);
return;

View File

@ -124,7 +124,7 @@ fuzz_thread_client(void *arg) {
close(sockfd);
named_server_flushonshutdown(named_g_server,
false);
isc_loopmgr_shutdown(named_g_loopmgr);
isc_loopmgr_shutdown();
return NULL;
}
raise(SIGSTOP);
@ -157,7 +157,7 @@ fuzz_thread_client(void *arg) {
close(sockfd);
named_server_flushonshutdown(named_g_server, false);
isc_loopmgr_shutdown(named_g_loopmgr);
isc_loopmgr_shutdown();
return NULL;
}
@ -372,7 +372,7 @@ fuzz_thread_resolver(void *arg) {
close(listenfd);
named_server_flushonshutdown(named_g_server,
false);
isc_loopmgr_shutdown(named_g_loopmgr);
isc_loopmgr_shutdown();
return NULL;
}
raise(SIGSTOP);
@ -572,7 +572,7 @@ fuzz_thread_resolver(void *arg) {
close(sockfd);
close(listenfd);
named_server_flushonshutdown(named_g_server, false);
isc_loopmgr_shutdown(named_g_loopmgr);
isc_loopmgr_shutdown();
#ifdef __AFL_LOOP
/*
@ -714,7 +714,7 @@ fuzz_thread_tcp(void *arg) {
free(buf);
close(sockfd);
named_server_flushonshutdown(named_g_server, false);
isc_loopmgr_shutdown(named_g_loopmgr);
isc_loopmgr_shutdown();
return NULL;
}
@ -731,7 +731,7 @@ named_fuzz_notify(void) {
#ifdef ENABLE_AFL
if (getenv("AFL_CMIN")) {
named_server_flushonshutdown(named_g_server, false);
isc_loopmgr_shutdown(named_g_loopmgr);
isc_loopmgr_shutdown();
return;
}

View File

@ -50,8 +50,6 @@
EXTERN isc_mem_t *named_g_mctx INIT(NULL);
EXTERN unsigned int named_g_cpus INIT(0);
EXTERN isc_loop_t *named_g_mainloop INIT(NULL);
EXTERN isc_loopmgr_t *named_g_loopmgr INIT(NULL);
EXTERN bool named_g_loopmgr_running INIT(false);
EXTERN dns_dispatchmgr_t *named_g_dispatchmgr INIT(NULL);
EXTERN unsigned int named_g_cpus_detected INIT(1);

View File

@ -970,8 +970,7 @@ create_managers(void) {
"thread count limit)"
: "");
isc_managers_create(&named_g_mctx, named_g_cpus, &named_g_loopmgr,
&named_g_netmgr);
isc_managers_create(&named_g_mctx, named_g_cpus, &named_g_netmgr);
isc_nm_maxudp(named_g_netmgr, maxudp);
@ -1472,7 +1471,7 @@ main(int argc, char *argv[]) {
* Pause the loop manager in fatal.
*/
named_g_loopmgr_running = true;
isc_loopmgr_run(named_g_loopmgr);
isc_loopmgr_run();
#ifdef HAVE_LIBSCF
if (named_smf_want_disable == 1) {
@ -1506,7 +1505,7 @@ main(int argc, char *argv[]) {
}
}
isc_managers_destroy(&named_g_mctx, &named_g_loopmgr, &named_g_netmgr);
isc_managers_destroy(&named_g_mctx, &named_g_netmgr);
#if ENABLE_LEAK_DETECTION
isc__crypto_setdestroycheck(true);

View File

@ -1132,7 +1132,7 @@ configure_view_dnsseckeys(dns_view_t *view, const cfg_obj_t *vconfig,
maps[i] = NULL;
dns_view_initsecroots(view);
dns_view_initntatable(view, named_g_loopmgr);
dns_view_initntatable(view);
if (auto_root && view->rdclass == dns_rdataclass_in) {
const cfg_obj_t *builtin_keys = NULL;
@ -2172,7 +2172,7 @@ configure_rpz(dns_view_t *view, dns_view_t *pview, const cfg_obj_t *rpz_obj,
}
nsdname_on = nsdname_enabled ? DNS_RPZ_ALL_ZBITS : 0;
result = dns_rpz_new_zones(view, named_g_loopmgr, &view->rpzs);
result = dns_rpz_new_zones(view, &view->rpzs);
if (result != ISC_R_SUCCESS) {
return result;
}
@ -2330,7 +2330,7 @@ catz_addmodzone_cb(void *arg) {
ns_cfgctx_t *cfg = NULL;
dns_zone_t *zone = NULL;
if (isc_loop_shuttingdown(isc_loop_get(named_g_loopmgr, isc_tid()))) {
if (isc_loop_shuttingdown(isc_loop_get(isc_tid()))) {
goto cleanup;
}
@ -2469,7 +2469,7 @@ catz_addmodzone_cb(void *arg) {
zoneobj = cfg_listelt_value(cfg_list_first(zlist));
/* Mark view unfrozen so that zone can be added */
isc_loopmgr_pause(named_g_loopmgr);
isc_loopmgr_pause();
dns_view_thaw(cz->view);
result = configure_zone(cfg->config, zoneobj, cfg->vconfig, cz->view,
&cz->cbd->server->viewlist,
@ -2477,7 +2477,7 @@ catz_addmodzone_cb(void *arg) {
&cz->cbd->server->keystorelist, cfg->actx, true,
false, true, cz->mod);
dns_view_freeze(cz->view);
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
if (result != ISC_R_SUCCESS) {
isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
@ -2543,11 +2543,11 @@ catz_delzone_cb(void *arg) {
char cname[DNS_NAME_FORMATSIZE];
const char *file = NULL;
if (isc_loop_shuttingdown(isc_loop_get(named_g_loopmgr, isc_tid()))) {
if (isc_loop_shuttingdown(isc_loop_get(isc_tid()))) {
goto cleanup;
}
isc_loopmgr_pause(named_g_loopmgr);
isc_loopmgr_pause();
dns_name_format(dns_catz_entry_getname(cz->entry), cname,
DNS_NAME_FORMATSIZE);
@ -2604,7 +2604,7 @@ catz_delzone_cb(void *arg) {
"zone '%s' deleted",
cname);
resume:
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
cleanup:
if (zone != NULL) {
dns_zone_detach(&zone);
@ -2645,7 +2645,7 @@ catz_run(dns_catz_entry_t *entry, dns_catz_zone_t *origin, dns_view_t *view,
dns_catz_zone_attach(origin, &cz->origin);
dns_view_weakattach(view, &cz->view);
isc_async_run(named_g_mainloop, action, cz);
isc_async_run(isc_loop_main(), action, cz);
return ISC_R_SUCCESS;
}
@ -2894,7 +2894,7 @@ configure_catz(dns_view_t *view, dns_view_t *pview, const cfg_obj_t *config,
dns_catz_zones_detach(&pview->catzs);
dns_catz_prereconfig(view->catzs);
} else {
view->catzs = dns_catz_zones_new(view->mctx, named_g_loopmgr,
view->catzs = dns_catz_zones_new(view->mctx,
&ns_catz_zonemodmethods);
}
@ -3598,7 +3598,7 @@ configure_dnstap(const cfg_obj_t **maps, dns_view_t *view) {
}
CHECKM(dns_dt_create(named_g_mctx, dmode, dpath, &fopt,
named_g_mainloop, &named_g_server->dtenv),
isc_loop_main(), &named_g_server->dtenv),
"unable to create dnstap environment");
CHECKM(dns_dt_setupfile(named_g_server->dtenv, max_size, rolls,
@ -4423,8 +4423,8 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
* is simply a named cache that is not shared.
*/
if (cache == NULL) {
CHECK(dns_cache_create(named_g_loopmgr, view->rdclass,
cachename, mctx, &cache));
CHECK(dns_cache_create(view->rdclass, cachename, mctx,
&cache));
}
nsc = isc_mem_get(mctx, sizeof(*nsc));
@ -5360,8 +5360,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
if (dctx == NULL) {
const void *hashinit = isc_hash_get_initializer();
dns_dyndb_createctx(mctx, hashinit, view,
named_g_server->zonemgr,
named_g_loopmgr, &dctx);
named_g_server->zonemgr, &dctx);
}
CHECK(configure_dyndb(dyndb, mctx, dctx));
@ -6192,8 +6191,8 @@ create_view(const cfg_obj_t *vconfig, dns_viewlist_t *viewlist,
}
INSIST(view == NULL);
dns_view_create(named_g_mctx, named_g_loopmgr, named_g_dispatchmgr,
viewclass, viewname, &view);
dns_view_create(named_g_mctx, named_g_dispatchmgr, viewclass, viewname,
&view);
isc_nonce_buf(view->secret, sizeof(view->secret));
@ -6990,7 +6989,7 @@ dotat(dns_keytable_t *keytable, dns_keynode_t *keynode, dns_name_t *keyname,
* view->lock (dns_view_findzonecut) while holding keytable->lock
* (dns_keytable_forall)
*/
isc_async_run(named_g_mainloop, tat_send, tat);
isc_async_run(isc_loop_main(), tat_send, tat);
}
static void
@ -7011,7 +7010,7 @@ tat_timer_tick(void *arg) {
}
dotat_arg.view = view;
dotat_arg.loop = named_g_mainloop;
dotat_arg.loop = isc_loop_main();
dns_keytable_forall(secroots, dotat, &dotat_arg);
dns_keytable_detach(&secroots);
}
@ -7844,7 +7843,7 @@ apply_configuration(cfg_parser_t *configparser, cfg_obj_t *config,
/*
* Require the reconfiguration to happen always on the main loop
*/
REQUIRE(isc_loop() == named_g_mainloop);
REQUIRE(isc_loop() == isc_loop_main());
ISC_LIST_INIT(kasplist);
ISC_LIST_INIT(keystorelist);
@ -7854,7 +7853,7 @@ apply_configuration(cfg_parser_t *configparser, cfg_obj_t *config,
ISC_LIST_INIT(altsecrets);
/* Ensure exclusive access to configuration data. */
isc_loopmgr_pause(named_g_loopmgr);
isc_loopmgr_pause();
/* Create the ACL configuration context */
if (named_g_aclconfctx != NULL) {
@ -8390,9 +8389,9 @@ apply_configuration(cfg_parser_t *configparser, cfg_obj_t *config,
* listen-on option. This requires the loopmgr to be
* temporarily resumed.
*/
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
result = ns_interfacemgr_scan(server->interfacemgr, true, true);
isc_loopmgr_pause(named_g_loopmgr);
isc_loopmgr_pause();
/*
* Check that named is able to TCP listen on at least one
@ -9093,7 +9092,7 @@ apply_configuration(cfg_parser_t *configparser, cfg_obj_t *config,
*/
named_g_defaultconfigtime = isc_time_now();
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
exclusive = false;
/* Take back root privileges temporarily */
@ -9195,7 +9194,7 @@ cleanup_bindkeys_parser:
cleanup_exclusive:
if (exclusive) {
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
}
isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
@ -9323,7 +9322,7 @@ load_zones(named_server_t *server, bool reconfig) {
zl->server = server;
zl->reconfig = reconfig;
isc_loopmgr_pause(named_g_loopmgr);
isc_loopmgr_pause();
isc_refcount_init(&zl->refs, 1);
@ -9368,7 +9367,7 @@ cleanup:
isc_mem_put(server->mctx, zl, sizeof(*zl));
}
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
return result;
}
@ -9381,8 +9380,8 @@ run_server(void *arg) {
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),
CHECKFATAL(dns_dispatchmgr_create(named_g_mctx, named_g_netmgr,
&named_g_dispatchmgr),
"creating dispatch manager");
dns_dispatchmgr_setstats(named_g_dispatchmgr, server->resolverstats);
@ -9394,18 +9393,17 @@ run_server(void *arg) {
#endif /* if defined(HAVE_GEOIP2) */
CHECKFATAL(ns_interfacemgr_create(named_g_mctx, server->sctx,
named_g_loopmgr, named_g_netmgr,
named_g_dispatchmgr, geoip,
&server->interfacemgr),
named_g_netmgr, named_g_dispatchmgr,
geoip, &server->interfacemgr),
"creating interface manager");
isc_timer_create(named_g_mainloop, interface_timer_tick, server,
isc_timer_create(isc_loop_main(), interface_timer_tick, server,
&server->interface_timer);
isc_timer_create(named_g_mainloop, tat_timer_tick, server,
isc_timer_create(isc_loop_main(), tat_timer_tick, server,
&server->tat_timer);
isc_timer_create(named_g_mainloop, pps_timer_tick, server,
isc_timer_create(isc_loop_main(), pps_timer_tick, server,
&server->pps_timer);
CHECKFATAL(cfg_parser_create(named_g_mctx, &named_g_parser),
@ -9461,7 +9459,7 @@ shutdown_server(void *arg) {
named_statschannels_shutdown(server);
isc_loopmgr_pause(named_g_loopmgr);
isc_loopmgr_pause();
isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
ISC_LOG_INFO, "shutting down%s",
@ -9523,7 +9521,7 @@ shutdown_server(void *arg) {
dns_db_detach(&server->in_roothints);
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
}
static isc_result_t
@ -9791,18 +9789,16 @@ named_server_create(isc_mem_t *mctx, named_server_t **serverp) {
server->sctx->fuzznotify = named_fuzz_notify;
#endif /* ifdef ENABLE_AFL */
named_g_mainloop = isc_loop_main(named_g_loopmgr);
isc_loop_setup(named_g_mainloop, run_server, server);
isc_loop_teardown(named_g_mainloop, shutdown_server, server);
isc_loop_setup(isc_loop_main(), run_server, server);
isc_loop_teardown(isc_loop_main(), shutdown_server, server);
/* Add SIGHUP reload handler */
server->sighup = isc_signal_new(
named_g_loopmgr, named_server_reloadwanted, server, SIGHUP);
server->sighup = isc_signal_new(named_server_reloadwanted, server,
SIGHUP);
/* Add SIGUSR2 closelogs handler */
server->sigusr1 = isc_signal_new(
named_g_loopmgr, named_server_closelogswanted, server, SIGUSR1);
server->sigusr1 = isc_signal_new(named_server_closelogswanted, server,
SIGUSR1);
isc_stats_create(server->mctx, &server->sockstats,
isc_sockstatscounter_max);
@ -9888,7 +9884,7 @@ named_server_destroy(named_server_t **serverp) {
static void
fatal(const char *msg, isc_result_t result) {
if (named_g_loopmgr_running) {
isc_loopmgr_pause(named_g_loopmgr);
isc_loopmgr_pause();
}
isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
ISC_LOG_CRITICAL, "%s: %s", msg,
@ -9975,7 +9971,7 @@ named_server_reloadwanted(void *arg, int signum) {
REQUIRE(signum == SIGHUP);
isc_async_run(named_g_mainloop, named_server_reload, server);
isc_async_run(isc_loop_main(), named_server_reload, server);
}
/*
@ -9997,7 +9993,7 @@ named_server_closelogswanted(void *arg, int signum) {
REQUIRE(signum == SIGUSR1);
isc_async_run(named_g_mainloop, named_server_closelogs, server);
isc_async_run(isc_loop_main(), named_server_closelogs, server);
}
#ifdef JEMALLOC_API_SUPPORTED
@ -11124,7 +11120,7 @@ resume:
dns_cache_getname(dctx->view->view->cache));
result = dns_master_dumptostreamasync(
dctx->mctx, dctx->cache, NULL, style, dctx->fp,
named_g_mainloop, dumpdone, dctx, &dctx->mdctx);
isc_loop_main(), dumpdone, dctx, &dctx->mdctx);
if (result == ISC_R_SUCCESS) {
return;
}
@ -11551,7 +11547,7 @@ named_server_validation(named_server_t *server, isc_lex_t *lex,
/* Look for the view name. */
ptr = next_token(lex, text);
isc_loopmgr_pause(named_g_loopmgr);
isc_loopmgr_pause();
ISC_LIST_FOREACH (server->viewlist, view, link) {
if ((ptr != NULL && strcasecmp(ptr, view->name) != 0) ||
strcasecmp("_bind", view->name) == 0)
@ -11587,7 +11583,7 @@ named_server_validation(named_server_t *server, isc_lex_t *lex,
result = ISC_R_FAILURE;
}
cleanup:
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
return result;
}
@ -11607,7 +11603,7 @@ named_server_flushcache(named_server_t *server, isc_lex_t *lex) {
/* Look for the view name. */
ptr = next_token(lex, NULL);
isc_loopmgr_pause(named_g_loopmgr);
isc_loopmgr_pause();
flushed = true;
found = false;
@ -11718,7 +11714,7 @@ named_server_flushcache(named_server_t *server, isc_lex_t *lex) {
result = ISC_R_FAILURE;
}
}
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
return result;
}
@ -11757,7 +11753,7 @@ named_server_flushnode(named_server_t *server, isc_lex_t *lex, bool tree) {
/* Look for the view name. */
viewname = next_token(lex, NULL);
isc_loopmgr_pause(named_g_loopmgr);
isc_loopmgr_pause();
flushed = true;
found = false;
ISC_LIST_FOREACH (server->viewlist, view, link) {
@ -11806,7 +11802,7 @@ named_server_flushnode(named_server_t *server, isc_lex_t *lex, bool tree) {
}
result = ISC_R_FAILURE;
}
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
return result;
}
@ -12102,7 +12098,7 @@ named_server_sync(named_server_t *server, isc_lex_t *lex, isc_buffer_t **text) {
}
if (zone == NULL) {
isc_loopmgr_pause(named_g_loopmgr);
isc_loopmgr_pause();
tresult = ISC_R_SUCCESS;
ISC_LIST_FOREACH (server->viewlist, view, link) {
result = dns_view_apply(view, false, NULL, synczone,
@ -12112,7 +12108,7 @@ named_server_sync(named_server_t *server, isc_lex_t *lex, isc_buffer_t **text) {
tresult = result;
}
}
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
ISC_LOG_INFO, "dumping all zones%s: %s",
cleanup ? ", removing journal files" : "",
@ -12120,9 +12116,9 @@ named_server_sync(named_server_t *server, isc_lex_t *lex, isc_buffer_t **text) {
return tresult;
}
isc_loopmgr_pause(named_g_loopmgr);
isc_loopmgr_pause();
result = synczone(zone, &cleanup);
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
dns_view_t *view = dns_zone_getview(zone);
if (strcmp(view->name, "_default") == 0 ||
@ -12168,7 +12164,7 @@ named_server_freeze(named_server_t *server, bool freeze, isc_lex_t *lex,
return result;
}
if (mayberaw == NULL) {
isc_loopmgr_pause(named_g_loopmgr);
isc_loopmgr_pause();
tresult = ISC_R_SUCCESS;
ISC_LIST_FOREACH (server->viewlist, view, link) {
result = dns_view_freezezones(view, freeze);
@ -12177,7 +12173,7 @@ named_server_freeze(named_server_t *server, bool freeze, isc_lex_t *lex,
tresult = result;
}
}
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
ISC_LOG_INFO, "%s all zones: %s",
freeze ? "freezing" : "thawing",
@ -12201,7 +12197,7 @@ named_server_freeze(named_server_t *server, bool freeze, isc_lex_t *lex,
return DNS_R_NOTDYNAMIC;
}
isc_loopmgr_pause(named_g_loopmgr);
isc_loopmgr_pause();
frozen = dns_zone_getupdatedisabled(mayberaw);
if (freeze) {
if (frozen) {
@ -12240,7 +12236,7 @@ named_server_freeze(named_server_t *server, bool freeze, isc_lex_t *lex,
}
}
}
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
if (msg != NULL) {
(void)putstr(text, msg);
@ -13122,7 +13118,7 @@ do_addzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
goto cleanup;
}
isc_loopmgr_pause(named_g_loopmgr);
isc_loopmgr_pause();
#ifndef HAVE_LMDB
/*
@ -13130,7 +13126,7 @@ do_addzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
*/
result = isc_stdio_open(view->new_zone_file, "a", &fp);
if (result != ISC_R_SUCCESS) {
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
TCHECK(putstr(text, "unable to create '"));
TCHECK(putstr(text, view->new_zone_file));
TCHECK(putstr(text, "': "));
@ -13146,7 +13142,7 @@ do_addzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
/* Make sure we can open the NZD database */
result = nzd_writable(view);
if (result != ISC_R_SUCCESS) {
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
TCHECK(putstr(text, "unable to open NZD database for '"));
TCHECK(putstr(text, view->new_zone_db));
TCHECK(putstr(text, "'"));
@ -13163,7 +13159,7 @@ do_addzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
NULL, NULL, NULL, view->name,
view->rdclass, cfg->actx, cfg->mctx);
if (result != ISC_R_SUCCESS) {
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
goto cleanup;
}
@ -13175,7 +13171,7 @@ do_addzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
false, false);
dns_view_freeze(view);
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
if (result != ISC_R_SUCCESS) {
TCHECK(putstr(text, "configure_zone failed: "));
@ -13323,7 +13319,7 @@ do_modzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
}
#endif /* ifndef HAVE_LMDB */
isc_loopmgr_pause(named_g_loopmgr);
isc_loopmgr_pause();
#ifndef HAVE_LMDB
/* Make sure we can open the configuration save file */
@ -13333,7 +13329,7 @@ do_modzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
TCHECK(putstr(text, view->new_zone_file));
TCHECK(putstr(text, "': "));
TCHECK(putstr(text, isc_result_totext(result)));
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
goto cleanup;
}
(void)isc_stdio_close(fp);
@ -13348,7 +13344,7 @@ do_modzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
TCHECK(putstr(text, view->new_zone_db));
TCHECK(putstr(text, "'"));
result = ISC_R_FAILURE;
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
goto cleanup;
}
#endif /* HAVE_LMDB */
@ -13361,7 +13357,7 @@ do_modzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
NULL, NULL, NULL, view->name,
view->rdclass, cfg->actx, cfg->mctx);
if (result != ISC_R_SUCCESS) {
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
goto cleanup;
}
@ -13373,7 +13369,7 @@ do_modzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
false, true);
dns_view_freeze(view);
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
if (result != ISC_R_SUCCESS) {
TCHECK(putstr(text, "configure_zone failed: "));
@ -15134,7 +15130,7 @@ named_server_nta(named_server_t *server, isc_lex_t *lex, bool readonly,
now = isc_stdtime_now();
isc_loopmgr_pause(named_g_loopmgr);
isc_loopmgr_pause();
ISC_LIST_FOREACH (server->viewlist, view, link) {
if (viewname != NULL && strcmp(view->name, viewname) != 0) {
continue;
@ -15244,7 +15240,7 @@ named_server_nta(named_server_t *server, isc_lex_t *lex, bool readonly,
}
cleanup_exclusive:
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
cleanup:
@ -15327,7 +15323,7 @@ mkey_destroy(dns_view_t *view, isc_buffer_t **text) {
view->name);
CHECK(putstr(text, msg));
isc_loopmgr_pause(named_g_loopmgr);
isc_loopmgr_pause();
/* Remove and clean up managed keys zone from view */
mkzone = view->managed_keys;
@ -15370,7 +15366,7 @@ mkey_destroy(dns_view_t *view, isc_buffer_t **text) {
result = ISC_R_SUCCESS;
cleanup:
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
return result;
}
@ -15870,7 +15866,7 @@ named_server_servestale(named_server_t *server, isc_lex_t *lex,
}
}
isc_loopmgr_pause(named_g_loopmgr);
isc_loopmgr_pause();
ISC_LIST_FOREACH (server->viewlist, view, link) {
dns_ttl_t stale_ttl = 0;
@ -15957,7 +15953,7 @@ named_server_servestale(named_server_t *server, isc_lex_t *lex,
}
cleanup:
isc_loopmgr_resume(named_g_loopmgr);
isc_loopmgr_resume();
if (isc_buffer_usedlength(*text) > 0) {
(void)putnull(text);

View File

@ -122,7 +122,6 @@ static bool usevc = false;
static bool usegsstsig = false;
static bool local_only = false;
static isc_nm_t *netmgr = NULL;
static isc_loopmgr_t *loopmgr = NULL;
static isc_mem_t *gmctx = NULL;
static dns_dispatchmgr_t *dispatchmgr = NULL;
static dns_requestmgr_t *requestmgr = NULL;
@ -908,7 +907,7 @@ setup_system(void *arg ISC_ATTR_UNUSED) {
irs_resconf_destroy(&resconf);
result = dns_dispatchmgr_create(gmctx, loopmgr, netmgr, &dispatchmgr);
result = dns_dispatchmgr_create(gmctx, netmgr, &dispatchmgr);
check_result(result, "dns_dispatchmgr_create");
set_source_ports(dispatchmgr);
@ -950,7 +949,7 @@ setup_system(void *arg ISC_ATTR_UNUSED) {
dns_transport_set_always_verify_remote(transport,
tls_always_verify_remote);
result = dns_requestmgr_create(gmctx, loopmgr, dispatchmgr, dispatchv4,
result = dns_requestmgr_create(gmctx, dispatchmgr, dispatchv4,
dispatchv6, &requestmgr);
check_result(result, "dns_requestmgr_create");
@ -975,9 +974,9 @@ get_addresses(char *host, in_port_t port, isc_sockaddr_t *sockaddr,
int count = 0;
isc_result_t result;
isc_loopmgr_blocking(loopmgr);
isc_loopmgr_blocking();
result = isc_getaddresses(host, port, sockaddr, naddrs, &count);
isc_loopmgr_nonblocking(loopmgr);
isc_loopmgr_nonblocking();
if (result != ISC_R_SUCCESS) {
error("couldn't get address for '%s': %s", host,
isc_result_totext(result));
@ -2651,7 +2650,7 @@ send_update(dns_name_t *zone, isc_sockaddr_t *primary) {
result = dns_request_create(requestmgr, updatemsg, srcaddr, primary,
req_transport, req_tls_ctx_cache, options,
tsigkey, timeout, timeout, udp_timeout,
udp_retries, isc_loop_main(loopmgr),
udp_retries, isc_loop_main(),
update_completed, NULL, &request);
check_result(result, "dns_request_create");
@ -2757,8 +2756,8 @@ recvsoa(void *arg) {
result = dns_request_create(
requestmgr, soaquery, srcaddr, addr, req_transport,
req_tls_ctx_cache, options, NULL, timeout, timeout,
udp_timeout, udp_retries, isc_loop_main(loopmgr),
recvsoa, reqinfo, &request);
udp_timeout, udp_retries, isc_loop_main(), recvsoa,
reqinfo, &request);
check_result(result, "dns_request_create");
requests++;
return;
@ -2985,11 +2984,11 @@ sendrequest(isc_sockaddr_t *destaddr, dns_message_t *msg,
srcaddr = localaddr4;
}
result = dns_request_create(
requestmgr, msg, srcaddr, destaddr, req_transport,
req_tls_ctx_cache, options, default_servers ? NULL : tsigkey,
timeout, timeout, udp_timeout, udp_retries,
isc_loop_main(loopmgr), recvsoa, reqinfo, request);
result = dns_request_create(requestmgr, msg, srcaddr, destaddr,
req_transport, req_tls_ctx_cache, options,
default_servers ? NULL : tsigkey, timeout,
timeout, udp_timeout, udp_retries,
isc_loop_main(), recvsoa, reqinfo, request);
check_result(result, "dns_request_create");
requests++;
}
@ -3192,8 +3191,8 @@ send_gssrequest(isc_sockaddr_t *destaddr, dns_message_t *msg,
result = dns_request_create(requestmgr, msg, srcaddr, destaddr,
req_transport, req_tls_ctx_cache, options,
tsigkey, timeout, timeout, udp_timeout,
udp_retries, isc_loop_main(loopmgr),
recvgss, reqinfo, request);
udp_retries, isc_loop_main(), recvgss,
reqinfo, request);
check_result(result, "dns_request_create");
if (debugging) {
show_message(stdout, msg, "Outgoing update query:");
@ -3473,7 +3472,7 @@ cleanup(void) {
isc_mutex_destroy(&answer_lock);
ddebug("Shutting down managers");
isc_managers_destroy(&gmctx, &loopmgr, &netmgr);
isc_managers_destroy(&gmctx, &netmgr);
}
static void
@ -3488,11 +3487,11 @@ getinput(void *arg) {
}
reset_system();
isc_loopmgr_blocking(loopmgr);
isc_loopmgr_blocking();
more = user_interaction();
isc_loopmgr_nonblocking(loopmgr);
isc_loopmgr_nonblocking();
if (!more) {
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
return;
}
@ -3522,7 +3521,7 @@ main(int argc, char **argv) {
pre_parse_args(argc, argv);
isc_managers_create(&gmctx, 1, &loopmgr, &netmgr);
isc_managers_create(&gmctx, 1, &netmgr);
parse_args(argc, argv);
@ -3533,10 +3532,10 @@ main(int argc, char **argv) {
isc_nm_setkeepalivetimeout(netmgr, timeoutms);
isc_nm_setadvertisedtimeout(netmgr, timeoutms);
isc_loopmgr_setup(loopmgr, setup_system, NULL);
isc_loopmgr_setup(loopmgr, getinput, NULL);
isc_loopmgr_teardown(loopmgr, shutdown_program, NULL);
isc_loopmgr_run(loopmgr);
isc_loopmgr_setup(setup_system, NULL);
isc_loopmgr_setup(getinput, NULL);
isc_loopmgr_teardown(shutdown_program, NULL);
isc_loopmgr_run();
cleanup();

View File

@ -58,7 +58,6 @@
bool verbose;
static isc_nm_t *netmgr = NULL;
static isc_loopmgr_t *loopmgr = NULL;
static const char *admin_conffile = NULL;
static const char *admin_keyfile = NULL;
@ -362,7 +361,7 @@ rndc_recvdone(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
isccc_sexpr_free(&response);
isccc_ccmsg_disconnect(ccmsg);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
static void
@ -952,8 +951,8 @@ main(int argc, char **argv) {
serial = isc_random32();
isc_managers_create(&rndc_mctx, 1, &loopmgr, &netmgr);
isc_loopmgr_setup(loopmgr, rndc_start, NULL);
isc_managers_create(&rndc_mctx, 1, &netmgr);
isc_loopmgr_setup(rndc_start, NULL);
isc_nm_setinitialtimeout(netmgr, timeout);
isc_nm_setprimariestimeout(netmgr, timeout);
@ -1000,7 +999,7 @@ main(int argc, char **argv) {
get_addresses(servername, (in_port_t)remoteport);
}
isc_loopmgr_run(loopmgr);
isc_loopmgr_run();
isccc_ccmsg_invalidate(&rndc_ccmsg);
@ -1015,7 +1014,7 @@ main(int argc, char **argv) {
isc_mem_stats(rndc_mctx, stderr);
}
isc_managers_destroy(&rndc_mctx, &loopmgr, &netmgr);
isc_managers_destroy(&rndc_mctx, &netmgr);
if (failed) {
return 1;

View File

@ -134,7 +134,6 @@ new_sample_instance(isc_mem_t *mctx, const char *db_name, int argc, char **argv,
dns_view_attach(dctx->view, &inst->view);
dns_zonemgr_attach(dctx->zmgr, &inst->zmgr);
inst->loopmgr = dctx->loopmgr;
/* Register new DNS DB implementation. */
result = dns_db_register(db_name, create_db, inst, mctx, &inst->db_imp);

View File

@ -47,7 +47,6 @@ struct sample_instance {
/* These are needed for zone creation. */
dns_view_t *view;
dns_zonemgr_t *zmgr;
isc_loopmgr_t *loopmgr;
bool exiting;
dns_zone_t *zone1;

View File

@ -59,7 +59,6 @@
static isc_mem_t *mctx = NULL;
static dns_requestmgr_t *requestmgr = NULL;
static isc_loopmgr_t *loopmgr = NULL;
static bool have_src = false;
static isc_sockaddr_t srcaddr;
static isc_sockaddr_t dstaddr;
@ -113,7 +112,7 @@ recvresponse(void *arg) {
dns_request_destroy(&request);
if (--onfly == 0) {
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
return;
}
@ -165,7 +164,7 @@ sendquery(void) {
result = dns_request_create(
requestmgr, message, have_src ? &srcaddr : NULL, &dstaddr, NULL,
NULL, DNS_REQUESTOPT_TCP, NULL, TIMEOUT, TIMEOUT, 0, 0,
isc_loop_main(loopmgr), recvresponse, message, &request);
isc_loop_main(), recvresponse, message, &request);
CHECK("dns_request_create", result);
return ISC_R_SUCCESS;
@ -182,7 +181,7 @@ sendqueries(void *arg) {
} while (result == ISC_R_SUCCESS);
if (onfly == 0) {
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
return;
}
@ -271,26 +270,26 @@ main(int argc, char *argv[]) {
}
isc_sockaddr_fromin(&dstaddr, &inaddr, port);
isc_managers_create(&mctx, 1, &loopmgr, &netmgr);
isc_managers_create(&mctx, 1, &netmgr);
RUNCHECK(dns_dispatchmgr_create(mctx, loopmgr, netmgr, &dispatchmgr));
RUNCHECK(dns_dispatchmgr_create(mctx, netmgr, &dispatchmgr));
RUNCHECK(dns_dispatch_createudp(
dispatchmgr, have_src ? &srcaddr : &bind_any, &dispatchv4));
RUNCHECK(dns_requestmgr_create(mctx, loopmgr, dispatchmgr, dispatchv4,
NULL, &requestmgr));
RUNCHECK(dns_requestmgr_create(mctx, dispatchmgr, dispatchv4, NULL,
&requestmgr));
dns_view_create(mctx, loopmgr, NULL, 0, "_test", &view);
dns_view_create(mctx, NULL, 0, "_test", &view);
isc_loopmgr_setup(loopmgr, sendqueries, NULL);
isc_loopmgr_teardown(loopmgr, teardown_view, view);
isc_loopmgr_teardown(loopmgr, teardown_requestmgr, requestmgr);
isc_loopmgr_teardown(loopmgr, teardown_dispatchv4, dispatchv4);
isc_loopmgr_teardown(loopmgr, teardown_dispatchmgr, dispatchmgr);
isc_loopmgr_setup(sendqueries, NULL);
isc_loopmgr_teardown(teardown_view, view);
isc_loopmgr_teardown(teardown_requestmgr, requestmgr);
isc_loopmgr_teardown(teardown_dispatchv4, dispatchv4);
isc_loopmgr_teardown(teardown_dispatchmgr, dispatchmgr);
isc_loopmgr_run(loopmgr);
isc_loopmgr_run();
isc_managers_destroy(&mctx, &loopmgr, &netmgr);
isc_managers_destroy(&mctx, &netmgr);
return 0;
}

View File

@ -52,7 +52,6 @@ static const char *protocols[] = { "udp", "tcp",
"http-plain-get" };
static isc_mem_t *mctx = NULL;
static isc_loopmgr_t *loopmgr = NULL;
static isc_nm_t *netmgr = NULL;
static protocol_t protocol;
@ -287,7 +286,7 @@ parse_options(int argc, char **argv) {
static void
setup(void) {
isc_managers_create(&mctx, workers, &loopmgr, &netmgr);
isc_managers_create(&mctx, workers, &netmgr);
}
static void
@ -300,7 +299,7 @@ teardown(void) {
isc_tlsctx_free(&tls_ctx);
}
isc_managers_destroy(&mctx, &loopmgr, &netmgr);
isc_managers_destroy(&mctx, &netmgr);
}
static void

View File

@ -34,7 +34,6 @@ typedef enum { UDP, TCP, DOT, HTTPS, HTTP } protocol_t;
static const char *protocols[] = { "udp", "tcp", "dot", "https", "http-plain" };
static isc_mem_t *mctx = NULL;
static isc_loopmgr_t *loopmgr = NULL;
static isc_nm_t *netmgr = NULL;
static protocol_t protocol;
@ -168,7 +167,7 @@ parse_options(int argc, char **argv) {
static void
setup(void) {
isc_managers_create(&mctx, workers, &loopmgr, &netmgr);
isc_managers_create(&mctx, workers, &netmgr);
}
static void
@ -177,7 +176,7 @@ teardown(void) {
isc_tlsctx_free(&tls_ctx);
}
isc_managers_destroy(&mctx, &loopmgr, &netmgr);
isc_managers_destroy(&mctx, &netmgr);
}
static void

View File

@ -83,7 +83,6 @@
#define MAXTRIES 0xffffffff
static isc_mem_t *mctx = NULL;
static isc_loopmgr_t *loopmgr = NULL;
static dns_requestmgr_t *requestmgr = NULL;
static const char *batchname = NULL;
static FILE *batchfp = NULL;
@ -522,7 +521,7 @@ cleanup:
dns_request_destroy(&request);
if (--onfly == 0) {
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
return;
}
@ -731,7 +730,7 @@ sendquery(struct query *query) {
result = dns_request_create(
requestmgr, message, have_src ? &srcaddr : NULL, &dstaddr, NULL,
NULL, options, NULL, query->timeout, query->timeout,
query->udptimeout, query->udpretries, isc_loop_main(loopmgr),
query->udptimeout, query->udpretries, isc_loop_main(),
recvresponse, message, &request);
CHECK("dns_request_create", result);
@ -750,7 +749,7 @@ sendqueries(void *arg) {
}
if (onfly == 0) {
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
}
@ -2058,7 +2057,7 @@ teardown(void *arg ISC_ATTR_UNUSED) {
static void
setup(void *arg ISC_ATTR_UNUSED) {
RUNCHECK(dns_dispatchmgr_create(mctx, loopmgr, netmgr, &dispatchmgr));
RUNCHECK(dns_dispatchmgr_create(mctx, netmgr, &dispatchmgr));
set_source_ports(dispatchmgr);
@ -2071,10 +2070,10 @@ setup(void *arg ISC_ATTR_UNUSED) {
dispatchmgr, have_src ? &srcaddr : &bind_any, &dispatchvx));
RUNCHECK(dns_requestmgr_create(
mctx, loopmgr, dispatchmgr, have_ipv4 ? dispatchvx : NULL,
mctx, dispatchmgr, have_ipv4 ? dispatchvx : NULL,
have_ipv6 ? dispatchvx : NULL, &requestmgr));
dns_view_create(mctx, loopmgr, NULL, 0, "_mdig", &view);
dns_view_create(mctx, NULL, 0, "_mdig", &view);
}
/*% Main processing routine for mdig */
@ -2096,7 +2095,7 @@ main(int argc, char *argv[]) {
preparse_args(argc, argv);
isc_managers_create(&mctx, 1, &loopmgr, &netmgr);
isc_managers_create(&mctx, 1, &netmgr);
isc_nonce_buf(cookie_secret, sizeof(cookie_secret));
@ -2124,9 +2123,9 @@ main(int argc, char *argv[]) {
fatal("can't choose between IPv4 and IPv6");
}
isc_loopmgr_setup(loopmgr, setup, NULL);
isc_loopmgr_setup(loopmgr, sendqueries, ISC_LIST_HEAD(queries));
isc_loopmgr_teardown(loopmgr, teardown, NULL);
isc_loopmgr_setup(setup, NULL);
isc_loopmgr_setup(sendqueries, ISC_LIST_HEAD(queries));
isc_loopmgr_teardown(teardown, NULL);
/*
* Stall to the start of a new second.
@ -2154,7 +2153,7 @@ main(int argc, char *argv[]) {
} while (1);
}
isc_loopmgr_run(loopmgr);
isc_loopmgr_run();
ISC_LIST_FOREACH (queries, query, link) {
if (query->ednsopts != NULL) {
@ -2176,6 +2175,6 @@ main(int argc, char *argv[]) {
isc_mem_free(mctx, default_query.ecs_addr);
}
isc_managers_destroy(&mctx, &loopmgr, &netmgr);
isc_managers_destroy(&mctx, &netmgr);
return 0;
}

View File

@ -16,8 +16,9 @@ information regarding copyright ownership.
This document aims to describe the design of the basic event loop handling in
the BIND 9.
Every application is expected to create and use a single ``isc_loopmgr_t``
instance.
Every application is expected to run ``isc_loopmgr_create()``, either
directly or indirectly via ``isc_managers_create()``. This creates a
single loop manager.
## Event Loops

View File

@ -86,7 +86,6 @@ static isc_mem_t *mctx = NULL;
#define HMACSHA256 "\x0bhmac-sha256"
static isc_stdtime_t fuzztime = 0x622acce1;
static isc_loopmgr_t *loopmgr = NULL;
static dns_view_t *view = NULL;
static dns_tsigkey_t *tsigkey = NULL;
static dns_tsigkeyring_t *ring = NULL;
@ -171,9 +170,9 @@ LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) {
isc_mem_create("fuzz", &mctx);
isc_loopmgr_create(mctx, 1, &loopmgr);
isc_loopmgr_create(mctx, 1);
dns_view_create(mctx, loopmgr, NULL, dns_rdataclass_in, "view", &view);
dns_view_create(mctx, NULL, dns_rdataclass_in, "view", &view);
dns_tsigkeyring_create(mctx, &ring);
dns_tsigkeyring_create(mctx, &emptyring);

View File

@ -104,7 +104,6 @@ typedef struct dns_adblru {
struct dns_adb {
unsigned int magic;
uint32_t nloops;
isc_loopmgr_t *loopmgr;
isc_mutex_t lock;
isc_mem_t *mctx;
@ -1608,18 +1607,16 @@ ISC_REFCOUNT_IMPL(dns_adb, dns_adb_destroy);
*/
void
dns_adb_create(isc_mem_t *mem, isc_loopmgr_t *loopmgr, dns_view_t *view,
dns_adb_t **adbp) {
dns_adb_create(isc_mem_t *mem, dns_view_t *view, dns_adb_t **adbp) {
REQUIRE(mem != NULL);
REQUIRE(view != NULL);
REQUIRE(adbp != NULL && *adbp == NULL);
uint32_t nloops = isc_loopmgr_nloops(loopmgr);
uint32_t nloops = isc_loopmgr_nloops();
dns_adb_t *adb = isc_mem_get(mem, sizeof(dns_adb_t));
*adb = (dns_adb_t){
.references = 1,
.nloops = nloops,
.loopmgr = loopmgr,
.magic = DNS_ADB_MAGIC,
};
@ -1696,7 +1693,7 @@ dns_adb_shutdown(dns_adb_t *adb) {
* shutting down ADB.
*/
dns_adb_ref(adb);
isc_async_run(isc_loop_main(adb->loopmgr), dns_adb_shutdown_async, adb);
isc_async_run(isc_loop_main(), dns_adb_shutdown_async, adb);
}
/*

View File

@ -82,10 +82,8 @@ static bool
bcentry_alive(struct cds_lfht *ht, dns_bcentry_t *bad, isc_stdtime_t now);
dns_badcache_t *
dns_badcache_new(isc_mem_t *mctx, isc_loopmgr_t *loopmgr) {
REQUIRE(loopmgr != NULL);
uint32_t nloops = isc_loopmgr_nloops(loopmgr);
dns_badcache_new(isc_mem_t *mctx) {
uint32_t nloops = isc_loopmgr_nloops();
dns_badcache_t *bc = isc_mem_get(mctx, sizeof(*bc));
*bc = (dns_badcache_t){
.magic = BADCACHE_MAGIC,

View File

@ -69,7 +69,6 @@ struct dns_cache {
isc_mem_t *mctx; /* Memory context for the dns_cache object */
isc_mem_t *hmctx; /* Heap memory */
isc_mem_t *tmctx; /* Tree memory */
isc_loopmgr_t *loopmgr;
char *name;
isc_refcount_t references;
@ -135,7 +134,7 @@ cache_create_db(dns_cache_t *cache, dns_db_t **dbp, isc_mem_t **tmctxp,
* XXX this is only used by the RBT cache, and can
* be removed when it is.
*/
dns_db_setloop(db, isc_loop_main(cache->loopmgr));
dns_db_setloop(db, isc_loop_main());
*dbp = db;
*hmctxp = hmctx;
@ -167,12 +166,11 @@ cache_destroy(dns_cache_t *cache) {
}
isc_result_t
dns_cache_create(isc_loopmgr_t *loopmgr, dns_rdataclass_t rdclass,
const char *cachename, isc_mem_t *mctx, dns_cache_t **cachep) {
dns_cache_create(dns_rdataclass_t rdclass, const char *cachename,
isc_mem_t *mctx, dns_cache_t **cachep) {
isc_result_t result;
dns_cache_t *cache = NULL;
REQUIRE(loopmgr != NULL);
REQUIRE(cachename != NULL);
REQUIRE(cachep != NULL && *cachep == NULL);
@ -180,7 +178,6 @@ dns_cache_create(isc_loopmgr_t *loopmgr, dns_rdataclass_t rdclass,
*cache = (dns_cache_t){
.rdclass = rdclass,
.name = isc_mem_strdup(mctx, cachename),
.loopmgr = loopmgr,
.references = ISC_REFCOUNT_INITIALIZER(1),
.magic = CACHE_MAGIC,
};

View File

@ -142,7 +142,6 @@ struct dns_catz_zones {
isc_refcount_t references;
isc_mutex_t lock;
dns_catz_zonemodmethods_t *zmm;
isc_loopmgr_t *loopmgr;
dns_view_t *view;
atomic_bool shuttingdown;
};
@ -781,16 +780,15 @@ dns__catz_zones_merge(dns_catz_zone_t *catz, dns_catz_zone_t *newcatz) {
}
dns_catz_zones_t *
dns_catz_zones_new(isc_mem_t *mctx, isc_loopmgr_t *loopmgr,
dns_catz_zonemodmethods_t *zmm) {
dns_catz_zones_new(isc_mem_t *mctx, dns_catz_zonemodmethods_t *zmm) {
REQUIRE(mctx != NULL);
REQUIRE(loopmgr != NULL);
REQUIRE(zmm != NULL);
dns_catz_zones_t *catzs = isc_mem_get(mctx, sizeof(*catzs));
*catzs = (dns_catz_zones_t){ .loopmgr = loopmgr,
*catzs = (dns_catz_zones_t){
.zmm = zmm,
.magic = DNS_CATZ_ZONES_MAGIC };
.magic = DNS_CATZ_ZONES_MAGIC,
};
isc_mutex_init(&catzs->lock);
isc_refcount_init(&catzs->references, 1);

View File

@ -198,14 +198,13 @@ getudpdispatch(int family, dns_dispatchmgr_t *dispatchmgr,
static isc_result_t
createview(isc_mem_t *mctx, dns_rdataclass_t rdclass, isc_nm_t *nm,
isc_tlsctx_cache_t *tlsctx_client_cache, isc_loopmgr_t *loopmgr,
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;
dns_view_t *view = NULL;
dns_view_create(mctx, loopmgr, dispatchmgr, rdclass,
DNS_CLIENTVIEW_NAME, &view);
dns_view_create(mctx, dispatchmgr, rdclass, DNS_CLIENTVIEW_NAME, &view);
/* Initialize view security roots */
dns_view_initsecroots(view);
@ -225,8 +224,8 @@ cleanup:
}
isc_result_t
dns_client_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t *nm,
unsigned int options, isc_tlsctx_cache_t *tlsctx_client_cache,
dns_client_create(isc_mem_t *mctx, isc_nm_t *nm, unsigned int options,
isc_tlsctx_cache_t *tlsctx_client_cache,
dns_client_t **clientp, const isc_sockaddr_t *localaddr4,
const isc_sockaddr_t *localaddr6) {
isc_result_t result;
@ -244,14 +243,13 @@ dns_client_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t *nm,
client = isc_mem_get(mctx, sizeof(*client));
*client = (dns_client_t){
.loop = isc_loop_get(loopmgr, 0),
.loop = isc_loop_get(0),
.nm = nm,
.max_restarts = DEF_MAX_RESTARTS,
.max_queries = DEF_MAX_QUERIES,
};
result = dns_dispatchmgr_create(mctx, loopmgr, nm,
&client->dispatchmgr);
result = dns_dispatchmgr_create(mctx, nm, &client->dispatchmgr);
if (result != ISC_R_SUCCESS) {
goto cleanup_client;
}
@ -289,7 +287,6 @@ dns_client_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t *nm,
/* Create the default view for class IN */
result = createview(mctx, dns_rdataclass_in, nm, tlsctx_client_cache,
isc_loop_getloopmgr(client->loop),
client->dispatchmgr, dispatchv4, dispatchv6, &view);
if (result != ISC_R_SUCCESS) {
goto cleanup_references;

View File

@ -969,7 +969,7 @@ setavailports(dns_dispatchmgr_t *mgr, isc_portset_t *v4portset,
*/
isc_result_t
dns_dispatchmgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t *nm,
dns_dispatchmgr_create(isc_mem_t *mctx, isc_nm_t *nm,
dns_dispatchmgr_t **mgrp) {
dns_dispatchmgr_t *mgr = NULL;
isc_portset_t *v4portset = NULL;
@ -981,7 +981,7 @@ dns_dispatchmgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t *nm,
mgr = isc_mem_get(mctx, sizeof(dns_dispatchmgr_t));
*mgr = (dns_dispatchmgr_t){
.magic = 0,
.nloops = isc_loopmgr_nloops(loopmgr),
.nloops = isc_loopmgr_nloops(),
};
#if DNS_DISPATCH_TRACE

View File

@ -278,12 +278,10 @@ dns_dt_reopen(dns_dtenv_t *env, int roll) {
struct fstrm_file_options *ffwopt = NULL;
struct fstrm_writer_options *fwopt = NULL;
struct fstrm_writer *fw = NULL;
isc_loopmgr_t *loopmgr = NULL;
REQUIRE(VALID_DTENV(env));
loopmgr = isc_loop_getloopmgr(env->loop);
isc_loopmgr_pause(loopmgr);
isc_loopmgr_pause();
/*
* Check that we can create a new fw object.
@ -379,7 +377,7 @@ cleanup:
fstrm_writer_options_destroy(&fwopt);
}
isc_loopmgr_resume(loopmgr);
isc_loopmgr_resume();
return result;
}

View File

@ -258,15 +258,13 @@ dns_dyndb_cleanup(void) {
void
dns_dyndb_createctx(isc_mem_t *mctx, const void *hashinit, dns_view_t *view,
dns_zonemgr_t *zmgr, isc_loopmgr_t *loopmgr,
dns_dyndbctx_t **dctxp) {
dns_zonemgr_t *zmgr, dns_dyndbctx_t **dctxp) {
dns_dyndbctx_t *dctx;
REQUIRE(dctxp != NULL && *dctxp == NULL);
dctx = isc_mem_get(mctx, sizeof(*dctx));
*dctx = (dns_dyndbctx_t){
.loopmgr = loopmgr,
.hashinit = hashinit,
};
@ -300,7 +298,6 @@ dns_dyndb_destroyctx(dns_dyndbctx_t **dctxp) {
if (dctx->zmgr != NULL) {
dns_zonemgr_detach(&dctx->zmgr);
}
dctx->loopmgr = NULL;
isc_mem_putanddetach(&dctx->mctx, dctx, sizeof(*dctx));
}

View File

@ -235,8 +235,7 @@ struct dns_adbaddrinfo {
****/
void
dns_adb_create(isc_mem_t *mem, isc_loopmgr_t *loopmgr, dns_view_t *view,
dns_adb_t **newadb);
dns_adb_create(isc_mem_t *mem, dns_view_t *view, dns_adb_t **newadb);
/*%<
* Create a new ADB.
*

View File

@ -56,7 +56,7 @@
***/
dns_badcache_t *
dns_badcache_new(isc_mem_t *mctx, isc_loopmgr_t *loopmgr);
dns_badcache_new(isc_mem_t *mctx);
/*%
* Allocate and initialize a badcache and store it in '*bcp'.
*

View File

@ -69,8 +69,8 @@ ISC_REFCOUNT_DECL(dns_cache);
#endif
isc_result_t
dns_cache_create(isc_loopmgr_t *loopmgr, dns_rdataclass_t rdclass,
const char *cachename, isc_mem_t *mctx, dns_cache_t **cachep);
dns_cache_create(dns_rdataclass_t rdclass, const char *cachename,
isc_mem_t *mctx, dns_cache_t **cachep);
/*%<
* Create a new DNS cache.
*

View File

@ -279,8 +279,7 @@ struct dns_catz_zonemodmethods {
};
dns_catz_zones_t *
dns_catz_zones_new(isc_mem_t *mctx, isc_loopmgr_t *loopmgr,
dns_catz_zonemodmethods_t *zmm);
dns_catz_zones_new(isc_mem_t *mctx, dns_catz_zonemodmethods_t *zmm);
/*%<
* Allocate a new catz_zones object, a collection storing all catalog zones
* for a view.

View File

@ -95,8 +95,8 @@ typedef struct dns_clientresume {
} dns_clientresume_t; /* too long? */
isc_result_t
dns_client_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t *nm,
unsigned int options, isc_tlsctx_cache_t *tlsctx_client_cache,
dns_client_create(isc_mem_t *mctx, isc_nm_t *nm, unsigned int options,
isc_tlsctx_cache_t *tlsctx_client_cache,
dns_client_t **clientp, const isc_sockaddr_t *localaddr4,
const isc_sockaddr_t *localaddr6);
/*%<

View File

@ -75,8 +75,7 @@ typedef enum dns_dispatchopt {
} dns_dispatchopt_t;
isc_result_t
dns_dispatchmgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t *nm,
dns_dispatchmgr_t **mgrp);
dns_dispatchmgr_create(isc_mem_t *mctx, isc_nm_t *nm, dns_dispatchmgr_t **mgrp);
/*%<
* Creates a new dispatchmgr object, and sets the available ports
* to the default range (1024-65535).

View File

@ -36,7 +36,6 @@ struct dns_dyndbctx {
isc_mem_t *mctx;
dns_view_t *view;
dns_zonemgr_t *zmgr;
isc_loopmgr_t *loopmgr;
const bool *refvar; /* unused, but retained for API compatibility */
};
@ -124,8 +123,7 @@ dns_dyndb_cleanup(void);
void
dns_dyndb_createctx(isc_mem_t *mctx, const void *hashinit, dns_view_t *view,
dns_zonemgr_t *zmgr, isc_loopmgr_t *loopmgr,
dns_dyndbctx_t **dctxp);
dns_zonemgr_t *zmgr, dns_dyndbctx_t **dctxp);
/*%
* Create a dyndb initialization context structure, with
* pointers to structures in the server that the dyndb module will

View File

@ -45,8 +45,7 @@
#define VALID_NTATABLE(nt) ISC_MAGIC_VALID(nt, NTATABLE_MAGIC)
void
dns_ntatable_create(dns_view_t *view, isc_loopmgr_t *loopmgr,
dns_ntatable_t **ntatablep);
dns_ntatable_create(dns_view_t *view, dns_ntatable_t **ntatablep);
/*%<
* Create an NTA table in view 'view'.
*

View File

@ -49,8 +49,7 @@
#define DNS_REQUESTOPT_LARGE 0x00000008U
isc_result_t
dns_requestmgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr,
dns_dispatchmgr_t *dispatchmgr,
dns_requestmgr_create(isc_mem_t *mctx, dns_dispatchmgr_t *dispatchmgr,
dns_dispatch_t *dispatchv4, dns_dispatch_t *dispatchv6,
dns_requestmgr_t **requestmgrp);
/*%<

View File

@ -170,8 +170,8 @@ enum {
#define DNS_QMIN_MAX_NO_DELEGATION 3
isc_result_t
dns_resolver_create(dns_view_t *view, isc_loopmgr_t *loopmgr, isc_nm_t *nm,
unsigned int options, isc_tlsctx_cache_t *tlsctx_cache,
dns_resolver_create(dns_view_t *view, isc_nm_t *nm, unsigned int options,
isc_tlsctx_cache_t *tlsctx_cache,
dns_dispatch_t *dispatchv4, dns_dispatch_t *dispatchv6,
dns_resolver_t **resp);

View File

@ -212,7 +212,6 @@ struct dns_rpz_zones {
unsigned int magic;
isc_refcount_t references;
isc_mem_t *mctx;
isc_loopmgr_t *loopmgr;
dns_rpz_popt_t p;
dns_rpz_zone_t *zones[DNS_RPZ_MAX_ZONES];
@ -376,8 +375,7 @@ dns_rpz_decode_cname(dns_rpz_zone_t *rpz, dns_rdataset_t *rdataset,
dns_name_t *selfname);
isc_result_t
dns_rpz_new_zones(dns_view_t *view, isc_loopmgr_t *loopmgr,
dns_rpz_zones_t **rpzsp);
dns_rpz_new_zones(dns_view_t *view, dns_rpz_zones_t **rpzsp);
isc_result_t
dns_rpz_new_zone(dns_rpz_zones_t *rpzs, dns_rpz_zone_t **rpzp);

View File

@ -55,8 +55,8 @@
***/
dns_unreachcache_t *
dns_unreachcache_new(isc_mem_t *mctx, isc_loopmgr_t *loopmgr,
const uint16_t expire_min_s, const uint16_t expire_max_s,
dns_unreachcache_new(isc_mem_t *mctx, const uint16_t expire_min_s,
const uint16_t expire_max_s,
const uint16_t backoff_eligible_s);
/*%
* Allocate and initialize an unreachable cache. A newly entered entry expires

View File

@ -263,9 +263,8 @@ struct dns_view {
#endif /* HAVE_LMDB */
void
dns_view_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr,
dns_dispatchmgr_t *dispmgr, dns_rdataclass_t rdclass,
const char *name, dns_view_t **viewp);
dns_view_create(isc_mem_t *mctx, dns_dispatchmgr_t *dispmgr,
dns_rdataclass_t rdclass, const char *name, dns_view_t **viewp);
/*%<
* Create a view.
*
@ -924,13 +923,12 @@ dns_view_iscacheshared(dns_view_t *view);
*/
void
dns_view_initntatable(dns_view_t *view, isc_loopmgr_t *loopmgr);
dns_view_initntatable(dns_view_t *view);
/*%<
* Initialize the negative trust anchor table for the view.
*
* Requires:
* \li 'view' is valid.
* \li 'loopmgr' is a valid loopmgr.
*/
isc_result_t

View File

@ -42,7 +42,6 @@ struct dns_ntatable {
isc_mem_t *mctx;
dns_view_t *view;
isc_rwlock_t rwlock;
isc_loopmgr_t *loopmgr;
isc_refcount_t references;
dns_qpmulti_t *table;
atomic_bool shuttingdown;
@ -113,18 +112,16 @@ ISC_REFCOUNT_IMPL(dns__nta, dns__nta_destroy);
#endif
void
dns_ntatable_create(dns_view_t *view, isc_loopmgr_t *loopmgr,
dns_ntatable_t **ntatablep) {
dns_ntatable_create(dns_view_t *view, dns_ntatable_t **ntatablep) {
dns_ntatable_t *ntatable = NULL;
REQUIRE(ntatablep != NULL && *ntatablep == NULL);
ntatable = isc_mem_get(view->mctx, sizeof(*ntatable));
*ntatable = (dns_ntatable_t){
.loopmgr = loopmgr,
.mctx = isc_mem_ref(view->mctx),
};
isc_mem_attach(view->mctx, &ntatable->mctx);
dns_view_weakattach(view, &ntatable->view);
isc_rwlock_init(&ntatable->rwlock);

View File

@ -239,8 +239,6 @@ typedef struct qpcache qpcache_t;
struct qpcache {
/* Unlocked. */
dns_db_t common;
/* Loopmgr */
isc_loopmgr_t *loopmgr;
/* Locks the data in this struct */
isc_rwlock_t lock;
/* Locks the tree structure (prevents nodes appearing/disappearing) */
@ -788,8 +786,7 @@ qpcnode_release(qpcache_t *qpdb, qpcnode_t *node, isc_rwlocktype_t *nlocktypep,
deadlink))
{
/* Queue was empty, trigger new cleaning */
isc_loop_t *loop = isc_loop_get(qpdb->loopmgr,
node->locknum);
isc_loop_t *loop = isc_loop_get(node->locknum);
qpcache_ref(qpdb);
isc_async_run(loop, cleanup_deadnodes_cb, qpdb);
@ -3166,8 +3163,7 @@ dns__qpcache_create(isc_mem_t *mctx, const dns_name_t *origin,
isc_mem_t *hmctx = mctx;
isc_loop_t *loop = isc_loop();
int i;
isc_loopmgr_t *loopmgr = isc_loop_getloopmgr(loop);
size_t nloops = isc_loopmgr_nloops(loopmgr);
size_t nloops = isc_loopmgr_nloops();
/* This database implementation only supports cache semantics */
REQUIRE(type == dns_dbtype_cache);
@ -3181,7 +3177,6 @@ dns__qpcache_create(isc_mem_t *mctx, const dns_name_t *origin,
.common.rdclass = rdclass,
.common.attributes = DNS_DBATTR_CACHE,
.common.references = 1,
.loopmgr = isc_loop_getloopmgr(loop),
.references = 1,
.buckets_count = nloops,
};
@ -3196,7 +3191,7 @@ dns__qpcache_create(isc_mem_t *mctx, const dns_name_t *origin,
isc_rwlock_init(&qpdb->lock);
TREE_INITLOCK(&qpdb->tree_lock);
qpdb->buckets_count = isc_loopmgr_nloops(qpdb->loopmgr);
qpdb->buckets_count = isc_loopmgr_nloops();
dns_rdatasetstats_create(mctx, &qpdb->rrsetstats);
for (i = 0; i < (int)qpdb->buckets_count; i++) {

View File

@ -49,7 +49,6 @@ struct dns_requestmgr {
unsigned int magic;
isc_mem_t *mctx;
isc_refcount_t references;
isc_loopmgr_t *loopmgr;
atomic_bool shuttingdown;
@ -122,8 +121,7 @@ req_log(int level, const char *fmt, ...) ISC_FORMAT_PRINTF(2, 3);
***/
isc_result_t
dns_requestmgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr,
dns_dispatchmgr_t *dispatchmgr,
dns_requestmgr_create(isc_mem_t *mctx, dns_dispatchmgr_t *dispatchmgr,
dns_dispatch_t *dispatchv4, dns_dispatch_t *dispatchv6,
dns_requestmgr_t **requestmgrp) {
REQUIRE(requestmgrp != NULL && *requestmgrp == NULL);
@ -134,18 +132,17 @@ dns_requestmgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr,
dns_requestmgr_t *requestmgr = isc_mem_get(mctx, sizeof(*requestmgr));
*requestmgr = (dns_requestmgr_t){
.magic = REQUESTMGR_MAGIC,
.loopmgr = loopmgr,
};
isc_mem_attach(mctx, &requestmgr->mctx);
uint32_t nloops = isc_loopmgr_nloops(requestmgr->loopmgr);
uint32_t nloops = isc_loopmgr_nloops();
requestmgr->requests = isc_mem_cget(requestmgr->mctx, nloops,
sizeof(requestmgr->requests[0]));
for (size_t i = 0; i < nloops; i++) {
ISC_LIST_INIT(requestmgr->requests[i]);
/* unreferenced in requests_cancel() */
isc_loop_ref(isc_loop_get(requestmgr->loopmgr, i));
isc_loop_ref(isc_loop_get(i));
}
dns_dispatchmgr_attach(dispatchmgr, &requestmgr->dispatchmgr);
@ -153,12 +150,12 @@ dns_requestmgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr,
if (dispatchv4 != NULL) {
dns_dispatchset_create(requestmgr->mctx, dispatchv4,
&requestmgr->dispatches4,
isc_loopmgr_nloops(requestmgr->loopmgr));
isc_loopmgr_nloops());
}
if (dispatchv6 != NULL) {
dns_dispatchset_create(requestmgr->mctx, dispatchv6,
&requestmgr->dispatches6,
isc_loopmgr_nloops(requestmgr->loopmgr));
isc_loopmgr_nloops());
}
isc_refcount_init(&requestmgr->references, 1);
@ -184,7 +181,7 @@ requests_cancel(void *arg) {
req_sendevent(request, ISC_R_CANCELED);
}
isc_loop_unref(isc_loop_get(requestmgr->loopmgr, tid));
isc_loop_unref(isc_loop_get(tid));
dns_requestmgr_detach(&requestmgr);
}
@ -211,7 +208,7 @@ dns_requestmgr_shutdown(dns_requestmgr_t *requestmgr) {
synchronize_rcu();
isc_tid_t tid = isc_tid();
uint32_t nloops = isc_loopmgr_nloops(requestmgr->loopmgr);
uint32_t nloops = isc_loopmgr_nloops();
for (size_t i = 0; i < nloops; i++) {
dns_requestmgr_ref(requestmgr);
@ -221,7 +218,7 @@ dns_requestmgr_shutdown(dns_requestmgr_t *requestmgr) {
continue;
}
isc_loop_t *loop = isc_loop_get(requestmgr->loopmgr, i);
isc_loop_t *loop = isc_loop_get(i);
isc_async_run(loop, requests_cancel, requestmgr);
}
}
@ -232,7 +229,7 @@ requestmgr_destroy(dns_requestmgr_t *requestmgr) {
INSIST(atomic_load(&requestmgr->shuttingdown));
size_t nloops = isc_loopmgr_nloops(requestmgr->loopmgr);
size_t nloops = isc_loopmgr_nloops();
for (size_t i = 0; i < nloops; i++) {
INSIST(ISC_LIST_EMPTY(requestmgr->requests[i]));
}

View File

@ -551,7 +551,6 @@ struct dns_resolver {
isc_mutex_t lock;
isc_mutex_t primelock;
dns_rdataclass_t rdclass;
isc_loopmgr_t *loopmgr;
isc_nm_t *nm;
dns_view_t *view;
bool frozen;
@ -9849,8 +9848,8 @@ spillattimer_countdown(void *arg) {
}
isc_result_t
dns_resolver_create(dns_view_t *view, isc_loopmgr_t *loopmgr, isc_nm_t *nm,
unsigned int options, isc_tlsctx_cache_t *tlsctx_cache,
dns_resolver_create(dns_view_t *view, isc_nm_t *nm, unsigned int options,
isc_tlsctx_cache_t *tlsctx_cache,
dns_dispatch_t *dispatchv4, dns_dispatch_t *dispatchv6,
dns_resolver_t **resp) {
dns_resolver_t *res = NULL;
@ -9866,7 +9865,6 @@ dns_resolver_create(dns_view_t *view, isc_loopmgr_t *loopmgr, isc_nm_t *nm,
res = isc_mem_get(view->mctx, sizeof(*res));
*res = (dns_resolver_t){
.loopmgr = loopmgr,
.rdclass = view->rdclass,
.nm = nm,
.options = options,
@ -9880,7 +9878,7 @@ dns_resolver_create(dns_view_t *view, isc_loopmgr_t *loopmgr, isc_nm_t *nm,
.maxdepth = DEFAULT_RECURSION_DEPTH,
.maxqueries = DEFAULT_MAX_QUERIES,
.alternates = ISC_LIST_INITIALIZER,
.nloops = isc_loopmgr_nloops(loopmgr),
.nloops = isc_loopmgr_nloops(),
.maxvalidations = DEFAULT_MAX_VALIDATIONS,
.maxvalidationfails = DEFAULT_MAX_VALIDATION_FAILURES,
};
@ -9928,7 +9926,7 @@ dns_resolver_create(dns_view_t *view, isc_loopmgr_t *loopmgr, isc_nm_t *nm,
res->rdspools = isc_mem_cget(res->mctx, res->nloops,
sizeof(res->rdspools[0]));
for (size_t i = 0; i < res->nloops; i++) {
isc_loop_t *loop = isc_loop_get(res->loopmgr, i);
isc_loop_t *loop = isc_loop_get(i);
isc_mem_t *pool_mctx = isc_loop_getmctx(loop);
dns_message_createpools(pool_mctx, &res->namepools[i],
@ -10950,8 +10948,7 @@ dns_resolver_setstats(dns_resolver_t *res, isc_stats_t *stats) {
isc_stats_attach(stats, &res->stats);
/* initialize the bucket "counter"; it's a static value */
set_stats(res, dns_resstatscounter_buckets,
isc_loopmgr_nloops(res->loopmgr));
set_stats(res, dns_resstatscounter_buckets, isc_loopmgr_nloops());
}
void

View File

@ -1493,8 +1493,7 @@ add_name(dns_rpz_zone_t *rpz, dns_rpz_type_t rpz_type,
* Get ready for a new set of policy zones for a view.
*/
isc_result_t
dns_rpz_new_zones(dns_view_t *view, isc_loopmgr_t *loopmgr,
dns_rpz_zones_t **rpzsp) {
dns_rpz_new_zones(dns_view_t *view, dns_rpz_zones_t **rpzsp) {
dns_rpz_zones_t *rpzs = NULL;
isc_mem_t *mctx = NULL;
@ -1505,7 +1504,6 @@ dns_rpz_new_zones(dns_view_t *view, isc_loopmgr_t *loopmgr,
rpzs = isc_mem_get(mctx, sizeof(*rpzs));
*rpzs = (dns_rpz_zones_t){
.loopmgr = loopmgr,
.magic = DNS_RPZ_ZONES_MAGIC,
};

View File

@ -86,14 +86,13 @@ ucentry_alive(struct cds_lfht *ht, dns_ucentry_t *unreach, isc_stdtime_t now,
bool alive_or_waiting);
dns_unreachcache_t *
dns_unreachcache_new(isc_mem_t *mctx, isc_loopmgr_t *loopmgr,
const uint16_t expire_min_s, const uint16_t expire_max_s,
dns_unreachcache_new(isc_mem_t *mctx, const uint16_t expire_min_s,
const uint16_t expire_max_s,
const uint16_t backoff_eligible_s) {
REQUIRE(loopmgr != NULL);
REQUIRE(expire_min_s > 0);
REQUIRE(expire_min_s <= expire_max_s);
uint32_t nloops = isc_loopmgr_nloops(loopmgr);
uint32_t nloops = isc_loopmgr_nloops();
dns_unreachcache_t *uc = isc_mem_get(mctx, sizeof(*uc));
*uc = (dns_unreachcache_t){
.magic = UNREACHCACHE_MAGIC,

View File

@ -21,6 +21,7 @@
#include <lmdb.h>
#endif /* ifdef HAVE_LMDB */
#include <isc/async.h>
#include <isc/atomic.h>
#include <isc/dir.h>
#include <isc/file.h>
@ -91,9 +92,9 @@
#define UNREACH_BACKOFF_ELIGIBLE_SEC ((uint16_t)120)
void
dns_view_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr,
dns_dispatchmgr_t *dispatchmgr, dns_rdataclass_t rdclass,
const char *name, dns_view_t **viewp) {
dns_view_create(isc_mem_t *mctx, dns_dispatchmgr_t *dispatchmgr,
dns_rdataclass_t rdclass, const char *name,
dns_view_t **viewp) {
dns_view_t *view = NULL;
isc_result_t result;
char buffer[1024];
@ -153,10 +154,10 @@ dns_view_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr,
dns_tsigkeyring_create(view->mctx, &view->dynamickeys);
view->failcache = dns_badcache_new(view->mctx, loopmgr);
view->failcache = dns_badcache_new(view->mctx);
view->unreachcache = dns_unreachcache_new(
view->mctx, loopmgr, UNREACH_HOLD_TIME_INITIAL_SEC,
view->mctx, UNREACH_HOLD_TIME_INITIAL_SEC,
UNREACH_HOLD_TIME_MAX_SEC, UNREACH_BACKOFF_ELIGIBLE_SEC);
isc_mutex_init(&view->new_zone_lock);
@ -393,16 +394,8 @@ dns_view_attach(dns_view_t *source, dns_view_t **targetp) {
*targetp = source;
}
void
dns_view_detach(dns_view_t **viewp) {
dns_view_t *view = NULL;
REQUIRE(viewp != NULL && DNS_VIEW_VALID(*viewp));
view = *viewp;
*viewp = NULL;
if (isc_refcount_decrement(&view->references) == 1) {
static void
shutdown_view(dns_view_t *view) {
dns_zone_t *mkzone = NULL, *rdzone = NULL;
dns_zt_t *zonetable = NULL;
dns_resolver_t *resolver = NULL;
@ -478,6 +471,7 @@ dns_view_detach(dns_view_t **viewp) {
if (resolver != NULL) {
dns_resolver_detach(&resolver);
}
synchronize_rcu();
if (dispatchmgr != NULL) {
dns_dispatchmgr_detach(&dispatchmgr);
@ -499,6 +493,19 @@ dns_view_detach(dns_view_t **viewp) {
}
dns_view_weakdetach(&view);
}
void
dns_view_detach(dns_view_t **viewp) {
dns_view_t *view = NULL;
REQUIRE(viewp != NULL && DNS_VIEW_VALID(*viewp));
view = *viewp;
*viewp = NULL;
if (isc_refcount_decrement(&view->references) == 1) {
shutdown_view(view);
}
}
@ -535,25 +542,23 @@ dns_view_createresolver(dns_view_t *view, isc_nm_t *netmgr,
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);
REQUIRE(view->resolver == NULL);
REQUIRE(view->dispatchmgr != NULL);
result = dns_resolver_create(view, loopmgr, netmgr, options,
tlsctx_cache, dispatchv4, dispatchv6,
&view->resolver);
result = dns_resolver_create(view, netmgr, options, tlsctx_cache,
dispatchv4, dispatchv6, &view->resolver);
if (result != ISC_R_SUCCESS) {
return result;
}
isc_mem_create("ADB", &mctx);
dns_adb_create(mctx, loopmgr, view, &view->adb);
dns_adb_create(mctx, view, &view->adb);
isc_mem_detach(&mctx);
result = dns_requestmgr_create(view->mctx, loopmgr, view->dispatchmgr,
result = dns_requestmgr_create(view->mctx, view->dispatchmgr,
dispatchv4, dispatchv6,
&view->requestmgr);
if (result != ISC_R_SUCCESS) {
@ -1479,12 +1484,12 @@ dns_view_freezezones(dns_view_t *view, bool value) {
}
void
dns_view_initntatable(dns_view_t *view, isc_loopmgr_t *loopmgr) {
dns_view_initntatable(dns_view_t *view) {
REQUIRE(DNS_VIEW_VALID(view));
if (view->ntatable_priv != NULL) {
dns_ntatable_detach(&view->ntatable_priv);
}
dns_ntatable_create(view, loopmgr, &view->ntatable_priv);
dns_ntatable_create(view, &view->ntatable_priv);
}
isc_result_t

View File

@ -616,7 +616,6 @@ struct dns_zonemgr {
unsigned int magic;
isc_mem_t *mctx;
isc_refcount_t refs;
isc_loopmgr_t *loopmgr;
isc_nm_t *netmgr;
uint32_t workers;
isc_mem_t **mctxpool;
@ -19321,7 +19320,6 @@ void
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();
isc_loopmgr_t *loopmgr = isc_loop_getloopmgr(loop);
REQUIRE(mctx != NULL);
REQUIRE(netmgr != NULL);
@ -19330,9 +19328,8 @@ dns_zonemgr_create(isc_mem_t *mctx, isc_nm_t *netmgr, dns_zonemgr_t **zmgrp) {
zmgr = isc_mem_get(mctx, sizeof(*zmgr));
*zmgr = (dns_zonemgr_t){
.loopmgr = loopmgr,
.netmgr = netmgr,
.workers = isc_loopmgr_nloops(loopmgr),
.workers = isc_loopmgr_nloops(),
.transfersin = 10,
.transfersperns = 2,
};
@ -19414,7 +19411,7 @@ dns_zonemgr_managezone(dns_zonemgr_t *zmgr, dns_zone_t *zone) {
REQUIRE(zone->timer == NULL);
REQUIRE(zone->zmgr == NULL);
isc_loop_t *loop = isc_loop_get(zmgr->loopmgr, zone->tid);
isc_loop_t *loop = isc_loop_get(zone->tid);
isc_loop_attach(loop, &zone->loop);
zonemgr_keymgmt_add(zmgr, zone, &zone->kfio);

View File

@ -41,8 +41,7 @@ isc_helper_run(isc_loop_t *loop, isc_job_cb cb, void *cbarg) {
REQUIRE(VALID_LOOP(loop));
REQUIRE(cb != NULL);
isc_loop_t *helper = &loop->loopmgr->helpers[loop->tid];
isc_loop_t *helper = isc_loop_helper(loop);
isc_job_t *job = isc_mem_get(helper->mctx, sizeof(*job));
*job = (isc_job_t){
.cb = cb,

View File

@ -15,6 +15,9 @@
#include <inttypes.h>
#include <urcu/compiler.h>
#include <urcu/system.h>
#include <isc/job.h>
#include <isc/mem.h>
#include <isc/refcount.h>
@ -34,8 +37,9 @@ 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);
isc_loopmgr_create(isc_mem_t *mctx, uint32_t nloops);
/*%<
* Create a loop manager supporting 'nloops' loops.
*
@ -44,65 +48,63 @@ isc_loopmgr_create(isc_mem_t *mctx, uint32_t nloops, isc_loopmgr_t **loopmgrp);
*/
void
isc_loopmgr_destroy(isc_loopmgr_t **loopmgrp);
isc_loopmgr_destroy(void);
/*%<
* Destroy the loop manager pointed to by 'loopmgrp'.
*
* Requires:
*\li 'loopmgr' points to a valid loop manager.
* Destroy the loop manager.
*/
void
isc_loopmgr_shutdown(isc_loopmgr_t *loopmgr);
isc_loopmgr_shutdown(void);
/*%<
* Request shutdown of the loop manager 'loopmgr'.
* Request shutdown of the loop manager.
*
* This will stop all signal handlers and send shutdown events to
* all active loops. As a final action on shutting down, each loop
* will run the function (or functions) set by isc_loopmgr_teardown()
* or isc_loop_teardown().
*
* Requires:
*\li 'loopmgr' is a valid loop manager.
*/
void
isc_loopmgr_run(isc_loopmgr_t *loopmgr);
isc_loopmgr_run(void);
/*%<
* Run the loops in 'loopmgr'. Each loop will start by running the
* Run the loops in loop manager. Each loop will start by running the
* function (or functions) set by isc_loopmgr_setup() or isc_loop_setup().
*
* Requires:
*\li 'loopmgr' is a valid loop manager.
*/
void
isc_loopmgr_pause(isc_loopmgr_t *loopmgr);
isc_loopmgr_pause(void);
/*%<
* Send pause events to all running loops in 'loopmgr' except the
* Send pause events to all running loops in loop manager except the
* current one. This can only be called from a running loop.
* All the paused loops will wait until isc_loopmgr_resume() is
* run in the calling loop before continuing.
*
* Requires:
*\li 'loopmgr' is a valid loop manager.
*\li We are in a running loop.
*/
bool
isc_loopmgr_paused(void);
/*%<
* Returns true if the loopmgr has been paused and not yet resumed.
*
* Requires:
*\li We are in a running loop.
*/
void
isc_loopmgr_resume(isc_loopmgr_t *loopmgr);
isc_loopmgr_resume(void);
/*%<
* Send resume events to all paused loops in 'loopmgr'. This can
* Send resume events to all paused loops in loop manager. This can
* only be called by a running loop (which must therefore be the
* loop that called isc_loopmgr_pause()).
*
* Requires:
*\li 'loopmgr' is a valid loop manager.
*\li We are in a running loop.
*/
uint32_t
isc_loopmgr_nloops(isc_loopmgr_t *loopmgr);
isc_loopmgr_nloops(void);
isc_job_t *
isc_loop_setup(isc_loop_t *loop, isc_job_cb cb, void *cbarg);
@ -119,9 +121,9 @@ isc_loop_teardown(isc_loop_t *loop, isc_job_cb cb, void *cbarg);
*/
void
isc_loopmgr_setup(isc_loopmgr_t *loopmgr, isc_job_cb cb, void *cbarg);
isc_loopmgr_setup(isc_job_cb cb, void *cbarg);
void
isc_loopmgr_teardown(isc_loopmgr_t *loopmgr, isc_job_cb cb, void *cbarg);
isc_loopmgr_teardown(isc_job_cb cb, void *cbarg);
/*%<
* Schedule actions to be run when starting, and when shutting down,
* *all* of the loops in loopmgr.
@ -130,8 +132,7 @@ isc_loopmgr_teardown(isc_loopmgr_t *loopmgr, isc_job_cb cb, void *cbarg);
* isc_loop_teardown() on each of the loops in turn.
*
* Requires:
*\li 'loopmgr' is a valid loop manager.
*\li 'loopmgr' is paused or has not yet been started.
*\li loopmgr is paused or has not yet been started.
*/
isc_mem_t *
@ -145,27 +146,21 @@ isc_loop_getmctx(isc_loop_t *loop);
*/
isc_loop_t *
isc_loop_main(isc_loopmgr_t *loopmgr);
isc_loop_main(void);
/*%<
* Returns the main loop for the 'loopmgr' (which is 'loopmgr->loops[0]',
* Returns the main loop for the loop manager (which is 'loops[0]',
* regardless of how many loops there are).
*
* Requires:
*\li 'loopmgr' is a valid loop manager.
*/
isc_loop_t *
isc_loop_get(isc_loopmgr_t *loopmgr, isc_tid_t tid);
isc_loop_get(isc_tid_t tid);
/*%<
* Return the loop object associated with the 'tid' threadid
*
* Requires:
*\li 'loopmgr' is a valid loop manager.
*\li 'tid' is smaller than number of initialized loops
*/
#
#if ISC_LOOP_TRACE
#define isc_loop_ref(ptr) isc_loop__ref(ptr, __func__, __FILE__, __LINE__)
#define isc_loop_unref(ptr) isc_loop__unref(ptr, __func__, __FILE__, __LINE__)
@ -182,25 +177,13 @@ ISC_REFCOUNT_DECL(isc_loop);
*/
void
isc_loopmgr_blocking(isc_loopmgr_t *loopmgr);
isc_loopmgr_blocking(void);
void
isc_loopmgr_nonblocking(isc_loopmgr_t *loopmgr);
isc_loopmgr_nonblocking(void);
/*%<
* isc_loopmgr_blocking() stops the SIGINT and SIGTERM signal handlers
* during blocking operations, for example while waiting for user
* interaction; isc_loopmgr_nonblocking() restarts them.
*
* Requires:
*\li 'loopmgr' is a valid loop manager.
*/
isc_loopmgr_t *
isc_loop_getloopmgr(isc_loop_t *loop);
/*%<
* Return the loopmgr associated with 'loop'.
*
* Requires:
*\li 'loop' is a valid loop.
*/
isc_time_t
@ -222,3 +205,13 @@ isc_loop_shuttingdown(isc_loop_t *loop);
*
* \li 'loop' is a valid loop and the loop tid matches the current tid.
*/
isc_loop_t *
isc_loop_helper(isc_loop_t *loop);
/*%<
* Returns the helper thread corresponding to the thread ID for 'loop'.
*
* Requires:
*
* \li 'loop' is a valid loop.
*/

View File

@ -13,7 +13,6 @@
#pragma once
#include <isc/loop.h>
#include <isc/netmgr.h>
#include <isc/result.h>
#include <isc/timer.h>
@ -21,9 +20,7 @@
typedef struct isc_managers isc_managers_t;
void
isc_managers_create(isc_mem_t **mctx, uint32_t workers,
isc_loopmgr_t **loopmgrp, isc_nm_t **netmgrp);
isc_managers_create(isc_mem_t **mctx, uint32_t workers, isc_nm_t **netmgrp);
void
isc_managers_destroy(isc_mem_t **mctx, isc_loopmgr_t **loopmgrp,
isc_nm_t **netmgrp);
isc_managers_destroy(isc_mem_t **mctx, isc_nm_t **netmgrp);

View File

@ -118,7 +118,7 @@ typedef enum isc_nm_proxy_type {
*/
void
isc_netmgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t **netgmrp);
isc_netmgr_create(isc_mem_t *mctx, isc_nm_t **netgmrp);
/*%<
* Creates a new network manager and starts it running when loopmgr is started.
*/

View File

@ -20,8 +20,7 @@
typedef void (*isc_signal_cb)(void *, int);
isc_signal_t *
isc_signal_new(isc_loopmgr_t *loopmgr, isc_signal_cb cb, void *cbarg,
int signum);
isc_signal_new(isc_signal_cb cb, void *cbarg, int signum);
/*%<
* Create a new signal handler for loop manager 'loopmgr', handling
* the signal value 'signum'.

View File

@ -50,7 +50,6 @@ typedef struct isc_interface isc_interface_t; /*%< Interface */
typedef struct isc_interfaceiter isc_interfaceiter_t; /*%< Interface Iterator */
typedef struct isc_lex isc_lex_t; /*%< Lex */
typedef struct isc_loop isc_loop_t; /*%< Event loop */
typedef struct isc_loopmgr isc_loopmgr_t; /*%< Event loop manager */
typedef struct isc_mem isc_mem_t; /*%< Memory */
typedef struct isc_mempool isc_mempool_t; /*%< Memory Pool */
typedef struct isc_netaddr isc_netaddr_t; /*%< Net Address */

View File

@ -15,6 +15,8 @@
#include <sys/types.h>
#include <unistd.h>
#include <urcu/system.h>
#include <isc/async.h>
#include <isc/atomic.h>
#include <isc/barrier.h>
@ -47,6 +49,7 @@
*/
thread_local isc_loop_t *isc__loop_local = NULL;
isc_loopmgr_t *isc__loopmgr = NULL;
static void
ignore_signal(int sig, void (*handler)(int)) {
@ -58,7 +61,8 @@ ignore_signal(int sig, void (*handler)(int)) {
}
void
isc_loopmgr_shutdown(isc_loopmgr_t *loopmgr) {
isc_loopmgr_shutdown(void) {
isc_loopmgr_t *loopmgr = isc__loopmgr;
if (!atomic_compare_exchange_strong(&loopmgr->shuttingdown,
&(bool){ false }, true))
{
@ -75,13 +79,11 @@ isc_loopmgr_shutdown(isc_loopmgr_t *loopmgr) {
}
static void
isc__loopmgr_signal(void *arg, int signum) {
isc_loopmgr_t *loopmgr = (isc_loopmgr_t *)arg;
isc__loopmgr_signal(void *arg ISC_ATTR_UNUSED, int signum) {
switch (signum) {
case SIGINT:
case SIGTERM:
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
break;
default:
UNREACHABLE();
@ -90,7 +92,7 @@ isc__loopmgr_signal(void *arg, int signum) {
static void
pause_loop(isc_loop_t *loop) {
isc_loopmgr_t *loopmgr = loop->loopmgr;
isc_loopmgr_t *loopmgr = isc__loopmgr;
rcu_thread_offline();
@ -100,7 +102,7 @@ pause_loop(isc_loop_t *loop) {
static void
resume_loop(isc_loop_t *loop) {
isc_loopmgr_t *loopmgr = loop->loopmgr;
isc_loopmgr_t *loopmgr = isc__loopmgr;
(void)isc_barrier_wait(&loopmgr->resuming);
loop->paused = false;
@ -160,7 +162,7 @@ destroy_cb(uv_async_t *handle) {
static void
shutdown_cb(uv_async_t *handle) {
isc_loop_t *loop = uv_handle_get_data(handle);
isc_loopmgr_t *loopmgr = loop->loopmgr;
isc_loopmgr_t *loopmgr = isc__loopmgr;
/* Make sure, we can't be called again */
uv_close(&loop->shutdown_trigger, shutdown_trigger_close_cb);
@ -187,11 +189,9 @@ shutdown_cb(uv_async_t *handle) {
}
static void
loop_init(isc_loop_t *loop, isc_loopmgr_t *loopmgr, isc_tid_t tid,
const char *kind) {
loop_init(isc_loop_t *loop, isc_tid_t tid, const char *kind) {
*loop = (isc_loop_t){
.tid = tid,
.loopmgr = loopmgr,
.run_jobs = ISC_LIST_INITIALIZER,
};
@ -278,7 +278,7 @@ helper_thread(void *arg) {
int r = uv_prepare_start(&helper->quiescent, quiescent_cb);
UV_RUNTIME_CHECK(uv_prepare_start, r);
isc_barrier_wait(&helper->loopmgr->starting);
isc_barrier_wait(&isc__loopmgr->starting);
r = uv_run(&helper->loop, UV_RUN_DEFAULT);
UV_RUNTIME_CHECK(uv_run, r);
@ -286,7 +286,7 @@ helper_thread(void *arg) {
/* Invalidate the helper early */
helper->magic = 0;
isc_barrier_wait(&helper->loopmgr->stopping);
isc_barrier_wait(&isc__loopmgr->stopping);
return NULL;
}
@ -294,7 +294,7 @@ helper_thread(void *arg) {
static void *
loop_thread(void *arg) {
isc_loop_t *loop = (isc_loop_t *)arg;
isc_loopmgr_t *loopmgr = loop->loopmgr;
isc_loopmgr_t *loopmgr = isc__loopmgr;
isc_loop_t *helper = &loopmgr->helpers[loop->tid];
char name[32];
/* Initialize the thread_local variables*/
@ -367,18 +367,19 @@ ISC_REFCOUNT_IMPL(isc_loop, loop_destroy);
#endif
void
isc_loopmgr_create(isc_mem_t *mctx, uint32_t nloops, isc_loopmgr_t **loopmgrp) {
isc_loopmgr_t *loopmgr = NULL;
REQUIRE(loopmgrp != NULL && *loopmgrp == NULL);
isc_loopmgr_create(isc_mem_t *mctx, uint32_t nloops) {
REQUIRE(isc__loopmgr == NULL);
REQUIRE(nloops > 0);
isc_loopmgr_t *loopmgr = NULL;
threadpool_initialize(nloops);
isc__tid_initcount(nloops);
loopmgr = isc_mem_get(mctx, sizeof(*loopmgr));
*loopmgr = (isc_loopmgr_t){
.nloops = nloops,
.magic = LOOPMGR_MAGIC,
};
isc_mem_attach(mctx, &loopmgr->mctx);
@ -393,27 +394,24 @@ isc_loopmgr_create(isc_mem_t *mctx, uint32_t nloops, isc_loopmgr_t **loopmgrp) {
sizeof(loopmgr->loops[0]));
for (size_t i = 0; i < loopmgr->nloops; i++) {
isc_loop_t *loop = &loopmgr->loops[i];
loop_init(loop, loopmgr, i, "loop");
loop_init(loop, i, "loop");
}
loopmgr->helpers = isc_mem_cget(loopmgr->mctx, loopmgr->nloops,
sizeof(loopmgr->helpers[0]));
for (size_t i = 0; i < loopmgr->nloops; i++) {
isc_loop_t *loop = &loopmgr->helpers[i];
loop_init(loop, loopmgr, i, "helper");
loop_init(loop, i, "helper");
}
loopmgr->sigint = isc_signal_new(loopmgr, isc__loopmgr_signal, loopmgr,
SIGINT);
loopmgr->sigterm = isc_signal_new(loopmgr, isc__loopmgr_signal, loopmgr,
isc__loopmgr = loopmgr;
loopmgr->sigint = isc_signal_new(isc__loopmgr_signal, loopmgr, SIGINT);
loopmgr->sigterm = isc_signal_new(isc__loopmgr_signal, loopmgr,
SIGTERM);
isc_signal_start(loopmgr->sigint);
isc_signal_start(loopmgr->sigterm);
loopmgr->magic = LOOPMGR_MAGIC;
*loopmgrp = loopmgr;
}
isc_job_t *
@ -421,7 +419,7 @@ isc_loop_setup(isc_loop_t *loop, isc_job_cb cb, void *cbarg) {
REQUIRE(VALID_LOOP(loop));
REQUIRE(cb != NULL);
isc_loopmgr_t *loopmgr = loop->loopmgr;
isc_loopmgr_t *loopmgr = isc__loopmgr;
isc_job_t *job = isc_mem_get(loop->mctx, sizeof(*job));
*job = (isc_job_t){
.cb = cb,
@ -443,7 +441,7 @@ isc_job_t *
isc_loop_teardown(isc_loop_t *loop, isc_job_cb cb, void *cbarg) {
REQUIRE(VALID_LOOP(loop));
isc_loopmgr_t *loopmgr = loop->loopmgr;
isc_loopmgr_t *loopmgr = isc__loopmgr;
isc_job_t *job = isc_mem_get(loop->mctx, sizeof(*job));
*job = (isc_job_t){
.cb = cb,
@ -461,33 +459,33 @@ isc_loop_teardown(isc_loop_t *loop, isc_job_cb cb, void *cbarg) {
}
void
isc_loopmgr_setup(isc_loopmgr_t *loopmgr, isc_job_cb cb, void *cbarg) {
REQUIRE(VALID_LOOPMGR(loopmgr));
REQUIRE(!atomic_load(&loopmgr->running) ||
atomic_load(&loopmgr->paused));
isc_loopmgr_setup(isc_job_cb cb, void *cbarg) {
REQUIRE(VALID_LOOPMGR(isc__loopmgr));
REQUIRE(!atomic_load(&isc__loopmgr->running) ||
atomic_load(&isc__loopmgr->paused));
for (size_t i = 0; i < loopmgr->nloops; i++) {
isc_loop_t *loop = &loopmgr->loops[i];
for (size_t i = 0; i < isc__loopmgr->nloops; i++) {
isc_loop_t *loop = &isc__loopmgr->loops[i];
(void)isc_loop_setup(loop, cb, cbarg);
}
}
void
isc_loopmgr_teardown(isc_loopmgr_t *loopmgr, isc_job_cb cb, void *cbarg) {
REQUIRE(VALID_LOOPMGR(loopmgr));
REQUIRE(!atomic_load(&loopmgr->running) ||
atomic_load(&loopmgr->paused));
isc_loopmgr_teardown(isc_job_cb cb, void *cbarg) {
REQUIRE(VALID_LOOPMGR(isc__loopmgr));
REQUIRE(!atomic_load(&isc__loopmgr->running) ||
atomic_load(&isc__loopmgr->paused));
for (size_t i = 0; i < loopmgr->nloops; i++) {
isc_loop_t *loop = &loopmgr->loops[i];
for (size_t i = 0; i < isc__loopmgr->nloops; i++) {
isc_loop_t *loop = &isc__loopmgr->loops[i];
(void)isc_loop_teardown(loop, cb, cbarg);
}
}
void
isc_loopmgr_run(isc_loopmgr_t *loopmgr) {
REQUIRE(VALID_LOOPMGR(loopmgr));
RUNTIME_CHECK(atomic_compare_exchange_strong(&loopmgr->running,
isc_loopmgr_run(void) {
REQUIRE(VALID_LOOPMGR(isc__loopmgr));
RUNTIME_CHECK(atomic_compare_exchange_strong(&isc__loopmgr->running,
&(bool){ false }, true));
/*
@ -500,9 +498,9 @@ isc_loopmgr_run(isc_loopmgr_t *loopmgr) {
/*
* The thread 0 is this one.
*/
for (size_t i = 1; i < loopmgr->nloops; i++) {
for (size_t i = 1; i < isc__loopmgr->nloops; i++) {
char name[32];
isc_loop_t *loop = &loopmgr->loops[i];
isc_loop_t *loop = &isc__loopmgr->loops[i];
isc_thread_create(loop_thread, loop, &loop->thread);
@ -510,12 +508,12 @@ isc_loopmgr_run(isc_loopmgr_t *loopmgr) {
isc_thread_setname(loop->thread, name);
}
isc_thread_main(loop_thread, &loopmgr->loops[0]);
isc_thread_main(loop_thread, &isc__loopmgr->loops[0]);
}
void
isc_loopmgr_pause(isc_loopmgr_t *loopmgr) {
REQUIRE(VALID_LOOPMGR(loopmgr));
isc_loopmgr_pause(void) {
REQUIRE(VALID_LOOPMGR(isc__loopmgr));
REQUIRE(isc_tid() != ISC_TID_UNKNOWN);
if (isc_log_wouldlog(ISC_LOG_DEBUG(1))) {
@ -524,15 +522,15 @@ isc_loopmgr_pause(isc_loopmgr_t *loopmgr) {
"loop exclusive mode: starting");
}
for (size_t i = 0; i < loopmgr->nloops; i++) {
isc_loop_t *helper = &loopmgr->helpers[i];
for (size_t i = 0; i < isc__loopmgr->nloops; i++) {
isc_loop_t *helper = &isc__loopmgr->helpers[i];
int r = uv_async_send(&helper->pause_trigger);
UV_RUNTIME_CHECK(uv_async_send, r);
}
for (size_t i = 0; i < loopmgr->nloops; i++) {
isc_loop_t *loop = &loopmgr->loops[i];
for (size_t i = 0; i < isc__loopmgr->nloops; i++) {
isc_loop_t *loop = &isc__loopmgr->loops[i];
/* Skip current loop */
if (i == (size_t)isc_tid()) {
@ -543,9 +541,9 @@ isc_loopmgr_pause(isc_loopmgr_t *loopmgr) {
UV_RUNTIME_CHECK(uv_async_send, r);
}
RUNTIME_CHECK(atomic_compare_exchange_strong(&loopmgr->paused,
RUNTIME_CHECK(atomic_compare_exchange_strong(&isc__loopmgr->paused,
&(bool){ false }, true));
pause_loop(CURRENT_LOOP(loopmgr));
pause_loop(CURRENT_LOOP(isc__loopmgr));
if (isc_log_wouldlog(ISC_LOG_DEBUG(1))) {
isc_log_write(ISC_LOGCATEGORY_GENERAL, ISC_LOGMODULE_OTHER,
@ -554,17 +552,17 @@ isc_loopmgr_pause(isc_loopmgr_t *loopmgr) {
}
void
isc_loopmgr_resume(isc_loopmgr_t *loopmgr) {
REQUIRE(VALID_LOOPMGR(loopmgr));
isc_loopmgr_resume(void) {
REQUIRE(VALID_LOOPMGR(isc__loopmgr));
if (isc_log_wouldlog(ISC_LOG_DEBUG(1))) {
isc_log_write(ISC_LOGCATEGORY_GENERAL, ISC_LOGMODULE_OTHER,
ISC_LOG_DEBUG(1), "loop exclusive mode: ending");
}
RUNTIME_CHECK(atomic_compare_exchange_strong(&loopmgr->paused,
RUNTIME_CHECK(atomic_compare_exchange_strong(&isc__loopmgr->paused,
&(bool){ true }, false));
resume_loop(CURRENT_LOOP(loopmgr));
resume_loop(CURRENT_LOOP(isc__loopmgr));
if (isc_log_wouldlog(ISC_LOG_DEBUG(1))) {
isc_log_write(ISC_LOGCATEGORY_GENERAL, ISC_LOGMODULE_OTHER,
@ -572,19 +570,22 @@ isc_loopmgr_resume(isc_loopmgr_t *loopmgr) {
}
}
bool
isc_loopmgr_paused(void) {
REQUIRE(VALID_LOOPMGR(isc__loopmgr));
return atomic_load(&isc__loopmgr->paused);
}
void
isc_loopmgr_destroy(isc_loopmgr_t **loopmgrp) {
isc_loopmgr_t *loopmgr = NULL;
REQUIRE(loopmgrp != NULL);
REQUIRE(VALID_LOOPMGR(*loopmgrp));
loopmgr = *loopmgrp;
*loopmgrp = NULL;
isc_loopmgr_destroy(void) {
isc_loopmgr_t *loopmgr = isc__loopmgr;
RUNTIME_CHECK(atomic_compare_exchange_strong(&loopmgr->running,
&(bool){ true }, false));
isc__loopmgr = NULL;
/* Wait for all helpers to finish */
for (size_t i = 0; i < loopmgr->nloops; i++) {
isc_loop_t *helper = &loopmgr->helpers[i];
@ -624,10 +625,10 @@ isc_loopmgr_destroy(isc_loopmgr_t **loopmgrp) {
}
uint32_t
isc_loopmgr_nloops(isc_loopmgr_t *loopmgr) {
REQUIRE(VALID_LOOPMGR(loopmgr));
isc_loopmgr_nloops(void) {
REQUIRE(VALID_LOOPMGR(isc__loopmgr));
return loopmgr->nloops;
return isc__loopmgr->nloops;
}
isc_mem_t *
@ -638,41 +639,34 @@ isc_loop_getmctx(isc_loop_t *loop) {
}
isc_loop_t *
isc_loop_main(isc_loopmgr_t *loopmgr) {
REQUIRE(VALID_LOOPMGR(loopmgr));
isc_loop_main(void) {
REQUIRE(VALID_LOOPMGR(isc__loopmgr));
return DEFAULT_LOOP(loopmgr);
return DEFAULT_LOOP(isc__loopmgr);
}
isc_loop_t *
isc_loop_get(isc_loopmgr_t *loopmgr, isc_tid_t tid) {
REQUIRE(VALID_LOOPMGR(loopmgr));
REQUIRE((uint32_t)tid < loopmgr->nloops);
isc_loop_get(isc_tid_t tid) {
REQUIRE(VALID_LOOPMGR(isc__loopmgr));
REQUIRE((uint32_t)tid < isc__loopmgr->nloops);
return LOOP(loopmgr, tid);
return LOOP(isc__loopmgr, tid);
}
void
isc_loopmgr_blocking(isc_loopmgr_t *loopmgr) {
REQUIRE(VALID_LOOPMGR(loopmgr));
isc_loopmgr_blocking(void) {
REQUIRE(VALID_LOOPMGR(isc__loopmgr));
isc_signal_stop(loopmgr->sigterm);
isc_signal_stop(loopmgr->sigint);
isc_signal_stop(isc__loopmgr->sigterm);
isc_signal_stop(isc__loopmgr->sigint);
}
void
isc_loopmgr_nonblocking(isc_loopmgr_t *loopmgr) {
REQUIRE(VALID_LOOPMGR(loopmgr));
isc_loopmgr_nonblocking(void) {
REQUIRE(VALID_LOOPMGR(isc__loopmgr));
isc_signal_start(loopmgr->sigint);
isc_signal_start(loopmgr->sigterm);
}
isc_loopmgr_t *
isc_loop_getloopmgr(isc_loop_t *loop) {
REQUIRE(VALID_LOOP(loop));
return loop->loopmgr;
isc_signal_start(isc__loopmgr->sigint);
isc_signal_start(isc__loopmgr->sigterm);
}
isc_time_t
@ -695,3 +689,10 @@ isc_loop_shuttingdown(isc_loop_t *loop) {
return loop->shuttingdown;
}
isc_loop_t *
isc_loop_helper(isc_loop_t *loop) {
REQUIRE(VALID_LOOP(loop));
return &isc__loopmgr->helpers[loop->tid];
}

View File

@ -43,8 +43,6 @@ struct isc_loop {
isc_refcount_t references;
isc_thread_t thread;
isc_loopmgr_t *loopmgr;
uv_loop_t loop;
isc_tid_t tid;
@ -83,7 +81,7 @@ struct isc_loop {
#define LOOPMGR_MAGIC ISC_MAGIC('L', 'o', 'o', 'M')
#define VALID_LOOPMGR(t) ISC_MAGIC_VALID(t, LOOPMGR_MAGIC)
struct isc_loopmgr {
typedef struct isc_loopmgr {
int magic;
isc_mem_t *mctx;
@ -110,7 +108,7 @@ struct isc_loopmgr {
/* per-thread objects */
isc_loop_t *loops;
isc_loop_t *helpers;
};
} isc_loopmgr_t;
/*
* Signal Handler

View File

@ -11,34 +11,30 @@
* information regarding copyright ownership.
*/
#include <isc/loop.h>
#include <isc/managers.h>
#include <isc/rwlock.h>
#include <isc/util.h>
#include <isc/uv.h>
void
isc_managers_create(isc_mem_t **mctxp, uint32_t workers,
isc_loopmgr_t **loopmgrp, isc_nm_t **netmgrp) {
isc_managers_create(isc_mem_t **mctxp, uint32_t workers, isc_nm_t **netmgrp) {
REQUIRE(mctxp != NULL && *mctxp == NULL);
isc_mem_create("managers", mctxp);
INSIST(*mctxp != NULL);
REQUIRE(loopmgrp != NULL && *loopmgrp == NULL);
isc_loopmgr_create(*mctxp, workers, loopmgrp);
INSIST(*loopmgrp != NULL);
isc_loopmgr_create(*mctxp, workers);
REQUIRE(netmgrp != NULL && *netmgrp == NULL);
isc_netmgr_create(*mctxp, *loopmgrp, netmgrp);
isc_netmgr_create(*mctxp, netmgrp);
INSIST(*netmgrp != NULL);
isc_rwlock_setworkers(workers);
}
void
isc_managers_destroy(isc_mem_t **mctxp, isc_loopmgr_t **loopmgrp,
isc_nm_t **netmgrp) {
isc_managers_destroy(isc_mem_t **mctxp, isc_nm_t **netmgrp) {
REQUIRE(mctxp != NULL && *mctxp != NULL);
REQUIRE(loopmgrp != NULL && *loopmgrp != NULL);
REQUIRE(netmgrp != NULL && *netmgrp != NULL);
/*
@ -46,6 +42,6 @@ isc_managers_destroy(isc_mem_t **mctxp, isc_loopmgr_t **loopmgrp,
*/
isc_nm_detach(netmgrp);
isc_loopmgr_destroy(loopmgrp);
isc_loopmgr_destroy();
isc_mem_detach(mctxp);
}

View File

@ -3403,17 +3403,13 @@ http_set_endpoints_cb(void *arg) {
void
isc_nm_http_set_endpoints(isc_nmsocket_t *listener,
isc_nm_http_endpoints_t *eps) {
isc_loopmgr_t *loopmgr = NULL;
REQUIRE(VALID_NMSOCK(listener));
REQUIRE(listener->type == isc_nm_httplistener);
REQUIRE(VALID_HTTP_ENDPOINTS(eps));
loopmgr = listener->worker->netmgr->loopmgr;
atomic_store(&eps->in_use, true);
for (size_t i = 0; i < isc_loopmgr_nloops(loopmgr); i++) {
for (size_t i = 0; i < isc_loopmgr_nloops(); i++) {
isc__networker_t *worker =
&listener->worker->netmgr->workers[i];
http_endpoints_data_t *data = isc_mem_cget(worker->loop->mctx,
@ -3430,14 +3426,12 @@ static void
http_init_listener_endpoints(isc_nmsocket_t *listener,
isc_nm_http_endpoints_t *epset) {
size_t nworkers;
isc_loopmgr_t *loopmgr = NULL;
REQUIRE(VALID_NMSOCK(listener));
REQUIRE(listener->worker != NULL && VALID_NM(listener->worker->netmgr));
REQUIRE(VALID_HTTP_ENDPOINTS(epset));
loopmgr = listener->worker->netmgr->loopmgr;
nworkers = (size_t)isc_loopmgr_nloops(loopmgr);
nworkers = (size_t)isc_loopmgr_nloops();
INSIST(nworkers > 0);
listener->h2->listener_endpoints =

View File

@ -330,7 +330,6 @@ struct isc_nm {
int magic;
isc_refcount_t references;
isc_mem_t *mctx;
isc_loopmgr_t *loopmgr;
uint32_t nloops;
isc__networker_t *workers;

View File

@ -153,7 +153,7 @@ netmgr_teardown(void *arg) {
#endif
void
isc_netmgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t **netmgrp) {
isc_netmgr_create(isc_mem_t *mctx, isc_nm_t **netmgrp) {
isc_nm_t *netmgr = NULL;
#ifdef MAXIMAL_UV_VERSION
@ -174,8 +174,7 @@ isc_netmgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t **netmgrp) {
netmgr = isc_mem_get(mctx, sizeof(*netmgr));
*netmgr = (isc_nm_t){
.loopmgr = loopmgr,
.nloops = isc_loopmgr_nloops(loopmgr),
.nloops = isc_loopmgr_nloops(),
};
isc_mem_attach(mctx, &netmgr->mctx);
@ -205,12 +204,12 @@ isc_netmgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t **netmgrp) {
netmgr->workers = isc_mem_cget(mctx, netmgr->nloops,
sizeof(netmgr->workers[0]));
isc_loopmgr_teardown(loopmgr, netmgr_teardown, netmgr);
isc_loopmgr_teardown(netmgr_teardown, netmgr);
netmgr->magic = NM_MAGIC;
for (size_t i = 0; i < netmgr->nloops; i++) {
isc_loop_t *loop = isc_loop_get(netmgr->loopmgr, i);
isc_loop_t *loop = isc_loop_get(i);
isc__networker_t *worker = &netmgr->workers[i];
*worker = (isc__networker_t){
@ -2541,8 +2540,7 @@ settlsctx_cb(void *arg) {
static void
set_tlsctx_workers(isc_nmsocket_t *listener, isc_tlsctx_t *tlsctx) {
const size_t nworkers =
(size_t)isc_loopmgr_nloops(listener->worker->netmgr->loopmgr);
const size_t nworkers = (size_t)isc_loopmgr_nloops();
/* Update the TLS context reference for every worker thread. */
for (size_t i = 0; i < nworkers; i++) {
isc__networker_t *worker =

View File

@ -1516,8 +1516,7 @@ tls_init_listener_tlsctx(isc_nmsocket_t *listener, isc_tlsctx_t *ctx) {
REQUIRE(VALID_NMSOCK(listener));
REQUIRE(ctx != NULL);
nworkers =
(size_t)isc_loopmgr_nloops(listener->worker->netmgr->loopmgr);
nworkers = (size_t)isc_loopmgr_nloops();
INSIST(nworkers > 0);
listener->tlsstream.listener_tls_ctx = isc_mem_cget(

View File

@ -20,15 +20,12 @@
#include "loop_p.h"
isc_signal_t *
isc_signal_new(isc_loopmgr_t *loopmgr, isc_signal_cb cb, void *cbarg,
int signum) {
isc_loop_t *loop = NULL;
isc_signal_t *signal = NULL;
isc_signal_new(isc_signal_cb cb, void *cbarg, int signum) {
int r;
isc_loop_t *loop = isc_loop_main();
isc_signal_t *signal = isc_mem_get(isc_loop_getmctx(loop),
sizeof(*signal));
loop = DEFAULT_LOOP(loopmgr);
signal = isc_mem_get(isc_loop_getmctx(loop), sizeof(*signal));
*signal = (isc_signal_t){
.magic = SIGNAL_MAGIC,
.cb = cb,

View File

@ -51,16 +51,11 @@ isc_timer_create(isc_loop_t *loop, isc_job_cb cb, void *cbarg,
isc_timer_t **timerp) {
int r;
isc_timer_t *timer;
isc_loopmgr_t *loopmgr = NULL;
REQUIRE(cb != NULL);
REQUIRE(timerp != NULL && *timerp == NULL);
REQUIRE(VALID_LOOP(loop));
loopmgr = loop->loopmgr;
REQUIRE(VALID_LOOPMGR(loopmgr));
REQUIRE(loop == isc_loop());
timer = isc_mem_get(loop->mctx, sizeof(*timer));
@ -113,7 +108,6 @@ timer_cb(uv_timer_t *handle) {
void
isc_timer_start(isc_timer_t *timer, isc_timertype_t type,
const isc_interval_t *interval) {
isc_loopmgr_t *loopmgr = NULL;
isc_loop_t *loop = NULL;
int r;
@ -125,10 +119,6 @@ isc_timer_start(isc_timer_t *timer, isc_timertype_t type,
REQUIRE(VALID_LOOP(loop));
loopmgr = loop->loopmgr;
REQUIRE(VALID_LOOPMGR(loopmgr));
switch (type) {
case isc_timertype_once:
timer->timeout = isc_interval_ms(interval);

View File

@ -2661,8 +2661,7 @@ clientmgr_destroy(ns_clientmgr_t *mgr) {
ISC_REFCOUNT_IMPL(ns_clientmgr, clientmgr_destroy);
isc_result_t
ns_clientmgr_create(ns_server_t *sctx, isc_loopmgr_t *loopmgr,
dns_aclenv_t *aclenv, isc_tid_t tid,
ns_clientmgr_create(ns_server_t *sctx, dns_aclenv_t *aclenv, isc_tid_t tid,
ns_clientmgr_t **managerp) {
ns_clientmgr_t *manager = NULL;
isc_mem_t *mctx = NULL;
@ -2676,7 +2675,7 @@ ns_clientmgr_create(ns_server_t *sctx, isc_loopmgr_t *loopmgr,
.tid = tid,
.recursing = ISC_LIST_INITIALIZER,
};
isc_loop_attach(isc_loop_get(loopmgr, tid), &manager->loop);
isc_loop_attach(isc_loop_get(tid), &manager->loop);
isc_mutex_init(&manager->reclock);
dns_aclenv_attach(aclenv, &manager->aclenv);
isc_refcount_init(&manager->references, 1);

View File

@ -336,8 +336,7 @@ ns_client_settimeout(ns_client_t *client, unsigned int seconds);
*/
isc_result_t
ns_clientmgr_create(ns_server_t *sctx, isc_loopmgr_t *loopmgr,
dns_aclenv_t *aclenv, isc_tid_t tid,
ns_clientmgr_create(ns_server_t *sctx, dns_aclenv_t *aclenv, isc_tid_t tid,
ns_clientmgr_t **managerp);
/*%<
* Create a client manager.

View File

@ -98,8 +98,7 @@ struct ns_interface {
***/
isc_result_t
ns_interfacemgr_create(isc_mem_t *mctx, ns_server_t *sctx,
isc_loopmgr_t *loopmgr, isc_nm_t *nm,
ns_interfacemgr_create(isc_mem_t *mctx, ns_server_t *sctx, isc_nm_t *nm,
dns_dispatchmgr_t *dispatchmgr,
dns_geoip_databases_t *geoip, ns_interfacemgr_t **mgrp);
/*%<

View File

@ -65,7 +65,6 @@ struct ns_interfacemgr {
isc_mutex_t lock;
isc_mem_t *mctx; /*%< Memory context */
ns_server_t *sctx; /*%< Server context */
isc_loopmgr_t *loopmgr; /*%< Loop manager */
isc_nm_t *nm; /*%< Net manager */
uint32_t ncpus; /*%< Number of workers */
dns_dispatchmgr_t *dispatchmgr;
@ -267,8 +266,7 @@ route_connected(isc_nmhandle_t *handle, isc_result_t eresult, void *arg) {
}
isc_result_t
ns_interfacemgr_create(isc_mem_t *mctx, ns_server_t *sctx,
isc_loopmgr_t *loopmgr, isc_nm_t *nm,
ns_interfacemgr_create(isc_mem_t *mctx, ns_server_t *sctx, isc_nm_t *nm,
dns_dispatchmgr_t *dispatchmgr,
dns_geoip_databases_t *geoip, ns_interfacemgr_t **mgrp) {
isc_result_t result;
@ -280,11 +278,10 @@ ns_interfacemgr_create(isc_mem_t *mctx, ns_server_t *sctx,
mgr = isc_mem_get(mctx, sizeof(*mgr));
*mgr = (ns_interfacemgr_t){
.loopmgr = loopmgr,
.nm = nm,
.dispatchmgr = dispatchmgr,
.generation = 1,
.ncpus = isc_loopmgr_nloops(loopmgr),
.ncpus = isc_loopmgr_nloops(),
};
isc_mem_attach(mctx, &mgr->mctx);
@ -320,8 +317,7 @@ ns_interfacemgr_create(isc_mem_t *mctx, ns_server_t *sctx,
mgr->clientmgrs = isc_mem_cget(mgr->mctx, mgr->ncpus,
sizeof(mgr->clientmgrs[0]));
for (size_t i = 0; i < mgr->ncpus; i++) {
result = ns_clientmgr_create(mgr->sctx, mgr->loopmgr,
mgr->aclenv, (int)i,
result = ns_clientmgr_create(mgr->sctx, mgr->aclenv, (int)i,
&mgr->clientmgrs[i]);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
}

View File

@ -42,7 +42,6 @@
#include <dns/qp.h>
#include <dns/types.h>
#include "loop_p.h"
#include "qp_p.h"
#include <tests/qp.h>
@ -173,7 +172,6 @@ collect(void *);
struct thread_args {
struct bench_state *bctx; /* (in) */
isc_barrier_t *barrier; /* (in) */
isc_loopmgr_t *loopmgr; /* (in) */
isc_job_t job; /* (in) */
isc_job_cb cb; /* (in) */
dns_qpmulti_t *multi; /* (in) */
@ -211,7 +209,7 @@ next_loop(struct thread_args *args, isc_nanosecs_t start) {
isc_job_run(isc_loop(), &args->job, args->cb, args);
return;
}
isc_async_run(isc_loop_main(args->loopmgr), collect, args);
isc_async_run(isc_loop_main(), collect, args);
}
#if ZIPF
@ -332,7 +330,6 @@ enum benchmode {
struct bench_state {
isc_mem_t *mctx;
isc_barrier_t barrier;
isc_loopmgr_t *loopmgr;
dns_qpmulti_t *multi;
enum benchmode mode;
size_t bytes;
@ -430,11 +427,10 @@ dispatch(struct bench_state *bctx) {
case init:
goto init_max_items_rw;
fini:;
isc_loopmgr_t *loopmgr = bctx->loopmgr;
fini:
dns_qpmulti_destroy(&bctx->multi);
isc_mem_putanddetach(&bctx->mctx, bctx, bctx->bytes);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
return;
init_max_items_rw:
@ -703,7 +699,6 @@ dispatch(struct bench_state *bctx) {
bctx->thread[t] = (struct thread_args){
.bctx = bctx,
.barrier = &bctx->barrier,
.loopmgr = bctx->loopmgr,
.multi = bctx->multi,
.max_item = bctx->max_item,
.zipf_skew = bctx->zipf_skew,
@ -716,8 +711,7 @@ dispatch(struct bench_state *bctx) {
.tx_per_loop = mut ? bctx->mut_tx_per_loop
: bctx->read_tx_per_loop,
};
isc_async_run(isc_loop_get(bctx->loopmgr, t), first_loop,
&bctx->thread[t]);
isc_async_run(isc_loop_get(t), first_loop, &bctx->thread[t]);
}
}
@ -794,17 +788,15 @@ collect(void *varg) {
}
static void
startup(void *arg) {
isc_loopmgr_t *loopmgr = arg;
startup(void *arg ISC_ATTR_UNUSED) {
isc_loop_t *loop = isc_loop();
isc_mem_t *mctx = isc_loop_getmctx(loop);
uint32_t nloops = isc_loopmgr_nloops(loopmgr);
uint32_t nloops = isc_loopmgr_nloops();
size_t bytes = sizeof(struct bench_state) +
sizeof(struct thread_args) * nloops;
struct bench_state *bctx = isc_mem_cget(mctx, 1, bytes);
*bctx = (struct bench_state){
.loopmgr = loopmgr,
.bytes = bytes,
.nloops = nloops,
};
@ -814,7 +806,6 @@ startup(void *arg) {
}
struct ticker {
isc_loopmgr_t *loopmgr;
isc_mem_t *mctx;
isc_timer_t *timer;
};
@ -848,15 +839,14 @@ stop_ticker(void *varg) {
}
static void
setup_tickers(isc_mem_t *mctx, isc_loopmgr_t *loopmgr) {
uint32_t nloops = isc_loopmgr_nloops(loopmgr);
setup_tickers(isc_mem_t *mctx) {
uint32_t nloops = isc_loopmgr_nloops();
for (uint32_t i = 0; i < nloops; i++) {
isc_loop_t *loop = isc_loop_get(loopmgr, i);
isc_loop_t *loop = isc_loop_get(i);
struct ticker *ticker = isc_mem_get(mctx, sizeof(*ticker));
*ticker = (struct ticker){
.loopmgr = loopmgr,
.mctx = isc_mem_ref(mctx),
};
isc_mem_attach(mctx, &ticker->mctx);
isc_loop_setup(loop, start_ticker, ticker);
isc_loop_teardown(loop, stop_ticker, ticker);
}
@ -864,7 +854,6 @@ setup_tickers(isc_mem_t *mctx, isc_loopmgr_t *loopmgr) {
int
main(void) {
isc_loopmgr_t *loopmgr = NULL;
isc_mem_t *mctx = NULL;
setlinebuf(stdout);
@ -884,11 +873,11 @@ main(void) {
init_logging();
init_items(mctx);
isc_loopmgr_create(mctx, nloops, &loopmgr);
setup_tickers(mctx, loopmgr);
isc_loop_setup(isc_loop_main(loopmgr), startup, loopmgr);
isc_loopmgr_run(loopmgr);
isc_loopmgr_destroy(&loopmgr);
isc_loopmgr_create(mctx, nloops);
setup_tickers(mctx);
isc_loop_setup(isc_loop_main(), startup, NULL);
isc_loopmgr_run();
isc_loopmgr_destroy();
isc_mem_free(mctx, item);
isc_mem_checkdestroyed(stdout);

View File

@ -57,7 +57,7 @@ ISC_LOOP_TEST_IMPL(basic) {
dns_name_fromstring(name, "example.com.", NULL, 0, NULL);
bc = dns_badcache_new(mctx, loopmgr);
bc = dns_badcache_new(mctx);
dns_badcache_add(bc, name, dns_rdatatype_aaaa, flags, now + 60);
flags = 0;
@ -72,7 +72,7 @@ ISC_LOOP_TEST_IMPL(basic) {
dns_badcache_destroy(&bc);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_LOOP_TEST_IMPL(expire) {
@ -85,7 +85,7 @@ ISC_LOOP_TEST_IMPL(expire) {
dns_name_fromstring(name, "example.com.", NULL, 0, NULL);
bc = dns_badcache_new(mctx, loopmgr);
bc = dns_badcache_new(mctx);
dns_badcache_add(bc, name, dns_rdatatype_aaaa, flags, now + 60);
dns_badcache_add(bc, name, dns_rdatatype_a, flags, now + 60);
@ -111,7 +111,7 @@ ISC_LOOP_TEST_IMPL(expire) {
dns_badcache_destroy(&bc);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_LOOP_TEST_IMPL(print) {
@ -137,7 +137,7 @@ ISC_LOOP_TEST_IMPL(print) {
dns_name_fromstring(name, "example.com.", NULL, 0, NULL);
bc = dns_badcache_new(mctx, loopmgr);
bc = dns_badcache_new(mctx);
dns_badcache_add(bc, name, dns_rdatatype_a, flags, expire);
dns_badcache_add(bc, name, dns_rdatatype_aaaa, flags, expire);
@ -197,7 +197,7 @@ line:
dns_badcache_destroy(&bc);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_LOOP_TEST_IMPL(flush) {
@ -210,7 +210,7 @@ ISC_LOOP_TEST_IMPL(flush) {
dns_name_fromstring(name, "example.com.", NULL, 0, NULL);
bc = dns_badcache_new(mctx, loopmgr);
bc = dns_badcache_new(mctx);
dns_badcache_add(bc, name, dns_rdatatype_aaaa, flags, now + 60);
result = dns_badcache_find(bc, name, dns_rdatatype_aaaa, &flags, now);
@ -223,7 +223,7 @@ ISC_LOOP_TEST_IMPL(flush) {
dns_badcache_destroy(&bc);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_LOOP_TEST_IMPL(flushname) {
@ -234,7 +234,7 @@ ISC_LOOP_TEST_IMPL(flushname) {
isc_result_t result;
uint32_t flags = BADCACHE_TEST_FLAG;
bc = dns_badcache_new(mctx, loopmgr);
bc = dns_badcache_new(mctx);
dns_name_fromstring(name, "example.com.", NULL, 0, NULL);
dns_badcache_add(bc, name, dns_rdatatype_aaaa, flags, now + 60);
@ -269,7 +269,7 @@ ISC_LOOP_TEST_IMPL(flushname) {
dns_badcache_destroy(&bc);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_LOOP_TEST_IMPL(flushtree) {
@ -280,7 +280,7 @@ ISC_LOOP_TEST_IMPL(flushtree) {
isc_result_t result;
uint32_t flags = BADCACHE_TEST_FLAG;
bc = dns_badcache_new(mctx, loopmgr);
bc = dns_badcache_new(mctx);
dns_name_fromstring(name, "example.com.", NULL, 0, NULL);
dns_badcache_add(bc, name, dns_rdatatype_aaaa, flags, now + 60);
@ -318,7 +318,7 @@ ISC_LOOP_TEST_IMPL(flushtree) {
dns_badcache_destroy(&bc);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_LOOP_TEST_IMPL(purge) {
@ -329,7 +329,7 @@ ISC_LOOP_TEST_IMPL(purge) {
isc_result_t result;
uint32_t flags = BADCACHE_TEST_FLAG;
bc = dns_badcache_new(mctx, loopmgr);
bc = dns_badcache_new(mctx);
dns_name_fromstring(name, "example.com.", NULL, 0, NULL);
dns_badcache_add(bc, name, dns_rdatatype_aaaa, flags, now);
@ -370,7 +370,7 @@ ISC_LOOP_TEST_IMPL(purge) {
dns_badcache_destroy(&bc);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_TEST_LIST_START

View File

@ -61,7 +61,7 @@ ISC_LOOP_TEST_IMPL(getoriginnode) {
dns_db_detachnode(db, &node);
dns_db_detach(&db);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
/* test getservestalettl and setservestalettl */
@ -90,7 +90,7 @@ ISC_LOOP_TEST_IMPL(getsetservestalettl) {
assert_int_equal(ttl, 6 * 3600);
dns_db_detach(&db);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
/* check DNS_DBFIND_STALEOK works */
@ -239,7 +239,7 @@ ISC_LOOP_TEST_IMPL(dns_dbfind_staleok) {
}
dns_db_detach(&db);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
/* database class */
@ -259,7 +259,7 @@ ISC_LOOP_TEST_IMPL(class) {
assert_int_equal(dns_db_class(db), dns_rdataclass_in);
dns_db_detach(&db);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
/* database type */
@ -287,7 +287,7 @@ ISC_LOOP_TEST_IMPL(dbtype) {
assert_true(dns_db_iscache(db));
assert_false(dns_db_iszone(db));
dns_db_detach(&db);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
/* database versions */
@ -385,7 +385,7 @@ ISC_LOOP_TEST_IMPL(version) {
dns_db_closeversion(db, &ver, false);
dns_db_detach(&db);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_TEST_LIST_START

View File

@ -102,7 +102,7 @@ test_dispatch_done(test_dispatch_t *test) {
static void
test_dispatch_shutdown(test_dispatch_t *test) {
test_dispatch_done(test);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
static int
@ -158,12 +158,11 @@ setup_test(void **state) {
uv_os_sock_t socket = -1;
/* Create just 1 loop for this test */
isc_loopmgr_create(mctx, 1, &loopmgr);
mainloop = isc_loop_main(loopmgr);
isc_loopmgr_create(mctx, 1);
setup_netmgr(state);
isc_netmgr_create(mctx, loopmgr, &connect_nm);
isc_netmgr_create(mctx, &connect_nm);
udp_connect_addr = (isc_sockaddr_t){ .length = 0 };
isc_sockaddr_fromin6(&udp_connect_addr, &in6addr_loopback, 0);
@ -280,8 +279,7 @@ ISC_LOOP_TEST_IMPL(dispatchset_create) {
UNUSED(arg);
result = dns_dispatchmgr_create(mctx, loopmgr, connect_nm,
&dispatchmgr);
result = dns_dispatchmgr_create(mctx, connect_nm, &dispatchmgr);
assert_int_equal(result, ISC_R_SUCCESS);
result = make_dispatchset(dispatchmgr, 1, &dset);
@ -294,7 +292,7 @@ ISC_LOOP_TEST_IMPL(dispatchset_create) {
dns_dispatchmgr_detach(&dispatchmgr);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
/* test dispatch set per-loop dispatch */
@ -307,8 +305,7 @@ ISC_LOOP_TEST_IMPL(dispatchset_get) {
UNUSED(arg);
result = dns_dispatchmgr_create(mctx, loopmgr, connect_nm,
&dispatchmgr);
result = dns_dispatchmgr_create(mctx, connect_nm, &dispatchmgr);
assert_int_equal(result, ISC_R_SUCCESS);
result = make_dispatchset(dispatchmgr, 1, &dset);
@ -355,7 +352,7 @@ ISC_LOOP_TEST_IMPL(dispatchset_get) {
dns_dispatchset_destroy(&dset);
dns_dispatchmgr_detach(&dispatchmgr);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
static atomic_bool first = true;
@ -522,7 +519,7 @@ connected_gettcp(isc_result_t eresult ISC_ATTR_UNUSED,
assert_ptr_equal(test1->dispatch, test2->dispatch);
result = dns_dispatch_add(
test2->dispatch, isc_loop_main(loopmgr), 0, T_CLIENT_CONNECT,
test2->dispatch, isc_loop_main(), 0, T_CLIENT_CONNECT,
T_CLIENT_INIT, &tcp_server_addr, NULL, NULL, connected_shutdown,
client_senddone, response_noop, test2, &test2->id,
&test2->dispentry);
@ -556,7 +553,7 @@ connected_newtcp(isc_result_t eresult ISC_ATTR_UNUSED,
assert_ptr_not_equal(test3->dispatch, test4->dispatch);
result = dns_dispatch_add(
test4->dispatch, isc_loop_main(loopmgr), 0, T_CLIENT_CONNECT,
test4->dispatch, isc_loop_main(), 0, T_CLIENT_CONNECT,
T_CLIENT_INIT, &tcp_server_addr, NULL, NULL, connected_shutdown,
client_senddone, response_noop, test4, &test4->id,
&test4->dispentry);
@ -596,8 +593,7 @@ ISC_LOOP_TEST_IMPL(dispatch_timeout_tcp_connect) {
testdata.region.base = testdata.message;
testdata.region.length = sizeof(testdata.message);
result = dns_dispatchmgr_create(mctx, loopmgr, connect_nm,
&test->dispatchmgr);
result = dns_dispatchmgr_create(mctx, connect_nm, &test->dispatchmgr);
assert_int_equal(result, ISC_R_SUCCESS);
result = dns_dispatch_createtcp(test->dispatchmgr, &tcp_connect_addr,
@ -606,7 +602,7 @@ ISC_LOOP_TEST_IMPL(dispatch_timeout_tcp_connect) {
assert_int_equal(result, ISC_R_SUCCESS);
result = dns_dispatch_add(
test->dispatch, isc_loop_main(loopmgr), 0, T_CLIENT_SHORT,
test->dispatch, isc_loop_main(), 0, T_CLIENT_SHORT,
T_CLIENT_INIT, &tcp_server_addr, NULL, NULL, timeout_connected,
client_senddone, response_timeout, test, &test->id,
&test->dispentry);
@ -639,11 +635,10 @@ ISC_LOOP_TEST_IMPL(dispatch_timeout_tcp_response) {
assert_int_equal(result, ISC_R_SUCCESS);
/* ensure we stop listening after the test is done */
isc_loop_teardown(isc_loop_main(loopmgr), stop_listening, sock);
isc_loop_teardown(isc_loop_main(), stop_listening, sock);
/* Client */
result = dns_dispatchmgr_create(mctx, loopmgr, connect_nm,
&test->dispatchmgr);
result = dns_dispatchmgr_create(mctx, connect_nm, &test->dispatchmgr);
assert_int_equal(result, ISC_R_SUCCESS);
result = dns_dispatch_createtcp(test->dispatchmgr, &tcp_connect_addr,
@ -651,7 +646,7 @@ ISC_LOOP_TEST_IMPL(dispatch_timeout_tcp_response) {
&test->dispatch);
assert_int_equal(result, ISC_R_SUCCESS);
result = dns_dispatch_add(test->dispatch, isc_loop_main(loopmgr), 0,
result = dns_dispatch_add(test->dispatch, isc_loop_main(), 0,
T_CLIENT_CONNECT, T_CLIENT_SHORT,
&tcp_server_addr, NULL, NULL, connected,
client_senddone, response_timeout, test,
@ -672,14 +667,13 @@ ISC_LOOP_TEST_IMPL(dispatch_tcp_response) {
accept_cb, NULL, 0, NULL, NULL, ISC_NM_PROXY_NONE, &sock);
assert_int_equal(result, ISC_R_SUCCESS);
isc_loop_teardown(isc_loop_main(loopmgr), stop_listening, sock);
isc_loop_teardown(isc_loop_main(), stop_listening, sock);
/* Client */
testdata.region.base = testdata.message;
testdata.region.length = sizeof(testdata.message);
result = dns_dispatchmgr_create(mctx, loopmgr, connect_nm,
&test->dispatchmgr);
result = dns_dispatchmgr_create(mctx, connect_nm, &test->dispatchmgr);
assert_int_equal(result, ISC_R_SUCCESS);
result = dns_dispatch_createtcp(test->dispatchmgr, &tcp_connect_addr,
@ -687,7 +681,7 @@ ISC_LOOP_TEST_IMPL(dispatch_tcp_response) {
&test->dispatch);
assert_int_equal(result, ISC_R_SUCCESS);
result = dns_dispatch_add(test->dispatch, isc_loop_main(loopmgr), 0,
result = dns_dispatch_add(test->dispatch, isc_loop_main(), 0,
T_CLIENT_CONNECT, T_CLIENT_INIT,
&tcp_server_addr, NULL, NULL, connected,
client_senddone, response_shutdown, test,
@ -712,14 +706,13 @@ ISC_LOOP_TEST_IMPL(dispatch_tls_response) {
&sock);
assert_int_equal(result, ISC_R_SUCCESS);
isc_loop_teardown(isc_loop_main(loopmgr), stop_listening, sock);
isc_loop_teardown(isc_loop_main(), stop_listening, sock);
/* Client */
testdata.region.base = testdata.message;
testdata.region.length = sizeof(testdata.message);
result = dns_dispatchmgr_create(mctx, loopmgr, connect_nm,
&test->dispatchmgr);
result = dns_dispatchmgr_create(mctx, connect_nm, &test->dispatchmgr);
assert_int_equal(result, ISC_R_SUCCESS);
result = dns_dispatch_createtcp(test->dispatchmgr, &tls_connect_addr,
@ -728,7 +721,7 @@ ISC_LOOP_TEST_IMPL(dispatch_tls_response) {
assert_int_equal(result, ISC_R_SUCCESS);
result = dns_dispatch_add(
test->dispatch, isc_loop_main(loopmgr), 0, T_CLIENT_CONNECT,
test->dispatch, isc_loop_main(), 0, T_CLIENT_CONNECT,
T_CLIENT_INIT, &tls_server_addr, tls_transport,
tls_tlsctx_client_cache, connected, client_senddone,
response_shutdown, test, &test->id, &test->dispentry);
@ -751,18 +744,17 @@ ISC_LOOP_TEST_IMPL(dispatch_timeout_udp_response) {
assert_int_equal(result, ISC_R_SUCCESS);
/* ensure we stop listening after the test is done */
isc_loop_teardown(isc_loop_main(loopmgr), stop_listening, sock);
isc_loop_teardown(isc_loop_main(), stop_listening, sock);
/* Client */
result = dns_dispatchmgr_create(mctx, loopmgr, connect_nm,
&test->dispatchmgr);
result = dns_dispatchmgr_create(mctx, connect_nm, &test->dispatchmgr);
assert_int_equal(result, ISC_R_SUCCESS);
result = dns_dispatch_createudp(test->dispatchmgr, &udp_connect_addr,
&test->dispatch);
assert_int_equal(result, ISC_R_SUCCESS);
result = dns_dispatch_add(test->dispatch, isc_loop_main(loopmgr), 0,
result = dns_dispatch_add(test->dispatch, isc_loop_main(), 0,
T_CLIENT_CONNECT, T_CLIENT_SHORT,
&udp_server_addr, NULL, NULL, connected,
client_senddone, response_timeout, test,
@ -783,21 +775,20 @@ ISC_LOOP_TEST_IMPL(dispatch_getnext) {
nameserver, NULL, &sock);
assert_int_equal(result, ISC_R_SUCCESS);
isc_loop_teardown(isc_loop_main(loopmgr), stop_listening, sock);
isc_loop_teardown(isc_loop_main(), stop_listening, sock);
/* Client */
testdata.region.base = testdata.message;
testdata.region.length = sizeof(testdata.message);
result = dns_dispatchmgr_create(mctx, loopmgr, connect_nm,
&test->dispatchmgr);
result = dns_dispatchmgr_create(mctx, connect_nm, &test->dispatchmgr);
assert_int_equal(result, ISC_R_SUCCESS);
result = dns_dispatch_createudp(test->dispatchmgr, &udp_connect_addr,
&test->dispatch);
assert_int_equal(result, ISC_R_SUCCESS);
result = dns_dispatch_add(test->dispatch, isc_loop_main(loopmgr), 0,
result = dns_dispatch_add(test->dispatch, isc_loop_main(), 0,
T_CLIENT_CONNECT, T_CLIENT_INIT,
&udp_server_addr, NULL, NULL, connected,
client_senddone, response_getnext, test,
@ -822,10 +813,9 @@ ISC_LOOP_TEST_IMPL(dispatch_gettcp) {
assert_int_equal(result, ISC_R_SUCCESS);
/* ensure we stop listening after the test is done */
isc_loop_teardown(isc_loop_main(loopmgr), stop_listening, sock);
isc_loop_teardown(isc_loop_main(), stop_listening, sock);
result = dns_dispatchmgr_create(mctx, loopmgr, connect_nm,
&test->dispatchmgr);
result = dns_dispatchmgr_create(mctx, connect_nm, &test->dispatchmgr);
assert_int_equal(result, ISC_R_SUCCESS);
/* Client */
@ -835,7 +825,7 @@ ISC_LOOP_TEST_IMPL(dispatch_gettcp) {
assert_int_equal(result, ISC_R_SUCCESS);
result = dns_dispatch_add(
test->dispatch, isc_loop_main(loopmgr), 0, T_CLIENT_CONNECT,
test->dispatch, isc_loop_main(), 0, T_CLIENT_CONNECT,
T_CLIENT_INIT, &tcp_server_addr, NULL, NULL, connected_gettcp,
client_senddone, response_noop, test, &test->id,
&test->dispentry);
@ -856,11 +846,10 @@ ISC_LOOP_TEST_IMPL(dispatch_newtcp) {
assert_int_equal(result, ISC_R_SUCCESS);
/* ensure we stop listening after the test is done */
isc_loop_teardown(isc_loop_main(loopmgr), stop_listening, sock);
isc_loop_teardown(isc_loop_main(), stop_listening, sock);
/* Client - unshared */
result = dns_dispatchmgr_create(mctx, loopmgr, connect_nm,
&test->dispatchmgr);
result = dns_dispatchmgr_create(mctx, connect_nm, &test->dispatchmgr);
assert_int_equal(result, ISC_R_SUCCESS);
result = dns_dispatch_createtcp(
@ -869,7 +858,7 @@ ISC_LOOP_TEST_IMPL(dispatch_newtcp) {
assert_int_equal(result, ISC_R_SUCCESS);
result = dns_dispatch_add(
test->dispatch, isc_loop_main(loopmgr), 0, T_CLIENT_CONNECT,
test->dispatch, isc_loop_main(), 0, T_CLIENT_CONNECT,
T_CLIENT_INIT, &tcp_server_addr, NULL, NULL, connected_newtcp,
client_senddone, response_noop, test, &test->id,
&test->dispentry);

View File

@ -131,7 +131,7 @@ ISC_LOOP_TEST_IMPL(dns_dt_create) {
fstrm_iothr_options_destroy(&fopt);
}
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
/* send dnstap messages */
@ -298,7 +298,7 @@ ISC_LOOP_TEST_IMPL(dns_dt_send) {
dns_dt_close(&handle);
}
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
/* dnstap message to text */
@ -362,7 +362,7 @@ ISC_LOOP_TEST_IMPL(dns_dt_totext) {
if (handle != NULL) {
dns_dt_close(&handle);
}
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_TEST_LIST_START

View File

@ -21,6 +21,8 @@
#include <stdlib.h>
#include <unistd.h>
#include "isc/loop.h"
#define UNIT_TESTING
#include <cmocka.h>
@ -174,7 +176,7 @@ create_tables(void) {
ISC_R_SUCCESS);
dns_keytable_create(view, &keytable);
dns_ntatable_create(view, loopmgr, &ntatable);
dns_ntatable_create(view, &ntatable);
/* Add a normal key */
dns_test_namefromstring("example.com.", &fn);
@ -379,7 +381,7 @@ ISC_LOOP_TEST_IMPL(add) {
dns_keynode_detach(&keynode);
destroy_tables();
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
/* delete keys from the keytable */
@ -412,7 +414,7 @@ ISC_LOOP_TEST_IMPL(delete) {
destroy_tables();
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
/* delete key nodes from the keytable */
@ -481,7 +483,7 @@ ISC_LOOP_TEST_IMPL(deletekey) {
destroy_tables();
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
/* check find-variant operations */
@ -537,7 +539,7 @@ ISC_LOOP_TEST_IMPL(find) {
destroy_tables();
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
/* check issecuredomain() */
@ -576,7 +578,7 @@ ISC_LOOP_TEST_IMPL(issecuredomain) {
destroy_tables();
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
/* check dns_keytable_dump() */
@ -596,7 +598,7 @@ ISC_LOOP_TEST_IMPL(dump) {
destroy_tables();
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
/* check negative trust anchors */
@ -618,7 +620,7 @@ ISC_LOOP_TEST_IMPL(nta) {
result = dns_view_getsecroots(myview, &keytable);
assert_int_equal(result, ISC_R_SUCCESS);
dns_view_initntatable(myview, loopmgr);
dns_view_initntatable(myview);
result = dns_view_getntatable(myview, &ntatable);
assert_int_equal(result, ISC_R_SUCCESS);
@ -693,7 +695,7 @@ ISC_LOOP_TEST_IMPL(nta) {
assert_false(covered);
assert_true(issecure);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
/* Clean up */
dns_ntatable_detach(&ntatable);

View File

@ -170,7 +170,7 @@ ISC_LOOP_TEST_IMPL(overmempurge_bigrdata) {
dns_db_detach(&db);
isc_mem_detach(&mctx2);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_LOOP_TEST_IMPL(overmempurge_longname) {
@ -221,7 +221,7 @@ ISC_LOOP_TEST_IMPL(overmempurge_longname) {
dns_db_detach(&db);
isc_mem_detach(&mctx2);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_TEST_LIST_START

View File

@ -365,17 +365,17 @@ many_transactions(void *arg) {
}
dns_qpmulti_destroy(&qpm);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_RUN_TEST_IMPL(qpmulti) {
setup_loopmgr(NULL);
setup_logging();
setup_items();
isc_loop_setup(isc_loop_main(loopmgr), many_transactions, NULL);
isc_loopmgr_run(loopmgr);
isc_loop_setup(isc_loop_main(), many_transactions, NULL);
isc_loopmgr_run();
rcu_barrier();
isc_loopmgr_destroy(&loopmgr);
isc_loopmgr_destroy();
}
ISC_TEST_LIST_START

View File

@ -78,8 +78,8 @@ mkres(dns_resolver_t **resolverp) {
isc_result_t result;
isc_tlsctx_cache_create(mctx, &tlsctx_cache);
result = dns_resolver_create(view, loopmgr, netmgr, 0, tlsctx_cache,
dispatch, NULL, resolverp);
result = dns_resolver_create(view, netmgr, 0, tlsctx_cache, dispatch,
NULL, resolverp);
assert_int_equal(result, ISC_R_SUCCESS);
}
@ -98,7 +98,7 @@ ISC_LOOP_TEST_IMPL(create) {
mkres(&resolver);
destroy_resolver(&resolver);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
/* dns_resolver_gettimeout */
@ -112,7 +112,7 @@ ISC_LOOP_TEST_IMPL(gettimeout) {
assert_true(timeout > 0);
destroy_resolver(&resolver);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
/* dns_resolver_settimeout */
@ -128,7 +128,7 @@ ISC_LOOP_TEST_IMPL(settimeout) {
assert_true(timeout == default_timeout + 1);
destroy_resolver(&resolver);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
/* dns_resolver_settimeout */
@ -149,7 +149,7 @@ ISC_LOOP_TEST_IMPL(settimeout_default) {
assert_int_equal(timeout, default_timeout);
destroy_resolver(&resolver);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
/* dns_resolver_settimeout below minimum */
@ -166,7 +166,7 @@ ISC_LOOP_TEST_IMPL(settimeout_belowmin) {
assert_in_range(timeout, default_timeout, 3999999);
destroy_resolver(&resolver);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
/* dns_resolver_settimeout over maximum */
@ -183,7 +183,7 @@ ISC_LOOP_TEST_IMPL(settimeout_overmax) {
assert_in_range(timeout, default_timeout, 3999999);
destroy_resolver(&resolver);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_TEST_LIST_START

View File

@ -64,7 +64,7 @@ ISC_LOOP_TEST_IMPL(basic) {
isc_sockaddr_fromin6(&src_addrv6, &in6addr_loopback, src_port);
isc_sockaddr_fromin6(&dst_addrv6, &in6addr_loopback, dst_port);
uc = dns_unreachcache_new(mctx, loopmgr, EXPIRE_MIN_S, EXPIRE_MAX_S,
uc = dns_unreachcache_new(mctx, EXPIRE_MIN_S, EXPIRE_MAX_S,
BACKOFF_ELGIBLE_S);
dns_unreachcache_add(uc, &dst_addrv4, &src_addrv4);
dns_unreachcache_add(uc, &dst_addrv6, &src_addrv6);
@ -96,7 +96,7 @@ ISC_LOOP_TEST_IMPL(basic) {
dns_unreachcache_destroy(&uc);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_LOOP_TEST_IMPL(expire) {
@ -110,7 +110,7 @@ ISC_LOOP_TEST_IMPL(expire) {
isc_sockaddr_fromin(&src_addrv4, &localhost4, src_port);
isc_sockaddr_fromin(&dst_addrv4, &localhost4, dst_port);
uc = dns_unreachcache_new(mctx, loopmgr, EXPIRE_MIN_S, EXPIRE_MAX_S,
uc = dns_unreachcache_new(mctx, EXPIRE_MIN_S, EXPIRE_MAX_S,
BACKOFF_ELGIBLE_S);
/* Two adds to "confirm" the addition. */
dns_unreachcache_add(uc, &dst_addrv4, &src_addrv4);
@ -147,7 +147,7 @@ ISC_LOOP_TEST_IMPL(expire) {
dns_unreachcache_destroy(&uc);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_LOOP_TEST_IMPL(flush) {
@ -161,7 +161,7 @@ ISC_LOOP_TEST_IMPL(flush) {
isc_sockaddr_fromin(&src_addrv4, &localhost4, src_port);
isc_sockaddr_fromin(&dst_addrv4, &localhost4, dst_port);
uc = dns_unreachcache_new(mctx, loopmgr, EXPIRE_MIN_S, EXPIRE_MAX_S,
uc = dns_unreachcache_new(mctx, EXPIRE_MIN_S, EXPIRE_MAX_S,
BACKOFF_ELGIBLE_S);
/* Two adds to "confirm" the addition. */
dns_unreachcache_add(uc, &dst_addrv4, &src_addrv4);
@ -177,7 +177,7 @@ ISC_LOOP_TEST_IMPL(flush) {
dns_unreachcache_destroy(&uc);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_TEST_LIST_START

View File

@ -111,7 +111,7 @@ ISC_LOOP_TEST_IMPL(filename) {
assert_string_equal(dns_zone_getfile(zone), longname);
dns_zone_detach(&zone);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_TEST_LIST_START

View File

@ -63,7 +63,7 @@ ISC_LOOP_TEST_IMPL(zonemgr_create) {
dns_zonemgr_detach(&myzonemgr);
assert_null(myzonemgr);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
/* manage and release a zone */
@ -96,7 +96,7 @@ ISC_LOOP_TEST_IMPL(zonemgr_managezone) {
dns_zonemgr_detach(&myzonemgr);
assert_null(myzonemgr);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
/* create and release a zone */
@ -122,7 +122,7 @@ ISC_LOOP_TEST_IMPL(zonemgr_createzone) {
dns_zonemgr_detach(&myzonemgr);
assert_null(myzonemgr);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_TEST_LIST_START

View File

@ -87,7 +87,7 @@ ISC_LOOP_TEST_IMPL(apply) {
/* The view was left attached in dns_test_makezone() */
dns_view_detach(&view);
dns_zone_detach(&zone);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
static isc_result_t
@ -110,7 +110,7 @@ load_done_last(void *uap) {
dns_zone_detach(&zone);
dns_view_detach(&view);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
return ISC_R_SUCCESS;
}
@ -221,7 +221,7 @@ all_done(void *arg ISC_ATTR_UNUSED) {
dns_zone_detach(&zone3);
dns_view_detach(&view);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
return ISC_R_SUCCESS;
}

View File

@ -31,8 +31,6 @@
#include <isc/uv.h>
extern isc_mem_t *mctx;
extern isc_loop_t *mainloop;
extern isc_loopmgr_t *loopmgr;
extern isc_nm_t *netmgr;
extern int ncpus;
extern unsigned int workers;
@ -132,13 +130,14 @@ teardown_managers(void **state);
isc_job_cb setup_loop = setup; \
isc_job_cb teardown_loop = teardown; \
if (setup_loop != NULL) { \
isc_loop_setup(mainloop, setup_loop, state); \
isc_loop_setup(isc_loop_main(), setup_loop, state); \
} \
if (teardown_loop != NULL) { \
isc_loop_teardown(mainloop, teardown_loop, state); \
isc_loop_teardown(isc_loop_main(), teardown_loop, \
state); \
} \
isc_loop_setup(mainloop, loop_test_##name, state); \
isc_loopmgr_run(loopmgr); \
isc_loop_setup(isc_loop_main(), loop_test_##name, state); \
isc_loopmgr_run(); \
} \
void loop_test_##name(void *arg ISC_ATTR_UNUSED)

View File

@ -40,35 +40,31 @@
static atomic_uint scheduled = 0;
static void
async_cb(void *arg) {
async_cb(void *arg ISC_ATTR_UNUSED) {
isc_tid_t tid = isc_tid();
UNUSED(arg);
atomic_fetch_add(&scheduled, 1);
if (tid > 0) {
isc_loop_t *loop = isc_loop_get(loopmgr, tid - 1);
isc_async_run(loop, async_cb, loopmgr);
isc_loop_t *loop = isc_loop_get(tid - 1);
isc_async_run(loop, async_cb, NULL);
} else {
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
}
static void
async_setup_cb(void *arg) {
isc_tid_t tid = isc_loopmgr_nloops(loopmgr) - 1;
isc_loop_t *loop = isc_loop_get(loopmgr, tid);
async_setup_cb(void *arg ISC_ATTR_UNUSED) {
isc_tid_t tid = isc_loopmgr_nloops() - 1;
isc_loop_t *loop = isc_loop_get(tid);
UNUSED(arg);
isc_async_run(loop, async_cb, loopmgr);
isc_async_run(loop, async_cb, NULL);
}
ISC_RUN_TEST_IMPL(isc_async_run) {
isc_loop_setup(isc_loop_main(loopmgr), async_setup_cb, loopmgr);
isc_loopmgr_run(loopmgr);
assert_int_equal(atomic_load(&scheduled), loopmgr->nloops);
isc_loop_setup(isc_loop_main(), async_setup_cb, NULL);
isc_loopmgr_run();
assert_int_equal(atomic_load(&scheduled), isc_loopmgr_nloops());
}
static char string[32] = "";
@ -82,23 +78,21 @@ append(void *arg) {
}
static void
async_multiple(void *arg) {
async_multiple(void *arg ISC_ATTR_UNUSED) {
isc_loop_t *loop = isc_loop();
UNUSED(arg);
isc_async_run(loop, append, &n1);
isc_async_run(loop, append, &n2);
isc_async_run(loop, append, &n3);
isc_async_run(loop, append, &n4);
isc_async_run(loop, append, &n5);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_RUN_TEST_IMPL(isc_async_multiple) {
string[0] = '\0';
isc_loop_setup(isc_loop_main(loopmgr), async_multiple, loopmgr);
isc_loopmgr_run(loopmgr);
isc_loop_setup(isc_loop_main(), async_multiple, NULL);
isc_loopmgr_run();
assert_string_equal(string, "12345");
}

View File

@ -348,7 +348,7 @@ setup_test(void **state) {
nm = isc_mem_cget(mctx, MAX_NM, sizeof(nm[0]));
for (size_t i = 0; i < MAX_NM; i++) {
isc_netmgr_create(mctx, loopmgr, &nm[i]);
isc_netmgr_create(mctx, &nm[i]);
assert_non_null(nm[i]);
}
@ -434,10 +434,10 @@ doh_receive_reply_cb(isc_nmhandle_t *handle, isc_result_t eresult,
if (have_expected_csends(atomic_fetch_add(&csends, 1) + 1) ||
have_expected_creads(atomic_fetch_add(&creads, 1) + 1))
{
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
} else {
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
}
@ -518,7 +518,7 @@ ISC_LOOP_TEST_IMPL(mock_doh_uv_tcp_bind) {
RESET_RETURN;
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
static void
@ -546,7 +546,7 @@ doh_noop(void *arg ISC_ATTR_UNUSED) {
&tcp_listen_addr, 0, NULL, NULL, endpoints,
0, get_proxy_type(), &listen_sock);
assert_int_equal(result, ISC_R_SUCCESS);
isc_loop_teardown(mainloop, listen_sock_close, listen_sock);
isc_loop_teardown(isc_loop_main(), listen_sock_close, listen_sock);
sockaddr_to_url(&tcp_listen_addr, false, req_url, sizeof(req_url),
ISC_NM_HTTP_DEFAULT_PATH);
@ -555,7 +555,7 @@ doh_noop(void *arg ISC_ATTR_UNUSED) {
.length = send_msg.len },
noop_read_cb, NULL, atomic_load(&use_TLS), 30000);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
assert_int_equal(0, atomic_load(&csends));
assert_int_equal(0, atomic_load(&creads));
@ -589,7 +589,7 @@ doh_noresponse(void *arg ISC_ATTR_UNUSED) {
&tcp_listen_addr, 0, NULL, NULL, endpoints,
0, get_proxy_type(), &listen_sock);
assert_int_equal(result, ISC_R_SUCCESS);
isc_loop_teardown(mainloop, listen_sock_close, listen_sock);
isc_loop_teardown(isc_loop_main(), listen_sock_close, listen_sock);
sockaddr_to_url(&tcp_listen_addr, false, req_url, sizeof(req_url),
ISC_NM_HTTP_DEFAULT_PATH);
@ -598,7 +598,7 @@ doh_noresponse(void *arg ISC_ATTR_UNUSED) {
.length = send_msg.len },
noop_read_cb, NULL, atomic_load(&use_TLS), 30000);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_LOOP_TEST_IMPL(doh_noresponse_POST) {
@ -640,7 +640,7 @@ timeout_retry_cb(isc_nmhandle_t *handle, isc_result_t eresult,
}
isc_nmhandle_detach(&handle);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
static void
@ -681,7 +681,7 @@ doh_timeout_recovery(void *arg ISC_ATTR_UNUSED) {
&tcp_listen_addr, 0, NULL, NULL, endpoints,
0, get_proxy_type(), &listen_sock);
assert_int_equal(result, ISC_R_SUCCESS);
isc_loop_teardown(mainloop, listen_sock_close, listen_sock);
isc_loop_teardown(isc_loop_main(), listen_sock_close, listen_sock);
/*
* Accept connections but don't send responses, forcing client
@ -758,7 +758,7 @@ doh_receive_send_reply_cb(isc_nmhandle_t *handle, isc_result_t eresult,
isc_async_current(doh_connect_thread, connect_nm);
}
if (sends <= 0) {
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
}
@ -787,7 +787,7 @@ doh_connect_thread(void *arg) {
atomic_load(&use_TLS), 30000);
if (sends <= 0) {
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
}
@ -823,7 +823,7 @@ doh_recv_one(void *arg ISC_ATTR_UNUSED) {
doh_receive_reply_cb, NULL, atomic_load(&use_TLS),
30000);
isc_loop_teardown(mainloop, listen_sock_close, listen_sock);
isc_loop_teardown(isc_loop_main(), listen_sock_close, listen_sock);
}
static int
@ -954,7 +954,7 @@ doh_recv_two(void *arg ISC_ATTR_UNUSED) {
NULL, ctx, NULL, client_sess_cache, 5000,
get_proxy_type(), NULL);
isc_loop_teardown(mainloop, listen_sock_close, listen_sock);
isc_loop_teardown(isc_loop_main(), listen_sock_close, listen_sock);
}
static int
@ -1027,7 +1027,7 @@ doh_recv_send(void *arg ISC_ATTR_UNUSED) {
isc_nm_t *connect_nm = nm[1];
isc_result_t result = ISC_R_SUCCESS;
isc_nmsocket_t *listen_sock = NULL;
size_t nthreads = isc_loopmgr_nloops(loopmgr);
size_t nthreads = isc_loopmgr_nloops();
isc_quota_t *quotap = init_listener_quota(workers);
atomic_store(&total_sends, 1000);
@ -1044,11 +1044,10 @@ doh_recv_send(void *arg ISC_ATTR_UNUSED) {
assert_int_equal(result, ISC_R_SUCCESS);
for (size_t i = 0; i < nthreads; i++) {
isc_async_run(isc_loop_get(loopmgr, i), doh_connect_thread,
connect_nm);
isc_async_run(isc_loop_get(i), doh_connect_thread, connect_nm);
}
isc_loop_teardown(mainloop, listen_sock_close, listen_sock);
isc_loop_teardown(isc_loop_main(), listen_sock_close, listen_sock);
}
static int
@ -1168,7 +1167,7 @@ ISC_LOOP_TEST_IMPL(doh_bad_connect_uri) {
.length = send_msg.len },
doh_receive_reply_cb, NULL, true, 30000);
isc_loop_teardown(mainloop, listen_sock_close, listen_sock);
isc_loop_teardown(isc_loop_main(), listen_sock_close, listen_sock);
}
ISC_RUN_TEST_IMPL(doh_parse_GET_query_string) {

View File

@ -53,7 +53,7 @@ shutdown_cb(void *arg) {
isc_mem_put(mctx, ta, sizeof(*ta));
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
static void
@ -86,9 +86,9 @@ ISC_RUN_TEST_IMPL(isc_job_run) {
atomic_init(&scheduled, 0);
atomic_init(&executed, 0);
isc_loopmgr_setup(loopmgr, job_run_cb, NULL);
isc_loopmgr_setup(job_run_cb, NULL);
isc_loopmgr_run(loopmgr);
isc_loopmgr_run();
assert_int_equal(atomic_load(&scheduled), atomic_load(&executed));
}
@ -110,22 +110,20 @@ append(void *arg) {
}
static void
job_multiple(void *arg) {
UNUSED(arg);
job_multiple(void *arg ISC_ATTR_UNUSED) {
/* These will be processed in normal order */
isc_job_run(mainloop, &n1.job, append, &n1);
isc_job_run(mainloop, &n2.job, append, &n2);
isc_job_run(mainloop, &n3.job, append, &n3);
isc_job_run(mainloop, &n4.job, append, &n4);
isc_job_run(mainloop, &n5.job, append, &n5);
isc_loopmgr_shutdown(loopmgr);
isc_job_run(isc_loop_main(), &n1.job, append, &n1);
isc_job_run(isc_loop_main(), &n2.job, append, &n2);
isc_job_run(isc_loop_main(), &n3.job, append, &n3);
isc_job_run(isc_loop_main(), &n4.job, append, &n4);
isc_job_run(isc_loop_main(), &n5.job, append, &n5);
isc_loopmgr_shutdown();
}
ISC_RUN_TEST_IMPL(isc_job_multiple) {
string[0] = '\0';
isc_loop_setup(isc_loop_main(loopmgr), job_multiple, loopmgr);
isc_loopmgr_run(loopmgr);
isc_loop_setup(isc_loop_main(), job_multiple, NULL);
isc_loopmgr_run();
assert_string_equal(string, "12345");
}

View File

@ -21,6 +21,8 @@
#include <sys/types.h>
#include <unistd.h>
#include "isc/attributes.h"
#define UNIT_TESTING
#include <cmocka.h>
@ -38,97 +40,87 @@
static atomic_uint scheduled = 0;
static void
count(void *arg) {
UNUSED(arg);
count(void *arg ISC_ATTR_UNUSED) {
atomic_fetch_add(&scheduled, 1);
}
static void
shutdown_loopmgr(void *arg) {
UNUSED(arg);
while (atomic_load(&scheduled) != loopmgr->nloops) {
shutdown_loopmgr(void *arg ISC_ATTR_UNUSED) {
while (atomic_load(&scheduled) != isc_loopmgr_nloops()) {
isc_thread_yield();
}
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_RUN_TEST_IMPL(isc_loopmgr) {
atomic_store(&scheduled, 0);
isc_loopmgr_setup(loopmgr, count, loopmgr);
isc_loop_setup(mainloop, shutdown_loopmgr, loopmgr);
isc_loopmgr_setup(count, NULL);
isc_loop_setup(isc_loop_main(), shutdown_loopmgr, NULL);
isc_loopmgr_run(loopmgr);
isc_loopmgr_run();
assert_int_equal(atomic_load(&scheduled), loopmgr->nloops);
assert_int_equal(atomic_load(&scheduled), isc_loopmgr_nloops());
}
static void
runjob(void *arg ISC_ATTR_UNUSED) {
isc_async_current(count, loopmgr);
isc_async_current(count, NULL);
if (isc_tid() == 0) {
isc_async_current(shutdown_loopmgr, loopmgr);
isc_async_current(shutdown_loopmgr, NULL);
}
}
ISC_RUN_TEST_IMPL(isc_loopmgr_runjob) {
atomic_store(&scheduled, 0);
isc_loopmgr_setup(loopmgr, runjob, loopmgr);
isc_loopmgr_run(loopmgr);
assert_int_equal(atomic_load(&scheduled), loopmgr->nloops);
isc_loopmgr_setup(runjob, NULL);
isc_loopmgr_run();
assert_int_equal(atomic_load(&scheduled), isc_loopmgr_nloops());
}
static void
pause_loopmgr(void *arg) {
UNUSED(arg);
pause_loopmgr(void *arg ISC_ATTR_UNUSED) {
isc_loopmgr_pause();
isc_loopmgr_pause(loopmgr);
assert_true(isc_loopmgr_paused());
assert_true(atomic_load(&loopmgr->paused));
for (size_t i = 0; i < loopmgr->nloops; i++) {
isc_loop_t *loop = &loopmgr->loops[i];
for (size_t i = 0; i < isc_loopmgr_nloops(); i++) {
isc_loop_t *loop = isc_loop_get(i);
assert_true(loop->paused);
}
atomic_init(&scheduled, loopmgr->nloops);
atomic_init(&scheduled, isc_loopmgr_nloops());
isc_loopmgr_resume(loopmgr);
isc_loopmgr_resume();
}
ISC_RUN_TEST_IMPL(isc_loopmgr_pause) {
isc_loop_setup(mainloop, pause_loopmgr, loopmgr);
isc_loop_setup(mainloop, shutdown_loopmgr, loopmgr);
isc_loopmgr_run(loopmgr);
isc_loop_setup(isc_loop_main(), pause_loopmgr, NULL);
isc_loop_setup(isc_loop_main(), shutdown_loopmgr, NULL);
isc_loopmgr_run();
}
static void
send_sigint(void *arg) {
UNUSED(arg);
send_sigint(void *arg ISC_ATTR_UNUSED) {
kill(getpid(), SIGINT);
}
ISC_RUN_TEST_IMPL(isc_loopmgr_sigint) {
isc_loop_setup(mainloop, send_sigint, loopmgr);
isc_loopmgr_run(loopmgr);
isc_loop_setup(isc_loop_main(), send_sigint, NULL);
isc_loopmgr_run();
}
static void
send_sigterm(void *arg) {
UNUSED(arg);
send_sigterm(void *arg ISC_ATTR_UNUSED) {
kill(getpid(), SIGINT);
}
ISC_RUN_TEST_IMPL(isc_loopmgr_sigterm) {
isc_loop_setup(mainloop, send_sigterm, loopmgr);
isc_loopmgr_run(loopmgr);
isc_loop_setup(isc_loop_main(), send_sigterm, NULL);
isc_loopmgr_run();
}
ISC_TEST_LIST_START

View File

@ -26,6 +26,8 @@
*/
#include <openssl/err.h>
#include "isc/loop.h"
#define UNIT_TESTING
#include <cmocka.h>
@ -176,7 +178,7 @@ setup_netmgr_test(void **state) {
isc_nonce_buf(&send_magic, sizeof(send_magic));
setup_loopmgr(state);
isc_netmgr_create(mctx, loopmgr, &listen_nm);
isc_netmgr_create(mctx, &listen_nm);
assert_non_null(listen_nm);
isc_nm_setinitialtimeout(listen_nm, T_INIT);
isc_nm_setprimariestimeout(listen_nm, T_PRIMARIES);
@ -184,7 +186,7 @@ setup_netmgr_test(void **state) {
isc_nm_setkeepalivetimeout(listen_nm, T_KEEPALIVE);
isc_nm_setadvertisedtimeout(listen_nm, T_ADVERTISED);
isc_netmgr_create(mctx, loopmgr, &connect_nm);
isc_netmgr_create(mctx, &connect_nm);
assert_non_null(connect_nm);
isc_nm_setinitialtimeout(connect_nm, T_INIT);
isc_nm_setprimariestimeout(connect_nm, T_PRIMARIES);
@ -302,7 +304,7 @@ connect_send_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) {
break;
case ISC_R_SUCCESS:
if (have_expected_csends(atomic_fetch_add(&csends, 1) + 1)) {
do_csends_shutdown(loopmgr);
do_csends_shutdown();
}
break;
default:
@ -344,7 +346,7 @@ connect_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
assert_true(magic == send_magic);
if (have_expected_creads(atomic_fetch_add(&creads, 1) + 1)) {
do_creads_shutdown(loopmgr);
do_creads_shutdown();
}
if (magic == send_magic && allow_send_back) {
@ -392,7 +394,7 @@ connect_connect_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) {
/* We are finished, initiate the shutdown */
if (have_expected_cconnects(atomic_fetch_add(&cconnects, 1) + 1)) {
do_cconnects_shutdown(loopmgr);
do_cconnects_shutdown();
} else if (do_send) {
isc_async_current(stream_recv_send_connect,
cbarg == NULL
@ -426,7 +428,7 @@ listen_send_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) {
break;
case ISC_R_SUCCESS:
if (have_expected_ssends(atomic_fetch_add(&ssends, 1) + 1)) {
do_ssends_shutdown(loopmgr);
do_ssends_shutdown();
}
break;
default:
@ -459,7 +461,7 @@ listen_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
assert_true(magic == send_magic);
if (have_expected_sreads(atomic_fetch_add(&sreads, 1) + 1)) {
do_sreads_shutdown(loopmgr);
do_sreads_shutdown();
}
assert_true(region->length >= sizeof(magic));
@ -505,7 +507,7 @@ listen_accept_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) {
}
if (have_expected_saccepts(atomic_fetch_add(&saccepts, 1) + 1)) {
do_saccepts_shutdown(loopmgr);
do_saccepts_shutdown();
}
isc_nmhandle_attach(handle, &(isc_nmhandle_t *){ NULL });
@ -527,7 +529,7 @@ stream_accept_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) {
}
if (have_expected_saccepts(atomic_fetch_add(&saccepts, 1) + 1)) {
do_saccepts_shutdown(loopmgr);
do_saccepts_shutdown();
}
if (stream_use_PROXY) {
@ -578,7 +580,7 @@ timeout_retry_cb(isc_nmhandle_t *handle, isc_result_t eresult,
isc_refcount_decrement(&active_creads);
isc_nmhandle_detach(&handle);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
isc_quota_t *
@ -734,7 +736,7 @@ connect_success_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) {
assert_int_equal(eresult, ISC_R_SUCCESS);
if (have_expected_cconnects(atomic_fetch_add(&cconnects, 1) + 1)) {
do_cconnects_shutdown(loopmgr);
do_cconnects_shutdown();
return;
}
}
@ -764,7 +766,7 @@ stream_noop(void **state ISC_ATTR_UNUSED) {
result = stream_listen(noop_accept_cb, NULL, 128, NULL, &listen_sock);
assert_int_equal(result, ISC_R_SUCCESS);
isc_loop_teardown(mainloop, stop_listening, listen_sock);
isc_loop_teardown(isc_loop_main(), stop_listening, listen_sock);
connect_readcb = NULL;
stream_connect(connect_success_cb, NULL, T_CONNECT);
@ -811,7 +813,7 @@ noresponse_readcb(isc_nmhandle_t *handle, isc_result_t eresult,
isc_refcount_decrement(&active_creads);
isc_nmhandle_detach(&handle);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
static void
@ -893,7 +895,7 @@ stream_noresponse(void **state ISC_ATTR_UNUSED) {
result = stream_listen(noop_accept_cb, NULL, 128, NULL, &listen_sock);
assert_int_equal(result, ISC_R_SUCCESS);
isc_loop_teardown(mainloop, stop_listening, listen_sock);
isc_loop_teardown(isc_loop_main(), stop_listening, listen_sock);
stream_connect(noresponse_connectcb, NULL, T_CONNECT);
}
@ -1027,7 +1029,7 @@ stream_timeout_recovery(void **state ISC_ATTR_UNUSED) {
noanswer = true;
result = stream_listen(stream_accept_cb, NULL, 128, NULL, &listen_sock);
assert_int_equal(result, ISC_R_SUCCESS);
isc_loop_teardown(mainloop, stop_listening, listen_sock);
isc_loop_teardown(isc_loop_main(), stop_listening, listen_sock);
/*
* Shorten all the client timeouts to 0.05 seconds.
@ -1108,7 +1110,7 @@ stream_recv_one(void **state ISC_ATTR_UNUSED) {
result = stream_listen(stream_accept_cb, NULL, 128, quotap,
&listen_sock);
assert_int_equal(result, ISC_R_SUCCESS);
isc_loop_teardown(mainloop, stop_listening, listen_sock);
isc_loop_teardown(isc_loop_main(), stop_listening, listen_sock);
stream_connect(connect_connect_cb, NULL, T_CONNECT);
}
@ -1186,7 +1188,7 @@ stream_recv_two(void **state ISC_ATTR_UNUSED) {
result = stream_listen(stream_accept_cb, NULL, 128, quotap,
&listen_sock);
assert_int_equal(result, ISC_R_SUCCESS);
isc_loop_teardown(mainloop, stop_listening, listen_sock);
isc_loop_teardown(isc_loop_main(), stop_listening, listen_sock);
stream_connect(connect_connect_cb, NULL, T_CONNECT);
@ -1250,11 +1252,10 @@ stream_recv_send(void **state ISC_ATTR_UNUSED) {
result = stream_listen(stream_accept_cb, NULL, 128, quotap,
&listen_sock);
assert_int_equal(result, ISC_R_SUCCESS);
isc_loop_teardown(mainloop, stop_listening, listen_sock);
isc_loop_teardown(isc_loop_main(), stop_listening, listen_sock);
for (size_t i = 0; i < workers; i++) {
isc_async_run(isc_loop_get(loopmgr, i),
stream_recv_send_connect,
isc_async_run(isc_loop_get(i), stream_recv_send_connect,
get_stream_connect_function());
}
}
@ -1374,7 +1375,7 @@ udp_start_listening(uint32_t nworkers, isc_nm_recv_cb_t cb) {
assert_int_equal(result, ISC_R_SUCCESS);
isc_loop_teardown(mainloop, stop_listening, listen_sock);
isc_loop_teardown(isc_loop_main(), stop_listening, listen_sock);
}
static void
@ -1390,7 +1391,7 @@ udp__send_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) {
if (have_expected_csends(atomic_fetch_add(&csends, 1) + 1)) {
if (csends_shutdown) {
isc_nm_cancelread(handle);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
}
break;
@ -1448,7 +1449,7 @@ udp__connect_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
assert_true(magic == send_magic);
if (have_expected_creads(atomic_fetch_add(&creads, 1) + 1)) {
do_creads_shutdown(loopmgr);
do_creads_shutdown();
}
if (magic == send_magic && allow_send_back) {
@ -1486,7 +1487,7 @@ udp__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);
do_cconnects_shutdown();
} else if (do_send) {
isc_async_current(udp_enqueue_connect, cbarg);
}
@ -1585,7 +1586,7 @@ udp_noresponse_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
isc_nmhandle_detach(&handle);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
static void
@ -1720,7 +1721,7 @@ udp_timeout_recovery_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
isc_nmhandle_detach(&handle);
atomic_fetch_add(&creads, 1);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
static void
@ -1858,7 +1859,7 @@ udp_shutdown_connect_teardown(void **state) {
void
udp_shutdown_connect(void **arg ISC_ATTR_UNUSED) {
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
/*
* isc_nm_udpconnect() is synchronous, so we need to launch this on the
* async loop.
@ -1910,7 +1911,7 @@ udp_shutdown_read_send_cb(isc_nmhandle_t *handle, isc_result_t eresult,
atomic_fetch_add(&csends, 1);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
isc_nmhandle_detach(&handle);
isc_refcount_decrement(&active_csends);
@ -2060,7 +2061,7 @@ udp_cancel_read_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
case ISC_R_CANCELED:
/* The read has been canceled */
atomic_fetch_add(&creads, 1);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
break;
default:
UNREACHABLE();
@ -2269,8 +2270,7 @@ udp_recv_send(void **arg ISC_ATTR_UNUSED) {
udp_start_listening(ISC_NM_LISTEN_ALL, udp_listen_read_cb);
for (size_t i = 0; i < workers; i++) {
isc_async_run(isc_loop_get(loopmgr, i), udp_enqueue_connect,
NULL);
isc_async_run(isc_loop_get(i), udp_enqueue_connect, NULL);
}
}
@ -2299,7 +2299,7 @@ udp_double_read_send_cb(isc_nmhandle_t *handle, isc_result_t eresult,
switch (eresult) {
case ISC_R_SUCCESS:
if (have_expected_ssends(atomic_fetch_add(&ssends, 1) + 1)) {
do_ssends_shutdown(loopmgr);
do_ssends_shutdown();
} else {
isc_nmhandle_t *sendhandle = NULL;
isc_nmhandle_attach(handle, &sendhandle);
@ -2389,7 +2389,7 @@ udp_double_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
assert_true(magic == send_magic);
if (have_expected_creads(atomic_fetch_add(&creads, 1) + 1)) {
do_creads_shutdown(loopmgr);
do_creads_shutdown();
detach = true;
}

View File

@ -42,14 +42,14 @@ typedef struct rlstat {
ISC_LOOP_TEST_IMPL(ratelimiter_create) {
assert_null(rl);
expect_assert_failure(isc_ratelimiter_create(NULL, &rl));
expect_assert_failure(isc_ratelimiter_create(mainloop, NULL));
expect_assert_failure(isc_ratelimiter_create(isc_loop_main(), NULL));
assert_null(rl);
isc_ratelimiter_create(mainloop, &rl);
isc_ratelimiter_create(isc_loop_main(), &rl);
isc_ratelimiter_shutdown(rl);
isc_ratelimiter_detach(&rl);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_LOOP_TEST_IMPL(ratelimiter_shutdown) {
@ -57,7 +57,7 @@ ISC_LOOP_TEST_IMPL(ratelimiter_shutdown) {
expect_assert_failure(isc_ratelimiter_shutdown(NULL));
expect_assert_failure(isc_ratelimiter_shutdown(rl));
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_LOOP_TEST_IMPL(ratelimiter_detach) {
@ -66,7 +66,7 @@ ISC_LOOP_TEST_IMPL(ratelimiter_detach) {
expect_assert_failure(isc_ratelimiter_detach(NULL));
expect_assert_failure(isc_ratelimiter_detach(&rl));
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
static int ticks = 0;
@ -87,14 +87,14 @@ tick(void *arg) {
isc_ratelimiter_shutdown(rl);
isc_ratelimiter_detach(&rl);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_LOOP_SETUP_IMPL(ratelimiter_common) {
assert_null(rl);
isc_time_set(&tick_time, 0, 0);
start_time = isc_time_now();
isc_ratelimiter_create(mainloop, &rl);
isc_ratelimiter_create(isc_loop_main(), &rl);
}
ISC_LOOP_SETUP_IMPL(ratelimiter_enqueue) {
@ -109,7 +109,7 @@ ISC_LOOP_TEST_SETUP_TEARDOWN_IMPL(ratelimiter_enqueue) {
rlstat_t *rlstat = isc_mem_get(mctx, sizeof(*rlstat));
*rlstat = (rlstat_t){ 0 };
result = isc_ratelimiter_enqueue(rl, mainloop, tick, rlstat,
result = isc_ratelimiter_enqueue(rl, isc_loop_main(), tick, rlstat,
&rlstat->event);
assert_int_equal(result, ISC_R_SUCCESS);
assert_non_null(rlstat->event);
@ -129,22 +129,22 @@ ISC_LOOP_TEST_SETUP_TEARDOWN_IMPL(ratelimiter_enqueue_shutdown) {
rlstat_t *rlstat = isc_mem_get(mctx, sizeof(*rlstat));
*rlstat = (rlstat_t){ 0 };
expect_assert_failure(
isc_ratelimiter_enqueue(NULL, mainloop, tick, NULL, &event));
expect_assert_failure(isc_ratelimiter_enqueue(NULL, isc_loop_main(),
tick, NULL, &event));
expect_assert_failure(
isc_ratelimiter_enqueue(rl, NULL, tick, NULL, &event));
expect_assert_failure(
isc_ratelimiter_enqueue(rl, mainloop, tick, NULL, NULL));
isc_ratelimiter_enqueue(rl, isc_loop_main(), tick, NULL, NULL));
assert_int_equal(isc_ratelimiter_enqueue(rl, mainloop, tick, rlstat,
&rlstat->event),
assert_int_equal(isc_ratelimiter_enqueue(rl, isc_loop_main(), tick,
rlstat, &rlstat->event),
ISC_R_SUCCESS);
assert_non_null(rlstat->event);
isc_ratelimiter_shutdown(rl);
assert_int_equal(
isc_ratelimiter_enqueue(rl, mainloop, tick, NULL, &event),
assert_int_equal(isc_ratelimiter_enqueue(rl, isc_loop_main(), tick,
NULL, &event),
ISC_R_SHUTTINGDOWN);
assert_null(event);
}
@ -163,8 +163,8 @@ ISC_LOOP_TEST_SETUP_TEARDOWN_IMPL(ratelimiter_dequeue) {
rlstat_t *rlstat = isc_mem_get(mctx, sizeof(*rlstat));
*rlstat = (rlstat_t){ 0 };
assert_int_equal(isc_ratelimiter_enqueue(rl, mainloop, tick, rlstat,
&rlstat->event),
assert_int_equal(isc_ratelimiter_enqueue(rl, isc_loop_main(), tick,
rlstat, &rlstat->event),
ISC_R_SUCCESS);
assert_int_equal(isc_ratelimiter_dequeue(rl, &rlstat->event),
ISC_R_SUCCESS);
@ -172,7 +172,7 @@ ISC_LOOP_TEST_SETUP_TEARDOWN_IMPL(ratelimiter_dequeue) {
/* Set up a mock ratelimiter event that isn't actually scheduled */
*fake = (isc_rlevent_t){ .link = ISC_LINK_INITIALIZER };
isc_loop_attach(mainloop, &fake->loop);
isc_loop_attach(isc_loop_main(), &fake->loop);
isc_ratelimiter_attach(rl, &fake->rl);
assert_int_equal(isc_ratelimiter_dequeue(rl, &fake), ISC_R_NOTFOUND);
isc_loop_detach(&fake->loop);
@ -182,7 +182,7 @@ ISC_LOOP_TEST_SETUP_TEARDOWN_IMPL(ratelimiter_dequeue) {
isc_ratelimiter_shutdown(rl);
isc_ratelimiter_detach(&rl);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
static isc_time_t tock_time;
@ -231,14 +231,14 @@ ISC_LOOP_TEST_SETUP_TEARDOWN_IMPL(ratelimiter_pertick_interval) {
rlstat = isc_mem_get(mctx, sizeof(*rlstat));
*rlstat = (rlstat_t){ 0 };
assert_int_equal(isc_ratelimiter_enqueue(rl, mainloop, tock, rlstat,
&rlstat->event),
assert_int_equal(isc_ratelimiter_enqueue(rl, isc_loop_main(), tock,
rlstat, &rlstat->event),
ISC_R_SUCCESS);
rlstat = isc_mem_get(mctx, sizeof(*rlstat));
*rlstat = (rlstat_t){ 0 };
assert_int_equal(isc_ratelimiter_enqueue(rl, mainloop, tick, rlstat,
&rlstat->event),
assert_int_equal(isc_ratelimiter_enqueue(rl, isc_loop_main(), tick,
rlstat, &rlstat->event),
ISC_R_SUCCESS);
}
@ -266,14 +266,14 @@ ISC_LOOP_TEST_SETUP_TEARDOWN_IMPL(ratelimiter_pushpop) {
rlstat = isc_mem_get(mctx, sizeof(*rlstat));
*rlstat = (rlstat_t){ 0 };
assert_int_equal(isc_ratelimiter_enqueue(rl, mainloop, tock, rlstat,
&rlstat->event),
assert_int_equal(isc_ratelimiter_enqueue(rl, isc_loop_main(), tock,
rlstat, &rlstat->event),
ISC_R_SUCCESS);
rlstat = isc_mem_get(mctx, sizeof(*rlstat));
*rlstat = (rlstat_t){ 0 };
assert_int_equal(isc_ratelimiter_enqueue(rl, mainloop, tick, rlstat,
&rlstat->event),
assert_int_equal(isc_ratelimiter_enqueue(rl, isc_loop_main(), tick,
rlstat, &rlstat->event),
ISC_R_SUCCESS);
}

View File

@ -90,10 +90,10 @@ stream_shutdownconnect(void **state ISC_ATTR_UNUSED) {
isc_result_t result = stream_listen(stream_accept_cb, NULL, 128, NULL,
&listen_sock);
assert_int_equal(result, ISC_R_SUCCESS);
isc_loop_teardown(mainloop, stop_listening, listen_sock);
isc_loop_teardown(isc_loop_main(), stop_listening, listen_sock);
/* Schedule the shutdown before the connect */
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
stream_connect(shutdownconnect_connectcb, NULL, T_CONNECT);
}
@ -156,7 +156,7 @@ shutdownread_connectcb(isc_nmhandle_t *handle, isc_result_t eresult,
atomic_fetch_add(&cconnects, 1);
/* Schedule the shutdown before read and send */
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
isc_refcount_increment0(&active_creads);
isc_nmhandle_ref(handle);
@ -205,7 +205,7 @@ stream_shutdownread(void **state ISC_ATTR_UNUSED) {
isc_result_t result = stream_listen(stream_accept_cb, NULL, 128, NULL,
&listen_sock);
assert_int_equal(result, ISC_R_SUCCESS);
isc_loop_teardown(mainloop, stop_listening, listen_sock);
isc_loop_teardown(isc_loop_main(), stop_listening, listen_sock);
stream_connect(shutdownread_connectcb, NULL, T_CONNECT);
}

View File

@ -57,7 +57,7 @@ start_listening(uint32_t nworkers, isc_nm_accept_cb_t accept_cb,
NULL, 128, NULL, NULL, get_proxy_type(), &listen_sock);
assert_int_equal(result, ISC_R_SUCCESS);
isc_loop_teardown(mainloop, stop_listening, listen_sock);
isc_loop_teardown(isc_loop_main(), stop_listening, listen_sock);
}
static void
@ -127,8 +127,8 @@ ISC_LOOP_TEST_IMPL(tcpdns_recv_send) {
start_listening(ISC_NM_LISTEN_ALL, listen_accept_cb, listen_read_cb);
for (size_t i = 0; i < workers; i++) {
isc_async_run(isc_loop_get(loopmgr, i),
stream_recv_send_connect, tcpdns_connect);
isc_async_run(isc_loop_get(i), stream_recv_send_connect,
tcpdns_connect);
}
}

View File

@ -70,7 +70,7 @@ setup_test_run(void *data) {
lasttime = isc_time_now();
UNLOCK(&lasttime_mx);
isc_timer_create(mainloop, action, (void *)timertype, &timer);
isc_timer_create(isc_loop_main(), action, (void *)timertype, &timer);
isc_timer_start(timer, timertype, interval);
}
@ -88,8 +88,8 @@ setup_test(isc_timertype_t timertype, isc_interval_t *interval,
atomic_store(&errcnt, ISC_R_SUCCESS);
isc_loop_setup(mainloop, setup_test_run, &arg);
isc_loopmgr_run(loopmgr);
isc_loop_setup(isc_loop_main(), setup_test_run, &arg);
isc_loopmgr_run();
assert_int_equal(atomic_load(&errcnt), ISC_R_SUCCESS);
@ -168,7 +168,7 @@ ticktock(void *arg) {
if (atomic_load(&eventcnt) == nevents) {
endtime = isc_time_now();
isc_timer_destroy(&timer);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
}
@ -231,7 +231,7 @@ test_idle(void *arg) {
isc_mutex_unlock(&lasttime_mx);
isc_timer_destroy(&timer);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
/* timer type once idles out */
@ -300,7 +300,7 @@ test_reset(void *arg) {
}
} else {
isc_timer_destroy(&timer);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
}
@ -345,7 +345,7 @@ tick_event(void *arg) {
*/
if (tick == 0) {
isc_timer_destroy(&tickertimer);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
}
@ -392,14 +392,14 @@ ISC_LOOP_TEST_SETUP_TEARDOWN_IMPL(purge) {
isc_interval_set(&interval, seconds, 0);
tickertimer = NULL;
isc_timer_create(mainloop, tick_event, NULL, &tickertimer);
isc_timer_create(isc_loop_main(), tick_event, NULL, &tickertimer);
isc_timer_start(tickertimer, isc_timertype_ticker, &interval);
oncetimer = NULL;
isc_interval_set(&interval, (seconds * 2) + 1, 0);
isc_timer_create(mainloop, once_event, NULL, &oncetimer);
isc_timer_create(isc_loop_main(), once_event, NULL, &oncetimer);
isc_timer_start(oncetimer, isc_timertype_once, &interval);
}
@ -423,7 +423,7 @@ static void
timer_event(void *arg ISC_ATTR_UNUSED) {
if (--timer_ticks == 0) {
isc_timer_destroy(&timer);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
timer_stop = isc_loop_now(isc_loop());
} else {
isc_timer_start(timer, timer_type, &timer_interval);
@ -439,7 +439,7 @@ ISC_LOOP_SETUP_IMPL(reschedule_up) {
ISC_LOOP_TEST_CUSTOM_IMPL(reschedule_up, setup_loop_reschedule_up,
teardown_loop_timer_expect) {
isc_timer_create(mainloop, timer_event, NULL, &timer);
isc_timer_create(isc_loop_main(), timer_event, NULL, &timer);
/* Schedule the timer to fire immediately */
isc_interval_set(&timer_interval, 0, 0);
@ -459,7 +459,7 @@ ISC_LOOP_SETUP_IMPL(reschedule_down) {
ISC_LOOP_TEST_CUSTOM_IMPL(reschedule_down, setup_loop_reschedule_down,
teardown_loop_timer_expect) {
isc_timer_create(mainloop, timer_event, NULL, &timer);
isc_timer_create(isc_loop_main(), timer_event, NULL, &timer);
/* Schedule the timer to fire at 10 seconds */
isc_interval_set(&timer_interval, 10, 0);
@ -480,7 +480,7 @@ ISC_LOOP_SETUP_IMPL(reschedule_from_callback) {
ISC_LOOP_TEST_CUSTOM_IMPL(reschedule_from_callback,
setup_loop_reschedule_from_callback,
teardown_loop_timer_expect) {
isc_timer_create(mainloop, timer_event, NULL, &timer);
isc_timer_create(isc_loop_main(), timer_event, NULL, &timer);
isc_interval_set(&timer_interval, 0, NS_PER_SEC / 2);
isc_timer_start(timer, timer_type, &timer_interval);
@ -494,7 +494,7 @@ ISC_LOOP_SETUP_IMPL(zero) {
}
ISC_LOOP_TEST_CUSTOM_IMPL(zero, setup_loop_zero, teardown_loop_timer_expect) {
isc_timer_create(mainloop, timer_event, NULL, &timer);
isc_timer_create(isc_loop_main(), timer_event, NULL, &timer);
/* Schedule the timer to fire immediately (in the next event loop) */
isc_interval_set(&timer_interval, 0, 0);
@ -510,7 +510,7 @@ ISC_LOOP_SETUP_IMPL(reschedule_ticker) {
ISC_LOOP_TEST_CUSTOM_IMPL(reschedule_ticker, setup_loop_reschedule_ticker,
teardown_loop_timer_expect) {
isc_timer_create(mainloop, timer_event, NULL, &timer);
isc_timer_create(isc_loop_main(), timer_event, NULL, &timer);
/* Schedule the timer to fire immediately (in the next event loop) */
isc_interval_set(&timer_interval, 0, 0);

View File

@ -57,7 +57,7 @@ start_listening(uint32_t nworkers, isc_nm_accept_cb_t accept_cb,
&listen_sock);
assert_int_equal(result, ISC_R_SUCCESS);
isc_loop_teardown(mainloop, stop_listening, listen_sock);
isc_loop_teardown(isc_loop_main(), stop_listening, listen_sock);
}
static void
@ -139,8 +139,8 @@ ISC_LOOP_TEST_IMPL(tlsdns_recv_send) {
start_listening(ISC_NM_LISTEN_ALL, listen_accept_cb, listen_read_cb);
for (size_t i = 0; i < workers; i++) {
isc_async_run(isc_loop_get(loopmgr, i),
stream_recv_send_connect, tlsdns_connect);
isc_async_run(isc_loop_get(i), stream_recv_send_connect,
tlsdns_connect);
}
}

View File

@ -70,7 +70,7 @@ udp_connect_nomemory_cb(isc_nmhandle_t *handle, isc_result_t eresult,
isc_refcount_decrement(&active_cconnects);
assert_int_equal(eresult, ISC_R_NOMEMORY);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
/* UDP */
@ -87,7 +87,7 @@ ISC_LOOP_TEST_IMPL(mock_listenudp_uv_udp_open) {
RESET_RETURN;
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_LOOP_TEST_IMPL(mock_listenudp_uv_udp_bind) {
@ -102,7 +102,7 @@ ISC_LOOP_TEST_IMPL(mock_listenudp_uv_udp_bind) {
RESET_RETURN;
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_LOOP_TEST_IMPL(mock_listenudp_uv_udp_recv_start) {
@ -117,7 +117,7 @@ ISC_LOOP_TEST_IMPL(mock_listenudp_uv_udp_recv_start) {
RESET_RETURN;
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
ISC_LOOP_TEST_IMPL(mock_udpconnect_uv_udp_open) {
@ -126,7 +126,7 @@ ISC_LOOP_TEST_IMPL(mock_udpconnect_uv_udp_open) {
isc_refcount_increment0(&active_cconnects);
isc_nm_udpconnect(netmgr, &udp_connect_addr, &udp_listen_addr,
udp_connect_nomemory_cb, NULL, UDP_T_CONNECT);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
RESET_RETURN;
}
@ -137,7 +137,7 @@ ISC_LOOP_TEST_IMPL(mock_udpconnect_uv_udp_bind) {
isc_refcount_increment0(&active_cconnects);
isc_nm_udpconnect(netmgr, &udp_connect_addr, &udp_listen_addr,
udp_connect_nomemory_cb, NULL, UDP_T_CONNECT);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
RESET_RETURN;
}
@ -148,7 +148,7 @@ ISC_LOOP_TEST_IMPL(mock_udpconnect_uv_udp_connect) {
isc_refcount_increment0(&active_cconnects);
isc_nm_udpconnect(netmgr, &udp_connect_addr, &udp_listen_addr,
udp_connect_nomemory_cb, NULL, UDP_T_CONNECT);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
RESET_RETURN;
}
@ -159,7 +159,7 @@ ISC_LOOP_TEST_IMPL(mock_udpconnect_uv_recv_buffer_size) {
isc_refcount_increment0(&active_cconnects);
isc_nm_udpconnect(netmgr, &udp_connect_addr, &udp_listen_addr,
connect_success_cb, NULL, UDP_T_CONNECT);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
RESET_RETURN;
}
@ -170,7 +170,7 @@ ISC_LOOP_TEST_IMPL(mock_udpconnect_uv_send_buffer_size) {
isc_refcount_increment0(&active_cconnects);
isc_nm_udpconnect(netmgr, &udp_connect_addr, &udp_listen_addr,
connect_success_cb, NULL, UDP_T_CONNECT);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
RESET_RETURN;
}

View File

@ -40,38 +40,33 @@
static atomic_uint scheduled = 0;
static void
work_cb(void *arg) {
UNUSED(arg);
work_cb(void *arg ISC_ATTR_UNUSED) {
atomic_fetch_add(&scheduled, 1);
assert_int_equal(isc_tid(), ISC_TID_UNKNOWN);
}
static void
after_work_cb(void *arg) {
UNUSED(arg);
after_work_cb(void *arg ISC_ATTR_UNUSED) {
assert_int_equal(atomic_load(&scheduled), 1);
isc_loopmgr_shutdown(loopmgr);
isc_loopmgr_shutdown();
}
static void
work_enqueue_cb(void *arg) {
UNUSED(arg);
isc_tid_t tid = isc_loopmgr_nloops(loopmgr) - 1;
work_enqueue_cb(void *arg ISC_ATTR_UNUSED) {
isc_tid_t tid = isc_loopmgr_nloops() - 1;
isc_loop_t *loop = isc_loop_get(loopmgr, tid);
isc_loop_t *loop = isc_loop_get(tid);
isc_work_enqueue(loop, work_cb, after_work_cb, loopmgr);
isc_work_enqueue(loop, work_cb, after_work_cb, NULL);
}
ISC_RUN_TEST_IMPL(isc_work_enqueue) {
atomic_init(&scheduled, 0);
isc_loop_setup(isc_loop_main(loopmgr), work_enqueue_cb, loopmgr);
isc_loop_setup(isc_loop_main(), work_enqueue_cb, NULL);
isc_loopmgr_run(loopmgr);
isc_loopmgr_run();
assert_int_equal(atomic_load(&scheduled), 1);
}

View File

@ -65,23 +65,20 @@ dns_test_makeview(const char *name, bool with_dispatchmgr, bool with_cache,
dns_dispatchmgr_t *dispatchmgr = NULL;
if (with_dispatchmgr) {
result = dns_dispatchmgr_create(mctx, loopmgr, netmgr,
&dispatchmgr);
result = dns_dispatchmgr_create(mctx, netmgr, &dispatchmgr);
if (result != ISC_R_SUCCESS) {
return result;
}
}
dns_view_create(mctx, loopmgr, dispatchmgr, dns_rdataclass_in, name,
&view);
dns_view_create(mctx, dispatchmgr, dns_rdataclass_in, name, &view);
if (dispatchmgr != NULL) {
dns_dispatchmgr_detach(&dispatchmgr);
}
if (with_cache) {
result = dns_cache_create(loopmgr, dns_rdataclass_in, "", mctx,
&cache);
result = dns_cache_create(dns_rdataclass_in, "", mctx, &cache);
if (result != ISC_R_SUCCESS) {
dns_view_detach(&view);
return result;

View File

@ -33,8 +33,6 @@
#include <tests/isc.h>
isc_mem_t *mctx = NULL;
isc_loop_t *mainloop = NULL;
isc_loopmgr_t *loopmgr = NULL;
isc_nm_t *netmgr = NULL;
unsigned int workers = 0;
bool debug = false;
@ -90,8 +88,7 @@ setup_loopmgr(void **state ISC_ATTR_UNUSED) {
setup_workers(state);
isc_loopmgr_create(mctx, workers, &loopmgr);
mainloop = isc_loop_main(loopmgr);
isc_loopmgr_create(mctx, workers);
return 0;
}
@ -100,27 +97,22 @@ int
teardown_loopmgr(void **state ISC_ATTR_UNUSED) {
REQUIRE(netmgr == NULL);
mainloop = NULL;
isc_loopmgr_destroy(&loopmgr);
isc_loopmgr_destroy();
return 0;
}
int
setup_netmgr(void **state ISC_ATTR_UNUSED) {
REQUIRE(loopmgr != NULL);
adjustnofile();
isc_netmgr_create(mctx, loopmgr, &netmgr);
isc_netmgr_create(mctx, &netmgr);
return 0;
}
int
teardown_netmgr(void **state ISC_ATTR_UNUSED) {
REQUIRE(loopmgr != NULL);
isc_nm_detach(&netmgr);
return 0;

View File

@ -90,18 +90,18 @@ setup_server(void **state) {
ns_server_create(mctx, matchview, &sctx);
result = dns_dispatchmgr_create(mctx, loopmgr, netmgr, &dispatchmgr);
result = dns_dispatchmgr_create(mctx, netmgr, &dispatchmgr);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
result = ns_interfacemgr_create(mctx, sctx, loopmgr, netmgr,
dispatchmgr, NULL, &interfacemgr);
result = ns_interfacemgr_create(mctx, sctx, netmgr, dispatchmgr, NULL,
&interfacemgr);
if (result != ISC_R_SUCCESS) {
goto cleanup;
}
isc_loop_setup(mainloop, scan_interfaces, NULL);
isc_loop_setup(isc_loop_main(), scan_interfaces, NULL);
return 0;

Some files were not shown because too many files have changed in this diff Show More