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

View File

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

View File

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

View File

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

View File

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

View File

@ -764,9 +764,9 @@ readline_next_command(void *arg) {
UNUSED(arg); UNUSED(arg);
isc_loopmgr_blocking(loopmgr); isc_loopmgr_blocking();
ptr = readline("> "); ptr = readline("> ");
isc_loopmgr_nonblocking(loopmgr); isc_loopmgr_nonblocking();
if (ptr == NULL) { if (ptr == NULL) {
return; return;
} }
@ -840,7 +840,7 @@ start_next_command(void);
static void static void
process_next_command(void *arg ISC_ATTR_UNUSED) { 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) { if (cmdline == NULL) {
in_use = false; in_use = false;
} else { } else {
@ -856,15 +856,15 @@ process_next_command(void *arg ISC_ATTR_UNUSED) {
static void static void
start_next_command(void) { start_next_command(void) {
isc_loop_t *loop = isc_loop_main(loopmgr); isc_loop_t *loop = isc_loop_main();
if (!in_use) { if (!in_use) {
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
return; return;
} }
cmdline = NULL; cmdline = NULL;
isc_loopmgr_pause(loopmgr); isc_loopmgr_pause();
if (interactive) { if (interactive) {
isc_work_enqueue(loop, readline_next_command, isc_work_enqueue(loop, readline_next_command,
process_next_command, loop); process_next_command, loop);
@ -872,7 +872,7 @@ start_next_command(void) {
isc_work_enqueue(loop, fgets_next_command, process_next_command, isc_work_enqueue(loop, fgets_next_command, process_next_command,
loop); loop);
} }
isc_loopmgr_resume(loopmgr); isc_loopmgr_resume();
} }
static void static void
@ -911,13 +911,13 @@ main(int argc, char **argv) {
set_search_domain(domainopt); set_search_domain(domainopt);
} }
if (in_use) { if (in_use) {
isc_loopmgr_setup(loopmgr, run_loop, NULL); isc_loopmgr_setup(run_loop, NULL);
} else { } else {
isc_loopmgr_setup(loopmgr, read_loop, NULL); isc_loopmgr_setup(read_loop, NULL);
} }
in_use = !in_use; in_use = !in_use;
isc_loopmgr_run(loopmgr); isc_loopmgr_run();
puts(""); puts("");
debug("done, and starting to shut down"); 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 const char *directory = NULL, *dsdir = NULL;
static isc_mutex_t namelock; static isc_mutex_t namelock;
static isc_nm_t *netmgr = NULL; static isc_nm_t *netmgr = NULL;
static isc_loopmgr_t *loopmgr = NULL;
static dns_db_t *gdb; /* The database */ static dns_db_t *gdb; /* The database */
static dns_dbversion_t *gversion; /* The database version */ static dns_dbversion_t *gversion; /* The database version */
static dns_dbiterator_t *gdbiter; /* The database iterator */ static dns_dbiterator_t *gdbiter; /* The database iterator */
@ -1543,7 +1542,7 @@ assignwork(void *arg) {
if (atomic_load(&finished)) { if (atomic_load(&finished)) {
ended++; ended++;
if (ended == nloops) { if (ended == nloops) {
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
UNLOCK(&namelock); UNLOCK(&namelock);
return; return;
@ -1619,7 +1618,7 @@ assignwork(void *arg) {
if (!found) { if (!found) {
ended++; ended++;
if (ended == nloops) { if (ended == nloops) {
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
UNLOCK(&namelock); UNLOCK(&namelock);
return; return;
@ -3637,7 +3636,7 @@ main(int argc, char *argv[]) {
directory = "."; directory = ".";
} }
isc_managers_create(&mctx, nloops, &loopmgr, &netmgr); isc_managers_create(&mctx, nloops, &netmgr);
setup_logging(); setup_logging();
@ -3927,9 +3926,9 @@ main(int argc, char *argv[]) {
* There is more work to do. Spread it out over multiple * There is more work to do. Spread it out over multiple
* processors if possible. * processors if possible.
*/ */
isc_loopmgr_setup(loopmgr, assignwork, NULL); isc_loopmgr_setup(assignwork, NULL);
isc_loopmgr_teardown(loopmgr, abortwork, NULL); isc_loopmgr_teardown(abortwork, NULL);
isc_loopmgr_run(loopmgr); isc_loopmgr_run();
if (!atomic_load(&finished)) { if (!atomic_load(&finished)) {
fatal("process aborted by user"); fatal("process aborted by user");
@ -4007,7 +4006,7 @@ main(int argc, char *argv[]) {
isc_mem_stats(mctx, stdout); isc_mem_stats(mctx, stdout);
} }
isc_managers_destroy(&mctx, &loopmgr, &netmgr); isc_managers_destroy(&mctx, &netmgr);
if (printstats) { if (printstats) {
timer_finish = isc_time_now(); 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 */ /* Do not flush master files */
named_server_flushonshutdown(named_g_server, false); named_server_flushonshutdown(named_g_server, false);
named_os_shutdownmsg(cmdline, *text); named_os_shutdownmsg(cmdline, *text);
isc_loopmgr_shutdown(named_g_loopmgr); isc_loopmgr_shutdown();
result = ISC_R_SHUTTINGDOWN; result = ISC_R_SHUTTINGDOWN;
} else if (command_compare(command, NAMED_COMMAND_STOP)) { } 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 */ #endif /* ifdef HAVE_LIBSCF */
named_server_flushonshutdown(named_g_server, true); named_server_flushonshutdown(named_g_server, true);
named_os_shutdownmsg(cmdline, *text); named_os_shutdownmsg(cmdline, *text);
isc_loopmgr_shutdown(named_g_loopmgr); isc_loopmgr_shutdown();
result = ISC_R_SHUTTINGDOWN; result = ISC_R_SHUTTINGDOWN;
} else if (command_compare(command, NAMED_COMMAND_ADDZONE) || } else if (command_compare(command, NAMED_COMMAND_ADDZONE) ||
command_compare(command, NAMED_COMMAND_MODZONE)) 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); controlconnection_ref(conn);
/* Trigger the command asynchronously. */ /* Trigger the command asynchronously. */
isc_async_run(named_g_mainloop, control_command, conn); isc_async_run(isc_loop_main(), control_command, conn);
return; return;

View File

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

View File

@ -50,8 +50,6 @@
EXTERN isc_mem_t *named_g_mctx INIT(NULL); EXTERN isc_mem_t *named_g_mctx INIT(NULL);
EXTERN unsigned int named_g_cpus INIT(0); 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 bool named_g_loopmgr_running INIT(false);
EXTERN dns_dispatchmgr_t *named_g_dispatchmgr INIT(NULL); EXTERN dns_dispatchmgr_t *named_g_dispatchmgr INIT(NULL);
EXTERN unsigned int named_g_cpus_detected INIT(1); EXTERN unsigned int named_g_cpus_detected INIT(1);

View File

@ -970,8 +970,7 @@ create_managers(void) {
"thread count limit)" "thread count limit)"
: ""); : "");
isc_managers_create(&named_g_mctx, named_g_cpus, &named_g_loopmgr, isc_managers_create(&named_g_mctx, named_g_cpus, &named_g_netmgr);
&named_g_netmgr);
isc_nm_maxudp(named_g_netmgr, maxudp); isc_nm_maxudp(named_g_netmgr, maxudp);
@ -1472,7 +1471,7 @@ main(int argc, char *argv[]) {
* Pause the loop manager in fatal. * Pause the loop manager in fatal.
*/ */
named_g_loopmgr_running = true; named_g_loopmgr_running = true;
isc_loopmgr_run(named_g_loopmgr); isc_loopmgr_run();
#ifdef HAVE_LIBSCF #ifdef HAVE_LIBSCF
if (named_smf_want_disable == 1) { 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 #if ENABLE_LEAK_DETECTION
isc__crypto_setdestroycheck(true); 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; maps[i] = NULL;
dns_view_initsecroots(view); dns_view_initsecroots(view);
dns_view_initntatable(view, named_g_loopmgr); dns_view_initntatable(view);
if (auto_root && view->rdclass == dns_rdataclass_in) { if (auto_root && view->rdclass == dns_rdataclass_in) {
const cfg_obj_t *builtin_keys = NULL; 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; 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) { if (result != ISC_R_SUCCESS) {
return result; return result;
} }
@ -2330,7 +2330,7 @@ catz_addmodzone_cb(void *arg) {
ns_cfgctx_t *cfg = NULL; ns_cfgctx_t *cfg = NULL;
dns_zone_t *zone = 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; goto cleanup;
} }
@ -2469,7 +2469,7 @@ catz_addmodzone_cb(void *arg) {
zoneobj = cfg_listelt_value(cfg_list_first(zlist)); zoneobj = cfg_listelt_value(cfg_list_first(zlist));
/* Mark view unfrozen so that zone can be added */ /* Mark view unfrozen so that zone can be added */
isc_loopmgr_pause(named_g_loopmgr); isc_loopmgr_pause();
dns_view_thaw(cz->view); dns_view_thaw(cz->view);
result = configure_zone(cfg->config, zoneobj, cfg->vconfig, cz->view, result = configure_zone(cfg->config, zoneobj, cfg->vconfig, cz->view,
&cz->cbd->server->viewlist, &cz->cbd->server->viewlist,
@ -2477,7 +2477,7 @@ catz_addmodzone_cb(void *arg) {
&cz->cbd->server->keystorelist, cfg->actx, true, &cz->cbd->server->keystorelist, cfg->actx, true,
false, true, cz->mod); false, true, cz->mod);
dns_view_freeze(cz->view); dns_view_freeze(cz->view);
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume();
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER, isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
@ -2543,11 +2543,11 @@ catz_delzone_cb(void *arg) {
char cname[DNS_NAME_FORMATSIZE]; char cname[DNS_NAME_FORMATSIZE];
const char *file = NULL; 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; goto cleanup;
} }
isc_loopmgr_pause(named_g_loopmgr); isc_loopmgr_pause();
dns_name_format(dns_catz_entry_getname(cz->entry), cname, dns_name_format(dns_catz_entry_getname(cz->entry), cname,
DNS_NAME_FORMATSIZE); DNS_NAME_FORMATSIZE);
@ -2604,7 +2604,7 @@ catz_delzone_cb(void *arg) {
"zone '%s' deleted", "zone '%s' deleted",
cname); cname);
resume: resume:
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume();
cleanup: cleanup:
if (zone != NULL) { if (zone != NULL) {
dns_zone_detach(&zone); 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_catz_zone_attach(origin, &cz->origin);
dns_view_weakattach(view, &cz->view); 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; 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_zones_detach(&pview->catzs);
dns_catz_prereconfig(view->catzs); dns_catz_prereconfig(view->catzs);
} else { } else {
view->catzs = dns_catz_zones_new(view->mctx, named_g_loopmgr, view->catzs = dns_catz_zones_new(view->mctx,
&ns_catz_zonemodmethods); &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, 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"); "unable to create dnstap environment");
CHECKM(dns_dt_setupfile(named_g_server->dtenv, max_size, rolls, 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. * is simply a named cache that is not shared.
*/ */
if (cache == NULL) { if (cache == NULL) {
CHECK(dns_cache_create(named_g_loopmgr, view->rdclass, CHECK(dns_cache_create(view->rdclass, cachename, mctx,
cachename, mctx, &cache)); &cache));
} }
nsc = isc_mem_get(mctx, sizeof(*nsc)); 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) { if (dctx == NULL) {
const void *hashinit = isc_hash_get_initializer(); const void *hashinit = isc_hash_get_initializer();
dns_dyndb_createctx(mctx, hashinit, view, dns_dyndb_createctx(mctx, hashinit, view,
named_g_server->zonemgr, named_g_server->zonemgr, &dctx);
named_g_loopmgr, &dctx);
} }
CHECK(configure_dyndb(dyndb, mctx, 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); INSIST(view == NULL);
dns_view_create(named_g_mctx, named_g_loopmgr, named_g_dispatchmgr, dns_view_create(named_g_mctx, named_g_dispatchmgr, viewclass, viewname,
viewclass, viewname, &view); &view);
isc_nonce_buf(view->secret, sizeof(view->secret)); 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 * view->lock (dns_view_findzonecut) while holding keytable->lock
* (dns_keytable_forall) * (dns_keytable_forall)
*/ */
isc_async_run(named_g_mainloop, tat_send, tat); isc_async_run(isc_loop_main(), tat_send, tat);
} }
static void static void
@ -7011,7 +7010,7 @@ tat_timer_tick(void *arg) {
} }
dotat_arg.view = view; 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_forall(secroots, dotat, &dotat_arg);
dns_keytable_detach(&secroots); 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 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(kasplist);
ISC_LIST_INIT(keystorelist); ISC_LIST_INIT(keystorelist);
@ -7854,7 +7853,7 @@ apply_configuration(cfg_parser_t *configparser, cfg_obj_t *config,
ISC_LIST_INIT(altsecrets); ISC_LIST_INIT(altsecrets);
/* Ensure exclusive access to configuration data. */ /* Ensure exclusive access to configuration data. */
isc_loopmgr_pause(named_g_loopmgr); isc_loopmgr_pause();
/* Create the ACL configuration context */ /* Create the ACL configuration context */
if (named_g_aclconfctx != NULL) { 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 * listen-on option. This requires the loopmgr to be
* temporarily resumed. * temporarily resumed.
*/ */
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume();
result = ns_interfacemgr_scan(server->interfacemgr, true, true); 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 * 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(); named_g_defaultconfigtime = isc_time_now();
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume();
exclusive = false; exclusive = false;
/* Take back root privileges temporarily */ /* Take back root privileges temporarily */
@ -9195,7 +9194,7 @@ cleanup_bindkeys_parser:
cleanup_exclusive: cleanup_exclusive:
if (exclusive) { if (exclusive) {
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume();
} }
isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER, 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->server = server;
zl->reconfig = reconfig; zl->reconfig = reconfig;
isc_loopmgr_pause(named_g_loopmgr); isc_loopmgr_pause();
isc_refcount_init(&zl->refs, 1); isc_refcount_init(&zl->refs, 1);
@ -9368,7 +9367,7 @@ cleanup:
isc_mem_put(server->mctx, zl, sizeof(*zl)); isc_mem_put(server->mctx, zl, sizeof(*zl));
} }
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume();
return result; return result;
} }
@ -9381,8 +9380,8 @@ run_server(void *arg) {
dns_zonemgr_create(named_g_mctx, named_g_netmgr, &server->zonemgr); dns_zonemgr_create(named_g_mctx, named_g_netmgr, &server->zonemgr);
CHECKFATAL(dns_dispatchmgr_create(named_g_mctx, named_g_loopmgr, CHECKFATAL(dns_dispatchmgr_create(named_g_mctx, named_g_netmgr,
named_g_netmgr, &named_g_dispatchmgr), &named_g_dispatchmgr),
"creating dispatch manager"); "creating dispatch manager");
dns_dispatchmgr_setstats(named_g_dispatchmgr, server->resolverstats); dns_dispatchmgr_setstats(named_g_dispatchmgr, server->resolverstats);
@ -9394,18 +9393,17 @@ run_server(void *arg) {
#endif /* if defined(HAVE_GEOIP2) */ #endif /* if defined(HAVE_GEOIP2) */
CHECKFATAL(ns_interfacemgr_create(named_g_mctx, server->sctx, CHECKFATAL(ns_interfacemgr_create(named_g_mctx, server->sctx,
named_g_loopmgr, named_g_netmgr, named_g_netmgr, named_g_dispatchmgr,
named_g_dispatchmgr, geoip, geoip, &server->interfacemgr),
&server->interfacemgr),
"creating interface manager"); "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); &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); &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); &server->pps_timer);
CHECKFATAL(cfg_parser_create(named_g_mctx, &named_g_parser), CHECKFATAL(cfg_parser_create(named_g_mctx, &named_g_parser),
@ -9461,7 +9459,7 @@ shutdown_server(void *arg) {
named_statschannels_shutdown(server); named_statschannels_shutdown(server);
isc_loopmgr_pause(named_g_loopmgr); isc_loopmgr_pause();
isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER, isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
ISC_LOG_INFO, "shutting down%s", ISC_LOG_INFO, "shutting down%s",
@ -9523,7 +9521,7 @@ shutdown_server(void *arg) {
dns_db_detach(&server->in_roothints); dns_db_detach(&server->in_roothints);
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume();
} }
static isc_result_t 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; server->sctx->fuzznotify = named_fuzz_notify;
#endif /* ifdef ENABLE_AFL */ #endif /* ifdef ENABLE_AFL */
named_g_mainloop = isc_loop_main(named_g_loopmgr); isc_loop_setup(isc_loop_main(), run_server, server);
isc_loop_teardown(isc_loop_main(), shutdown_server, server);
isc_loop_setup(named_g_mainloop, run_server, server);
isc_loop_teardown(named_g_mainloop, shutdown_server, server);
/* Add SIGHUP reload handler */ /* Add SIGHUP reload handler */
server->sighup = isc_signal_new( server->sighup = isc_signal_new(named_server_reloadwanted, server,
named_g_loopmgr, named_server_reloadwanted, server, SIGHUP); SIGHUP);
/* Add SIGUSR2 closelogs handler */ /* Add SIGUSR2 closelogs handler */
server->sigusr1 = isc_signal_new( server->sigusr1 = isc_signal_new(named_server_closelogswanted, server,
named_g_loopmgr, named_server_closelogswanted, server, SIGUSR1); SIGUSR1);
isc_stats_create(server->mctx, &server->sockstats, isc_stats_create(server->mctx, &server->sockstats,
isc_sockstatscounter_max); isc_sockstatscounter_max);
@ -9888,7 +9884,7 @@ named_server_destroy(named_server_t **serverp) {
static void static void
fatal(const char *msg, isc_result_t result) { fatal(const char *msg, isc_result_t result) {
if (named_g_loopmgr_running) { 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_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
ISC_LOG_CRITICAL, "%s: %s", msg, ISC_LOG_CRITICAL, "%s: %s", msg,
@ -9975,7 +9971,7 @@ named_server_reloadwanted(void *arg, int signum) {
REQUIRE(signum == SIGHUP); 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); 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 #ifdef JEMALLOC_API_SUPPORTED
@ -11124,7 +11120,7 @@ resume:
dns_cache_getname(dctx->view->view->cache)); dns_cache_getname(dctx->view->view->cache));
result = dns_master_dumptostreamasync( result = dns_master_dumptostreamasync(
dctx->mctx, dctx->cache, NULL, style, dctx->fp, 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) { if (result == ISC_R_SUCCESS) {
return; return;
} }
@ -11551,7 +11547,7 @@ named_server_validation(named_server_t *server, isc_lex_t *lex,
/* Look for the view name. */ /* Look for the view name. */
ptr = next_token(lex, text); ptr = next_token(lex, text);
isc_loopmgr_pause(named_g_loopmgr); isc_loopmgr_pause();
ISC_LIST_FOREACH (server->viewlist, view, link) { ISC_LIST_FOREACH (server->viewlist, view, link) {
if ((ptr != NULL && strcasecmp(ptr, view->name) != 0) || if ((ptr != NULL && strcasecmp(ptr, view->name) != 0) ||
strcasecmp("_bind", 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; result = ISC_R_FAILURE;
} }
cleanup: cleanup:
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume();
return result; return result;
} }
@ -11607,7 +11603,7 @@ named_server_flushcache(named_server_t *server, isc_lex_t *lex) {
/* Look for the view name. */ /* Look for the view name. */
ptr = next_token(lex, NULL); ptr = next_token(lex, NULL);
isc_loopmgr_pause(named_g_loopmgr); isc_loopmgr_pause();
flushed = true; flushed = true;
found = false; found = false;
@ -11718,7 +11714,7 @@ named_server_flushcache(named_server_t *server, isc_lex_t *lex) {
result = ISC_R_FAILURE; result = ISC_R_FAILURE;
} }
} }
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume();
return result; return result;
} }
@ -11757,7 +11753,7 @@ named_server_flushnode(named_server_t *server, isc_lex_t *lex, bool tree) {
/* Look for the view name. */ /* Look for the view name. */
viewname = next_token(lex, NULL); viewname = next_token(lex, NULL);
isc_loopmgr_pause(named_g_loopmgr); isc_loopmgr_pause();
flushed = true; flushed = true;
found = false; found = false;
ISC_LIST_FOREACH (server->viewlist, view, link) { 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; result = ISC_R_FAILURE;
} }
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume();
return result; return result;
} }
@ -12102,7 +12098,7 @@ named_server_sync(named_server_t *server, isc_lex_t *lex, isc_buffer_t **text) {
} }
if (zone == NULL) { if (zone == NULL) {
isc_loopmgr_pause(named_g_loopmgr); isc_loopmgr_pause();
tresult = ISC_R_SUCCESS; tresult = ISC_R_SUCCESS;
ISC_LIST_FOREACH (server->viewlist, view, link) { ISC_LIST_FOREACH (server->viewlist, view, link) {
result = dns_view_apply(view, false, NULL, synczone, 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; tresult = result;
} }
} }
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume();
isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER, isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
ISC_LOG_INFO, "dumping all zones%s: %s", ISC_LOG_INFO, "dumping all zones%s: %s",
cleanup ? ", removing journal files" : "", 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; return tresult;
} }
isc_loopmgr_pause(named_g_loopmgr); isc_loopmgr_pause();
result = synczone(zone, &cleanup); result = synczone(zone, &cleanup);
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume();
dns_view_t *view = dns_zone_getview(zone); dns_view_t *view = dns_zone_getview(zone);
if (strcmp(view->name, "_default") == 0 || 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; return result;
} }
if (mayberaw == NULL) { if (mayberaw == NULL) {
isc_loopmgr_pause(named_g_loopmgr); isc_loopmgr_pause();
tresult = ISC_R_SUCCESS; tresult = ISC_R_SUCCESS;
ISC_LIST_FOREACH (server->viewlist, view, link) { ISC_LIST_FOREACH (server->viewlist, view, link) {
result = dns_view_freezezones(view, freeze); 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; tresult = result;
} }
} }
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume();
isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER, isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
ISC_LOG_INFO, "%s all zones: %s", ISC_LOG_INFO, "%s all zones: %s",
freeze ? "freezing" : "thawing", freeze ? "freezing" : "thawing",
@ -12201,7 +12197,7 @@ named_server_freeze(named_server_t *server, bool freeze, isc_lex_t *lex,
return DNS_R_NOTDYNAMIC; return DNS_R_NOTDYNAMIC;
} }
isc_loopmgr_pause(named_g_loopmgr); isc_loopmgr_pause();
frozen = dns_zone_getupdatedisabled(mayberaw); frozen = dns_zone_getupdatedisabled(mayberaw);
if (freeze) { if (freeze) {
if (frozen) { 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) { if (msg != NULL) {
(void)putstr(text, msg); (void)putstr(text, msg);
@ -13122,7 +13118,7 @@ do_addzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
goto cleanup; goto cleanup;
} }
isc_loopmgr_pause(named_g_loopmgr); isc_loopmgr_pause();
#ifndef HAVE_LMDB #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); result = isc_stdio_open(view->new_zone_file, "a", &fp);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume();
TCHECK(putstr(text, "unable to create '")); TCHECK(putstr(text, "unable to create '"));
TCHECK(putstr(text, view->new_zone_file)); TCHECK(putstr(text, view->new_zone_file));
TCHECK(putstr(text, "': ")); 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 */ /* Make sure we can open the NZD database */
result = nzd_writable(view); result = nzd_writable(view);
if (result != ISC_R_SUCCESS) { 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, "unable to open NZD database for '"));
TCHECK(putstr(text, view->new_zone_db)); TCHECK(putstr(text, view->new_zone_db));
TCHECK(putstr(text, "'")); 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, NULL, NULL, NULL, view->name,
view->rdclass, cfg->actx, cfg->mctx); view->rdclass, cfg->actx, cfg->mctx);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume();
goto cleanup; goto cleanup;
} }
@ -13175,7 +13171,7 @@ do_addzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
false, false); false, false);
dns_view_freeze(view); dns_view_freeze(view);
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume();
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
TCHECK(putstr(text, "configure_zone failed: ")); 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 */ #endif /* ifndef HAVE_LMDB */
isc_loopmgr_pause(named_g_loopmgr); isc_loopmgr_pause();
#ifndef HAVE_LMDB #ifndef HAVE_LMDB
/* Make sure we can open the configuration save file */ /* 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, view->new_zone_file));
TCHECK(putstr(text, "': ")); TCHECK(putstr(text, "': "));
TCHECK(putstr(text, isc_result_totext(result))); TCHECK(putstr(text, isc_result_totext(result)));
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume();
goto cleanup; goto cleanup;
} }
(void)isc_stdio_close(fp); (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, view->new_zone_db));
TCHECK(putstr(text, "'")); TCHECK(putstr(text, "'"));
result = ISC_R_FAILURE; result = ISC_R_FAILURE;
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume();
goto cleanup; goto cleanup;
} }
#endif /* HAVE_LMDB */ #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, NULL, NULL, NULL, view->name,
view->rdclass, cfg->actx, cfg->mctx); view->rdclass, cfg->actx, cfg->mctx);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume();
goto cleanup; goto cleanup;
} }
@ -13373,7 +13369,7 @@ do_modzone(named_server_t *server, ns_cfgctx_t *cfg, dns_view_t *view,
false, true); false, true);
dns_view_freeze(view); dns_view_freeze(view);
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume();
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
TCHECK(putstr(text, "configure_zone failed: ")); 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(); now = isc_stdtime_now();
isc_loopmgr_pause(named_g_loopmgr); isc_loopmgr_pause();
ISC_LIST_FOREACH (server->viewlist, view, link) { ISC_LIST_FOREACH (server->viewlist, view, link) {
if (viewname != NULL && strcmp(view->name, viewname) != 0) { if (viewname != NULL && strcmp(view->name, viewname) != 0) {
continue; continue;
@ -15244,7 +15240,7 @@ named_server_nta(named_server_t *server, isc_lex_t *lex, bool readonly,
} }
cleanup_exclusive: cleanup_exclusive:
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume();
cleanup: cleanup:
@ -15327,7 +15323,7 @@ mkey_destroy(dns_view_t *view, isc_buffer_t **text) {
view->name); view->name);
CHECK(putstr(text, msg)); CHECK(putstr(text, msg));
isc_loopmgr_pause(named_g_loopmgr); isc_loopmgr_pause();
/* Remove and clean up managed keys zone from view */ /* Remove and clean up managed keys zone from view */
mkzone = view->managed_keys; mkzone = view->managed_keys;
@ -15370,7 +15366,7 @@ mkey_destroy(dns_view_t *view, isc_buffer_t **text) {
result = ISC_R_SUCCESS; result = ISC_R_SUCCESS;
cleanup: cleanup:
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume();
return result; 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) { ISC_LIST_FOREACH (server->viewlist, view, link) {
dns_ttl_t stale_ttl = 0; dns_ttl_t stale_ttl = 0;
@ -15957,7 +15953,7 @@ named_server_servestale(named_server_t *server, isc_lex_t *lex,
} }
cleanup: cleanup:
isc_loopmgr_resume(named_g_loopmgr); isc_loopmgr_resume();
if (isc_buffer_usedlength(*text) > 0) { if (isc_buffer_usedlength(*text) > 0) {
(void)putnull(text); (void)putnull(text);

View File

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

View File

@ -58,7 +58,6 @@
bool verbose; bool verbose;
static isc_nm_t *netmgr = NULL; static isc_nm_t *netmgr = NULL;
static isc_loopmgr_t *loopmgr = NULL;
static const char *admin_conffile = NULL; static const char *admin_conffile = NULL;
static const char *admin_keyfile = 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_sexpr_free(&response);
isccc_ccmsg_disconnect(ccmsg); isccc_ccmsg_disconnect(ccmsg);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
static void static void
@ -952,8 +951,8 @@ main(int argc, char **argv) {
serial = isc_random32(); serial = isc_random32();
isc_managers_create(&rndc_mctx, 1, &loopmgr, &netmgr); isc_managers_create(&rndc_mctx, 1, &netmgr);
isc_loopmgr_setup(loopmgr, rndc_start, NULL); isc_loopmgr_setup(rndc_start, NULL);
isc_nm_setinitialtimeout(netmgr, timeout); isc_nm_setinitialtimeout(netmgr, timeout);
isc_nm_setprimariestimeout(netmgr, timeout); isc_nm_setprimariestimeout(netmgr, timeout);
@ -1000,7 +999,7 @@ main(int argc, char **argv) {
get_addresses(servername, (in_port_t)remoteport); get_addresses(servername, (in_port_t)remoteport);
} }
isc_loopmgr_run(loopmgr); isc_loopmgr_run();
isccc_ccmsg_invalidate(&rndc_ccmsg); isccc_ccmsg_invalidate(&rndc_ccmsg);
@ -1015,7 +1014,7 @@ main(int argc, char **argv) {
isc_mem_stats(rndc_mctx, stderr); isc_mem_stats(rndc_mctx, stderr);
} }
isc_managers_destroy(&rndc_mctx, &loopmgr, &netmgr); isc_managers_destroy(&rndc_mctx, &netmgr);
if (failed) { if (failed) {
return 1; 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_view_attach(dctx->view, &inst->view);
dns_zonemgr_attach(dctx->zmgr, &inst->zmgr); dns_zonemgr_attach(dctx->zmgr, &inst->zmgr);
inst->loopmgr = dctx->loopmgr;
/* Register new DNS DB implementation. */ /* Register new DNS DB implementation. */
result = dns_db_register(db_name, create_db, inst, mctx, &inst->db_imp); 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. */ /* These are needed for zone creation. */
dns_view_t *view; dns_view_t *view;
dns_zonemgr_t *zmgr; dns_zonemgr_t *zmgr;
isc_loopmgr_t *loopmgr;
bool exiting; bool exiting;
dns_zone_t *zone1; dns_zone_t *zone1;

View File

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

View File

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

View File

@ -83,7 +83,6 @@
#define MAXTRIES 0xffffffff #define MAXTRIES 0xffffffff
static isc_mem_t *mctx = NULL; static isc_mem_t *mctx = NULL;
static isc_loopmgr_t *loopmgr = NULL;
static dns_requestmgr_t *requestmgr = NULL; static dns_requestmgr_t *requestmgr = NULL;
static const char *batchname = NULL; static const char *batchname = NULL;
static FILE *batchfp = NULL; static FILE *batchfp = NULL;
@ -522,7 +521,7 @@ cleanup:
dns_request_destroy(&request); dns_request_destroy(&request);
if (--onfly == 0) { if (--onfly == 0) {
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
return; return;
} }
@ -731,7 +730,7 @@ sendquery(struct query *query) {
result = dns_request_create( result = dns_request_create(
requestmgr, message, have_src ? &srcaddr : NULL, &dstaddr, NULL, requestmgr, message, have_src ? &srcaddr : NULL, &dstaddr, NULL,
NULL, options, NULL, query->timeout, query->timeout, 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); recvresponse, message, &request);
CHECK("dns_request_create", result); CHECK("dns_request_create", result);
@ -750,7 +749,7 @@ sendqueries(void *arg) {
} }
if (onfly == 0) { if (onfly == 0) {
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
} }
@ -2058,7 +2057,7 @@ teardown(void *arg ISC_ATTR_UNUSED) {
static void static void
setup(void *arg ISC_ATTR_UNUSED) { 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); set_source_ports(dispatchmgr);
@ -2071,10 +2070,10 @@ setup(void *arg ISC_ATTR_UNUSED) {
dispatchmgr, have_src ? &srcaddr : &bind_any, &dispatchvx)); dispatchmgr, have_src ? &srcaddr : &bind_any, &dispatchvx));
RUNCHECK(dns_requestmgr_create( RUNCHECK(dns_requestmgr_create(
mctx, loopmgr, dispatchmgr, have_ipv4 ? dispatchvx : NULL, mctx, dispatchmgr, have_ipv4 ? dispatchvx : NULL,
have_ipv6 ? dispatchvx : NULL, &requestmgr)); 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 */ /*% Main processing routine for mdig */
@ -2096,7 +2095,7 @@ main(int argc, char *argv[]) {
preparse_args(argc, 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)); 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"); fatal("can't choose between IPv4 and IPv6");
} }
isc_loopmgr_setup(loopmgr, setup, NULL); isc_loopmgr_setup(setup, NULL);
isc_loopmgr_setup(loopmgr, sendqueries, ISC_LIST_HEAD(queries)); isc_loopmgr_setup(sendqueries, ISC_LIST_HEAD(queries));
isc_loopmgr_teardown(loopmgr, teardown, NULL); isc_loopmgr_teardown(teardown, NULL);
/* /*
* Stall to the start of a new second. * Stall to the start of a new second.
@ -2154,7 +2153,7 @@ main(int argc, char *argv[]) {
} while (1); } while (1);
} }
isc_loopmgr_run(loopmgr); isc_loopmgr_run();
ISC_LIST_FOREACH (queries, query, link) { ISC_LIST_FOREACH (queries, query, link) {
if (query->ednsopts != NULL) { if (query->ednsopts != NULL) {
@ -2176,6 +2175,6 @@ main(int argc, char *argv[]) {
isc_mem_free(mctx, default_query.ecs_addr); isc_mem_free(mctx, default_query.ecs_addr);
} }
isc_managers_destroy(&mctx, &loopmgr, &netmgr); isc_managers_destroy(&mctx, &netmgr);
return 0; 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 This document aims to describe the design of the basic event loop handling in
the BIND 9. the BIND 9.
Every application is expected to create and use a single ``isc_loopmgr_t`` Every application is expected to run ``isc_loopmgr_create()``, either
instance. directly or indirectly via ``isc_managers_create()``. This creates a
single loop manager.
## Event Loops ## Event Loops

View File

@ -86,7 +86,6 @@ static isc_mem_t *mctx = NULL;
#define HMACSHA256 "\x0bhmac-sha256" #define HMACSHA256 "\x0bhmac-sha256"
static isc_stdtime_t fuzztime = 0x622acce1; static isc_stdtime_t fuzztime = 0x622acce1;
static isc_loopmgr_t *loopmgr = NULL;
static dns_view_t *view = NULL; static dns_view_t *view = NULL;
static dns_tsigkey_t *tsigkey = NULL; static dns_tsigkey_t *tsigkey = NULL;
static dns_tsigkeyring_t *ring = 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_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, &ring);
dns_tsigkeyring_create(mctx, &emptyring); dns_tsigkeyring_create(mctx, &emptyring);

View File

@ -104,7 +104,6 @@ typedef struct dns_adblru {
struct dns_adb { struct dns_adb {
unsigned int magic; unsigned int magic;
uint32_t nloops; uint32_t nloops;
isc_loopmgr_t *loopmgr;
isc_mutex_t lock; isc_mutex_t lock;
isc_mem_t *mctx; isc_mem_t *mctx;
@ -1608,18 +1607,16 @@ ISC_REFCOUNT_IMPL(dns_adb, dns_adb_destroy);
*/ */
void void
dns_adb_create(isc_mem_t *mem, isc_loopmgr_t *loopmgr, dns_view_t *view, dns_adb_create(isc_mem_t *mem, dns_view_t *view, dns_adb_t **adbp) {
dns_adb_t **adbp) {
REQUIRE(mem != NULL); REQUIRE(mem != NULL);
REQUIRE(view != NULL); REQUIRE(view != NULL);
REQUIRE(adbp != NULL && *adbp == 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)); dns_adb_t *adb = isc_mem_get(mem, sizeof(dns_adb_t));
*adb = (dns_adb_t){ *adb = (dns_adb_t){
.references = 1, .references = 1,
.nloops = nloops, .nloops = nloops,
.loopmgr = loopmgr,
.magic = DNS_ADB_MAGIC, .magic = DNS_ADB_MAGIC,
}; };
@ -1696,7 +1693,7 @@ dns_adb_shutdown(dns_adb_t *adb) {
* shutting down ADB. * shutting down ADB.
*/ */
dns_adb_ref(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); bcentry_alive(struct cds_lfht *ht, dns_bcentry_t *bad, isc_stdtime_t now);
dns_badcache_t * dns_badcache_t *
dns_badcache_new(isc_mem_t *mctx, isc_loopmgr_t *loopmgr) { dns_badcache_new(isc_mem_t *mctx) {
REQUIRE(loopmgr != NULL); uint32_t nloops = isc_loopmgr_nloops();
uint32_t nloops = isc_loopmgr_nloops(loopmgr);
dns_badcache_t *bc = isc_mem_get(mctx, sizeof(*bc)); dns_badcache_t *bc = isc_mem_get(mctx, sizeof(*bc));
*bc = (dns_badcache_t){ *bc = (dns_badcache_t){
.magic = BADCACHE_MAGIC, .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 *mctx; /* Memory context for the dns_cache object */
isc_mem_t *hmctx; /* Heap memory */ isc_mem_t *hmctx; /* Heap memory */
isc_mem_t *tmctx; /* Tree memory */ isc_mem_t *tmctx; /* Tree memory */
isc_loopmgr_t *loopmgr;
char *name; char *name;
isc_refcount_t references; 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 * XXX this is only used by the RBT cache, and can
* be removed when it is. * be removed when it is.
*/ */
dns_db_setloop(db, isc_loop_main(cache->loopmgr)); dns_db_setloop(db, isc_loop_main());
*dbp = db; *dbp = db;
*hmctxp = hmctx; *hmctxp = hmctx;
@ -167,12 +166,11 @@ cache_destroy(dns_cache_t *cache) {
} }
isc_result_t isc_result_t
dns_cache_create(isc_loopmgr_t *loopmgr, dns_rdataclass_t rdclass, dns_cache_create(dns_rdataclass_t rdclass, const char *cachename,
const char *cachename, isc_mem_t *mctx, dns_cache_t **cachep) { isc_mem_t *mctx, dns_cache_t **cachep) {
isc_result_t result; isc_result_t result;
dns_cache_t *cache = NULL; dns_cache_t *cache = NULL;
REQUIRE(loopmgr != NULL);
REQUIRE(cachename != NULL); REQUIRE(cachename != NULL);
REQUIRE(cachep != NULL && *cachep == 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){ *cache = (dns_cache_t){
.rdclass = rdclass, .rdclass = rdclass,
.name = isc_mem_strdup(mctx, cachename), .name = isc_mem_strdup(mctx, cachename),
.loopmgr = loopmgr,
.references = ISC_REFCOUNT_INITIALIZER(1), .references = ISC_REFCOUNT_INITIALIZER(1),
.magic = CACHE_MAGIC, .magic = CACHE_MAGIC,
}; };

View File

@ -142,7 +142,6 @@ struct dns_catz_zones {
isc_refcount_t references; isc_refcount_t references;
isc_mutex_t lock; isc_mutex_t lock;
dns_catz_zonemodmethods_t *zmm; dns_catz_zonemodmethods_t *zmm;
isc_loopmgr_t *loopmgr;
dns_view_t *view; dns_view_t *view;
atomic_bool shuttingdown; 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_t *
dns_catz_zones_new(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, dns_catz_zones_new(isc_mem_t *mctx, dns_catz_zonemodmethods_t *zmm) {
dns_catz_zonemodmethods_t *zmm) {
REQUIRE(mctx != NULL); REQUIRE(mctx != NULL);
REQUIRE(loopmgr != NULL);
REQUIRE(zmm != NULL); REQUIRE(zmm != NULL);
dns_catz_zones_t *catzs = isc_mem_get(mctx, sizeof(*catzs)); 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, .zmm = zmm,
.magic = DNS_CATZ_ZONES_MAGIC }; .magic = DNS_CATZ_ZONES_MAGIC,
};
isc_mutex_init(&catzs->lock); isc_mutex_init(&catzs->lock);
isc_refcount_init(&catzs->references, 1); isc_refcount_init(&catzs->references, 1);

View File

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

View File

@ -969,7 +969,7 @@ setavailports(dns_dispatchmgr_t *mgr, isc_portset_t *v4portset,
*/ */
isc_result_t 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 **mgrp) {
dns_dispatchmgr_t *mgr = NULL; dns_dispatchmgr_t *mgr = NULL;
isc_portset_t *v4portset = 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 = isc_mem_get(mctx, sizeof(dns_dispatchmgr_t));
*mgr = (dns_dispatchmgr_t){ *mgr = (dns_dispatchmgr_t){
.magic = 0, .magic = 0,
.nloops = isc_loopmgr_nloops(loopmgr), .nloops = isc_loopmgr_nloops(),
}; };
#if DNS_DISPATCH_TRACE #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_file_options *ffwopt = NULL;
struct fstrm_writer_options *fwopt = NULL; struct fstrm_writer_options *fwopt = NULL;
struct fstrm_writer *fw = NULL; struct fstrm_writer *fw = NULL;
isc_loopmgr_t *loopmgr = NULL;
REQUIRE(VALID_DTENV(env)); REQUIRE(VALID_DTENV(env));
loopmgr = isc_loop_getloopmgr(env->loop); isc_loopmgr_pause();
isc_loopmgr_pause(loopmgr);
/* /*
* Check that we can create a new fw object. * Check that we can create a new fw object.
@ -379,7 +377,7 @@ cleanup:
fstrm_writer_options_destroy(&fwopt); fstrm_writer_options_destroy(&fwopt);
} }
isc_loopmgr_resume(loopmgr); isc_loopmgr_resume();
return result; return result;
} }

View File

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

View File

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

View File

@ -56,7 +56,7 @@
***/ ***/
dns_badcache_t * 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'. * Allocate and initialize a badcache and store it in '*bcp'.
* *

View File

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

View File

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

View File

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

View File

@ -75,8 +75,7 @@ typedef enum dns_dispatchopt {
} dns_dispatchopt_t; } dns_dispatchopt_t;
isc_result_t 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 **mgrp);
/*%< /*%<
* Creates a new dispatchmgr object, and sets the available ports * Creates a new dispatchmgr object, and sets the available ports
* to the default range (1024-65535). * to the default range (1024-65535).

View File

@ -36,7 +36,6 @@ struct dns_dyndbctx {
isc_mem_t *mctx; isc_mem_t *mctx;
dns_view_t *view; dns_view_t *view;
dns_zonemgr_t *zmgr; dns_zonemgr_t *zmgr;
isc_loopmgr_t *loopmgr;
const bool *refvar; /* unused, but retained for API compatibility */ const bool *refvar; /* unused, but retained for API compatibility */
}; };
@ -124,8 +123,7 @@ dns_dyndb_cleanup(void);
void void
dns_dyndb_createctx(isc_mem_t *mctx, const void *hashinit, dns_view_t *view, dns_dyndb_createctx(isc_mem_t *mctx, const void *hashinit, dns_view_t *view,
dns_zonemgr_t *zmgr, isc_loopmgr_t *loopmgr, dns_zonemgr_t *zmgr, dns_dyndbctx_t **dctxp);
dns_dyndbctx_t **dctxp);
/*% /*%
* Create a dyndb initialization context structure, with * Create a dyndb initialization context structure, with
* pointers to structures in the server that the dyndb module will * 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) #define VALID_NTATABLE(nt) ISC_MAGIC_VALID(nt, NTATABLE_MAGIC)
void void
dns_ntatable_create(dns_view_t *view, isc_loopmgr_t *loopmgr, dns_ntatable_create(dns_view_t *view, dns_ntatable_t **ntatablep);
dns_ntatable_t **ntatablep);
/*%< /*%<
* Create an NTA table in view 'view'. * Create an NTA table in view 'view'.
* *

View File

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

View File

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

View File

@ -212,7 +212,6 @@ struct dns_rpz_zones {
unsigned int magic; unsigned int magic;
isc_refcount_t references; isc_refcount_t references;
isc_mem_t *mctx; isc_mem_t *mctx;
isc_loopmgr_t *loopmgr;
dns_rpz_popt_t p; dns_rpz_popt_t p;
dns_rpz_zone_t *zones[DNS_RPZ_MAX_ZONES]; 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); dns_name_t *selfname);
isc_result_t isc_result_t
dns_rpz_new_zones(dns_view_t *view, isc_loopmgr_t *loopmgr, dns_rpz_new_zones(dns_view_t *view, dns_rpz_zones_t **rpzsp);
dns_rpz_zones_t **rpzsp);
isc_result_t isc_result_t
dns_rpz_new_zone(dns_rpz_zones_t *rpzs, dns_rpz_zone_t **rpzp); 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_t *
dns_unreachcache_new(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, dns_unreachcache_new(isc_mem_t *mctx, const uint16_t expire_min_s,
const uint16_t expire_min_s, const uint16_t expire_max_s, const uint16_t expire_max_s,
const uint16_t backoff_eligible_s); const uint16_t backoff_eligible_s);
/*% /*%
* Allocate and initialize an unreachable cache. A newly entered entry expires * Allocate and initialize an unreachable cache. A newly entered entry expires

View File

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

View File

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

View File

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

View File

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

View File

@ -551,7 +551,6 @@ struct dns_resolver {
isc_mutex_t lock; isc_mutex_t lock;
isc_mutex_t primelock; isc_mutex_t primelock;
dns_rdataclass_t rdclass; dns_rdataclass_t rdclass;
isc_loopmgr_t *loopmgr;
isc_nm_t *nm; isc_nm_t *nm;
dns_view_t *view; dns_view_t *view;
bool frozen; bool frozen;
@ -9849,8 +9848,8 @@ spillattimer_countdown(void *arg) {
} }
isc_result_t isc_result_t
dns_resolver_create(dns_view_t *view, isc_loopmgr_t *loopmgr, isc_nm_t *nm, dns_resolver_create(dns_view_t *view, isc_nm_t *nm, unsigned int options,
unsigned int options, isc_tlsctx_cache_t *tlsctx_cache, isc_tlsctx_cache_t *tlsctx_cache,
dns_dispatch_t *dispatchv4, dns_dispatch_t *dispatchv6, dns_dispatch_t *dispatchv4, dns_dispatch_t *dispatchv6,
dns_resolver_t **resp) { dns_resolver_t **resp) {
dns_resolver_t *res = NULL; 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 = isc_mem_get(view->mctx, sizeof(*res));
*res = (dns_resolver_t){ *res = (dns_resolver_t){
.loopmgr = loopmgr,
.rdclass = view->rdclass, .rdclass = view->rdclass,
.nm = nm, .nm = nm,
.options = options, .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, .maxdepth = DEFAULT_RECURSION_DEPTH,
.maxqueries = DEFAULT_MAX_QUERIES, .maxqueries = DEFAULT_MAX_QUERIES,
.alternates = ISC_LIST_INITIALIZER, .alternates = ISC_LIST_INITIALIZER,
.nloops = isc_loopmgr_nloops(loopmgr), .nloops = isc_loopmgr_nloops(),
.maxvalidations = DEFAULT_MAX_VALIDATIONS, .maxvalidations = DEFAULT_MAX_VALIDATIONS,
.maxvalidationfails = DEFAULT_MAX_VALIDATION_FAILURES, .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, res->rdspools = isc_mem_cget(res->mctx, res->nloops,
sizeof(res->rdspools[0])); sizeof(res->rdspools[0]));
for (size_t i = 0; i < res->nloops; i++) { 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); isc_mem_t *pool_mctx = isc_loop_getmctx(loop);
dns_message_createpools(pool_mctx, &res->namepools[i], 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); isc_stats_attach(stats, &res->stats);
/* initialize the bucket "counter"; it's a static value */ /* initialize the bucket "counter"; it's a static value */
set_stats(res, dns_resstatscounter_buckets, set_stats(res, dns_resstatscounter_buckets, isc_loopmgr_nloops());
isc_loopmgr_nloops(res->loopmgr));
} }
void 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. * Get ready for a new set of policy zones for a view.
*/ */
isc_result_t isc_result_t
dns_rpz_new_zones(dns_view_t *view, isc_loopmgr_t *loopmgr, dns_rpz_new_zones(dns_view_t *view, dns_rpz_zones_t **rpzsp) {
dns_rpz_zones_t **rpzsp) {
dns_rpz_zones_t *rpzs = NULL; dns_rpz_zones_t *rpzs = NULL;
isc_mem_t *mctx = 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 = isc_mem_get(mctx, sizeof(*rpzs));
*rpzs = (dns_rpz_zones_t){ *rpzs = (dns_rpz_zones_t){
.loopmgr = loopmgr,
.magic = DNS_RPZ_ZONES_MAGIC, .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); bool alive_or_waiting);
dns_unreachcache_t * dns_unreachcache_t *
dns_unreachcache_new(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, dns_unreachcache_new(isc_mem_t *mctx, const uint16_t expire_min_s,
const uint16_t expire_min_s, const uint16_t expire_max_s, const uint16_t expire_max_s,
const uint16_t backoff_eligible_s) { const uint16_t backoff_eligible_s) {
REQUIRE(loopmgr != NULL);
REQUIRE(expire_min_s > 0); REQUIRE(expire_min_s > 0);
REQUIRE(expire_min_s <= expire_max_s); 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)); dns_unreachcache_t *uc = isc_mem_get(mctx, sizeof(*uc));
*uc = (dns_unreachcache_t){ *uc = (dns_unreachcache_t){
.magic = UNREACHCACHE_MAGIC, .magic = UNREACHCACHE_MAGIC,

View File

@ -21,6 +21,7 @@
#include <lmdb.h> #include <lmdb.h>
#endif /* ifdef HAVE_LMDB */ #endif /* ifdef HAVE_LMDB */
#include <isc/async.h>
#include <isc/atomic.h> #include <isc/atomic.h>
#include <isc/dir.h> #include <isc/dir.h>
#include <isc/file.h> #include <isc/file.h>
@ -91,9 +92,9 @@
#define UNREACH_BACKOFF_ELIGIBLE_SEC ((uint16_t)120) #define UNREACH_BACKOFF_ELIGIBLE_SEC ((uint16_t)120)
void void
dns_view_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, dns_view_create(isc_mem_t *mctx, dns_dispatchmgr_t *dispatchmgr,
dns_dispatchmgr_t *dispatchmgr, dns_rdataclass_t rdclass, dns_rdataclass_t rdclass, const char *name,
const char *name, dns_view_t **viewp) { dns_view_t **viewp) {
dns_view_t *view = NULL; dns_view_t *view = NULL;
isc_result_t result; isc_result_t result;
char buffer[1024]; 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); 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->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); UNREACH_HOLD_TIME_MAX_SEC, UNREACH_BACKOFF_ELIGIBLE_SEC);
isc_mutex_init(&view->new_zone_lock); isc_mutex_init(&view->new_zone_lock);
@ -393,6 +394,107 @@ dns_view_attach(dns_view_t *source, dns_view_t **targetp) {
*targetp = source; *targetp = source;
} }
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;
dns_adb_t *adb = NULL;
dns_requestmgr_t *requestmgr = NULL;
dns_dispatchmgr_t *dispatchmgr = NULL;
isc_refcount_destroy(&view->references);
/* Shutdown the attached objects first */
if (view->resolver != NULL) {
dns_resolver_shutdown(view->resolver);
}
rcu_read_lock();
adb = rcu_dereference(view->adb);
if (adb != NULL) {
dns_adb_shutdown(adb);
}
rcu_read_unlock();
if (view->requestmgr != NULL) {
dns_requestmgr_shutdown(view->requestmgr);
}
/* Swap the pointers under the lock */
LOCK(&view->lock);
if (view->resolver != NULL) {
resolver = view->resolver;
view->resolver = NULL;
}
rcu_read_lock();
zonetable = rcu_xchg_pointer(&view->zonetable, NULL);
if (zonetable != NULL) {
if (view->flush) {
dns_zt_flush(zonetable);
}
}
adb = rcu_xchg_pointer(&view->adb, NULL);
dispatchmgr = rcu_xchg_pointer(&view->dispatchmgr, NULL);
rcu_read_unlock();
if (view->requestmgr != NULL) {
requestmgr = view->requestmgr;
view->requestmgr = NULL;
}
if (view->managed_keys != NULL) {
mkzone = view->managed_keys;
view->managed_keys = NULL;
if (view->flush) {
dns_zone_flush(mkzone);
}
}
if (view->redirect != NULL) {
rdzone = view->redirect;
view->redirect = NULL;
if (view->flush) {
dns_zone_flush(rdzone);
}
}
if (view->catzs != NULL) {
dns_catz_zones_shutdown(view->catzs);
dns_catz_zones_detach(&view->catzs);
}
if (view->ntatable_priv != NULL) {
dns_ntatable_shutdown(view->ntatable_priv);
}
UNLOCK(&view->lock);
/* Detach outside view lock */
if (resolver != NULL) {
dns_resolver_detach(&resolver);
}
synchronize_rcu();
if (dispatchmgr != NULL) {
dns_dispatchmgr_detach(&dispatchmgr);
}
if (adb != NULL) {
dns_adb_detach(&adb);
}
if (zonetable != NULL) {
dns_zt_detach(&zonetable);
}
if (requestmgr != NULL) {
dns_requestmgr_detach(&requestmgr);
}
if (mkzone != NULL) {
dns_zone_detach(&mkzone);
}
if (rdzone != NULL) {
dns_zone_detach(&rdzone);
}
dns_view_weakdetach(&view);
}
void void
dns_view_detach(dns_view_t **viewp) { dns_view_detach(dns_view_t **viewp) {
dns_view_t *view = NULL; dns_view_t *view = NULL;
@ -403,102 +505,7 @@ dns_view_detach(dns_view_t **viewp) {
*viewp = NULL; *viewp = NULL;
if (isc_refcount_decrement(&view->references) == 1) { if (isc_refcount_decrement(&view->references) == 1) {
dns_zone_t *mkzone = NULL, *rdzone = NULL; shutdown_view(view);
dns_zt_t *zonetable = NULL;
dns_resolver_t *resolver = NULL;
dns_adb_t *adb = NULL;
dns_requestmgr_t *requestmgr = NULL;
dns_dispatchmgr_t *dispatchmgr = NULL;
isc_refcount_destroy(&view->references);
/* Shutdown the attached objects first */
if (view->resolver != NULL) {
dns_resolver_shutdown(view->resolver);
}
rcu_read_lock();
adb = rcu_dereference(view->adb);
if (adb != NULL) {
dns_adb_shutdown(adb);
}
rcu_read_unlock();
if (view->requestmgr != NULL) {
dns_requestmgr_shutdown(view->requestmgr);
}
/* Swap the pointers under the lock */
LOCK(&view->lock);
if (view->resolver != NULL) {
resolver = view->resolver;
view->resolver = NULL;
}
rcu_read_lock();
zonetable = rcu_xchg_pointer(&view->zonetable, NULL);
if (zonetable != NULL) {
if (view->flush) {
dns_zt_flush(zonetable);
}
}
adb = rcu_xchg_pointer(&view->adb, NULL);
dispatchmgr = rcu_xchg_pointer(&view->dispatchmgr, NULL);
rcu_read_unlock();
if (view->requestmgr != NULL) {
requestmgr = view->requestmgr;
view->requestmgr = NULL;
}
if (view->managed_keys != NULL) {
mkzone = view->managed_keys;
view->managed_keys = NULL;
if (view->flush) {
dns_zone_flush(mkzone);
}
}
if (view->redirect != NULL) {
rdzone = view->redirect;
view->redirect = NULL;
if (view->flush) {
dns_zone_flush(rdzone);
}
}
if (view->catzs != NULL) {
dns_catz_zones_shutdown(view->catzs);
dns_catz_zones_detach(&view->catzs);
}
if (view->ntatable_priv != NULL) {
dns_ntatable_shutdown(view->ntatable_priv);
}
UNLOCK(&view->lock);
/* Detach outside view lock */
if (resolver != NULL) {
dns_resolver_detach(&resolver);
}
synchronize_rcu();
if (dispatchmgr != NULL) {
dns_dispatchmgr_detach(&dispatchmgr);
}
if (adb != NULL) {
dns_adb_detach(&adb);
}
if (zonetable != NULL) {
dns_zt_detach(&zonetable);
}
if (requestmgr != NULL) {
dns_requestmgr_detach(&requestmgr);
}
if (mkzone != NULL) {
dns_zone_detach(&mkzone);
}
if (rdzone != NULL) {
dns_zone_detach(&rdzone);
}
dns_view_weakdetach(&view);
} }
} }
@ -535,25 +542,23 @@ dns_view_createresolver(dns_view_t *view, isc_nm_t *netmgr,
dns_dispatch_t *dispatchv6) { dns_dispatch_t *dispatchv6) {
isc_result_t result; isc_result_t result;
isc_mem_t *mctx = NULL; isc_mem_t *mctx = NULL;
isc_loopmgr_t *loopmgr = isc_loop_getloopmgr(isc_loop());
REQUIRE(DNS_VIEW_VALID(view)); REQUIRE(DNS_VIEW_VALID(view));
REQUIRE(!view->frozen); REQUIRE(!view->frozen);
REQUIRE(view->resolver == NULL); REQUIRE(view->resolver == NULL);
REQUIRE(view->dispatchmgr != NULL); REQUIRE(view->dispatchmgr != NULL);
result = dns_resolver_create(view, loopmgr, netmgr, options, result = dns_resolver_create(view, netmgr, options, tlsctx_cache,
tlsctx_cache, dispatchv4, dispatchv6, dispatchv4, dispatchv6, &view->resolver);
&view->resolver);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
return result; return result;
} }
isc_mem_create("ADB", &mctx); isc_mem_create("ADB", &mctx);
dns_adb_create(mctx, loopmgr, view, &view->adb); dns_adb_create(mctx, view, &view->adb);
isc_mem_detach(&mctx); isc_mem_detach(&mctx);
result = dns_requestmgr_create(view->mctx, loopmgr, view->dispatchmgr, result = dns_requestmgr_create(view->mctx, view->dispatchmgr,
dispatchv4, dispatchv6, dispatchv4, dispatchv6,
&view->requestmgr); &view->requestmgr);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
@ -1479,12 +1484,12 @@ dns_view_freezezones(dns_view_t *view, bool value) {
} }
void void
dns_view_initntatable(dns_view_t *view, isc_loopmgr_t *loopmgr) { dns_view_initntatable(dns_view_t *view) {
REQUIRE(DNS_VIEW_VALID(view)); REQUIRE(DNS_VIEW_VALID(view));
if (view->ntatable_priv != NULL) { if (view->ntatable_priv != NULL) {
dns_ntatable_detach(&view->ntatable_priv); dns_ntatable_detach(&view->ntatable_priv);
} }
dns_ntatable_create(view, loopmgr, &view->ntatable_priv); dns_ntatable_create(view, &view->ntatable_priv);
} }
isc_result_t isc_result_t

View File

@ -616,7 +616,6 @@ struct dns_zonemgr {
unsigned int magic; unsigned int magic;
isc_mem_t *mctx; isc_mem_t *mctx;
isc_refcount_t refs; isc_refcount_t refs;
isc_loopmgr_t *loopmgr;
isc_nm_t *netmgr; isc_nm_t *netmgr;
uint32_t workers; uint32_t workers;
isc_mem_t **mctxpool; 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_create(isc_mem_t *mctx, isc_nm_t *netmgr, dns_zonemgr_t **zmgrp) {
dns_zonemgr_t *zmgr = NULL; dns_zonemgr_t *zmgr = NULL;
isc_loop_t *loop = isc_loop(); isc_loop_t *loop = isc_loop();
isc_loopmgr_t *loopmgr = isc_loop_getloopmgr(loop);
REQUIRE(mctx != NULL); REQUIRE(mctx != NULL);
REQUIRE(netmgr != 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 = isc_mem_get(mctx, sizeof(*zmgr));
*zmgr = (dns_zonemgr_t){ *zmgr = (dns_zonemgr_t){
.loopmgr = loopmgr,
.netmgr = netmgr, .netmgr = netmgr,
.workers = isc_loopmgr_nloops(loopmgr), .workers = isc_loopmgr_nloops(),
.transfersin = 10, .transfersin = 10,
.transfersperns = 2, .transfersperns = 2,
}; };
@ -19414,7 +19411,7 @@ dns_zonemgr_managezone(dns_zonemgr_t *zmgr, dns_zone_t *zone) {
REQUIRE(zone->timer == NULL); REQUIRE(zone->timer == NULL);
REQUIRE(zone->zmgr == 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); isc_loop_attach(loop, &zone->loop);
zonemgr_keymgmt_add(zmgr, zone, &zone->kfio); 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(VALID_LOOP(loop));
REQUIRE(cb != NULL); 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)); isc_job_t *job = isc_mem_get(helper->mctx, sizeof(*job));
*job = (isc_job_t){ *job = (isc_job_t){
.cb = cb, .cb = cb,

View File

@ -15,6 +15,9 @@
#include <inttypes.h> #include <inttypes.h>
#include <urcu/compiler.h>
#include <urcu/system.h>
#include <isc/job.h> #include <isc/job.h>
#include <isc/mem.h> #include <isc/mem.h>
#include <isc/refcount.h> #include <isc/refcount.h>
@ -34,8 +37,9 @@ static inline isc_loop_t *
isc_loop(void) { isc_loop(void) {
return isc__loop_local; return isc__loop_local;
} }
void 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. * 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 void
isc_loopmgr_destroy(isc_loopmgr_t **loopmgrp); isc_loopmgr_destroy(void);
/*%< /*%<
* Destroy the loop manager pointed to by 'loopmgrp'. * Destroy the loop manager.
*
* Requires:
*\li 'loopmgr' points to a valid loop manager.
*/ */
void 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 * This will stop all signal handlers and send shutdown events to
* all active loops. As a final action on shutting down, each loop * all active loops. As a final action on shutting down, each loop
* will run the function (or functions) set by isc_loopmgr_teardown() * will run the function (or functions) set by isc_loopmgr_teardown()
* or isc_loop_teardown(). * or isc_loop_teardown().
*
* Requires:
*\li 'loopmgr' is a valid loop manager.
*/ */
void 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(). * function (or functions) set by isc_loopmgr_setup() or isc_loop_setup().
*
* Requires:
*\li 'loopmgr' is a valid loop manager.
*/ */
void 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. * current one. This can only be called from a running loop.
* All the paused loops will wait until isc_loopmgr_resume() is * All the paused loops will wait until isc_loopmgr_resume() is
* run in the calling loop before continuing. * run in the calling loop before continuing.
* *
* Requires: * 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. *\li We are in a running loop.
*/ */
void 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 * only be called by a running loop (which must therefore be the
* loop that called isc_loopmgr_pause()). * loop that called isc_loopmgr_pause()).
* *
* Requires: * Requires:
*\li 'loopmgr' is a valid loop manager.
*\li We are in a running loop. *\li We are in a running loop.
*/ */
uint32_t uint32_t
isc_loopmgr_nloops(isc_loopmgr_t *loopmgr); isc_loopmgr_nloops(void);
isc_job_t * isc_job_t *
isc_loop_setup(isc_loop_t *loop, isc_job_cb cb, void *cbarg); 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 void
isc_loopmgr_setup(isc_loopmgr_t *loopmgr, isc_job_cb cb, void *cbarg); isc_loopmgr_setup(isc_job_cb cb, void *cbarg);
void 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, * Schedule actions to be run when starting, and when shutting down,
* *all* of the loops in loopmgr. * *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. * isc_loop_teardown() on each of the loops in turn.
* *
* Requires: * 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 * isc_mem_t *
@ -145,27 +146,21 @@ isc_loop_getmctx(isc_loop_t *loop);
*/ */
isc_loop_t * 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). * regardless of how many loops there are).
*
* Requires:
*\li 'loopmgr' is a valid loop manager.
*/ */
isc_loop_t * 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 * Return the loop object associated with the 'tid' threadid
* *
* Requires: * Requires:
*\li 'loopmgr' is a valid loop manager.
*\li 'tid' is smaller than number of initialized loops *\li 'tid' is smaller than number of initialized loops
*/ */
#
#if ISC_LOOP_TRACE #if ISC_LOOP_TRACE
#define isc_loop_ref(ptr) isc_loop__ref(ptr, __func__, __FILE__, __LINE__) #define isc_loop_ref(ptr) isc_loop__ref(ptr, __func__, __FILE__, __LINE__)
#define isc_loop_unref(ptr) isc_loop__unref(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 void
isc_loopmgr_blocking(isc_loopmgr_t *loopmgr); isc_loopmgr_blocking(void);
void void
isc_loopmgr_nonblocking(isc_loopmgr_t *loopmgr); isc_loopmgr_nonblocking(void);
/*%< /*%<
* isc_loopmgr_blocking() stops the SIGINT and SIGTERM signal handlers * isc_loopmgr_blocking() stops the SIGINT and SIGTERM signal handlers
* during blocking operations, for example while waiting for user * during blocking operations, for example while waiting for user
* interaction; isc_loopmgr_nonblocking() restarts them. * 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 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. * \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 #pragma once
#include <isc/loop.h>
#include <isc/netmgr.h> #include <isc/netmgr.h>
#include <isc/result.h> #include <isc/result.h>
#include <isc/timer.h> #include <isc/timer.h>
@ -21,9 +20,7 @@
typedef struct isc_managers isc_managers_t; typedef struct isc_managers isc_managers_t;
void void
isc_managers_create(isc_mem_t **mctx, uint32_t workers, isc_managers_create(isc_mem_t **mctx, uint32_t workers, isc_nm_t **netmgrp);
isc_loopmgr_t **loopmgrp, isc_nm_t **netmgrp);
void void
isc_managers_destroy(isc_mem_t **mctx, isc_loopmgr_t **loopmgrp, isc_managers_destroy(isc_mem_t **mctx, isc_nm_t **netmgrp);
isc_nm_t **netmgrp);

View File

@ -118,7 +118,7 @@ typedef enum isc_nm_proxy_type {
*/ */
void 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. * 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); typedef void (*isc_signal_cb)(void *, int);
isc_signal_t * isc_signal_t *
isc_signal_new(isc_loopmgr_t *loopmgr, isc_signal_cb cb, void *cbarg, isc_signal_new(isc_signal_cb cb, void *cbarg, int signum);
int signum);
/*%< /*%<
* Create a new signal handler for loop manager 'loopmgr', handling * Create a new signal handler for loop manager 'loopmgr', handling
* the signal value 'signum'. * 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_interfaceiter isc_interfaceiter_t; /*%< Interface Iterator */
typedef struct isc_lex isc_lex_t; /*%< Lex */ typedef struct isc_lex isc_lex_t; /*%< Lex */
typedef struct isc_loop isc_loop_t; /*%< Event loop */ 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_mem isc_mem_t; /*%< Memory */
typedef struct isc_mempool isc_mempool_t; /*%< Memory Pool */ typedef struct isc_mempool isc_mempool_t; /*%< Memory Pool */
typedef struct isc_netaddr isc_netaddr_t; /*%< Net Address */ typedef struct isc_netaddr isc_netaddr_t; /*%< Net Address */

View File

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

View File

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

View File

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

View File

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

View File

@ -153,7 +153,7 @@ netmgr_teardown(void *arg) {
#endif #endif
void 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; isc_nm_t *netmgr = NULL;
#ifdef MAXIMAL_UV_VERSION #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_mem_get(mctx, sizeof(*netmgr));
*netmgr = (isc_nm_t){ *netmgr = (isc_nm_t){
.loopmgr = loopmgr, .nloops = isc_loopmgr_nloops(),
.nloops = isc_loopmgr_nloops(loopmgr),
}; };
isc_mem_attach(mctx, &netmgr->mctx); 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, netmgr->workers = isc_mem_cget(mctx, netmgr->nloops,
sizeof(netmgr->workers[0])); sizeof(netmgr->workers[0]));
isc_loopmgr_teardown(loopmgr, netmgr_teardown, netmgr); isc_loopmgr_teardown(netmgr_teardown, netmgr);
netmgr->magic = NM_MAGIC; netmgr->magic = NM_MAGIC;
for (size_t i = 0; i < netmgr->nloops; i++) { 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]; isc__networker_t *worker = &netmgr->workers[i];
*worker = (isc__networker_t){ *worker = (isc__networker_t){
@ -2541,8 +2540,7 @@ settlsctx_cb(void *arg) {
static void static void
set_tlsctx_workers(isc_nmsocket_t *listener, isc_tlsctx_t *tlsctx) { set_tlsctx_workers(isc_nmsocket_t *listener, isc_tlsctx_t *tlsctx) {
const size_t nworkers = const size_t nworkers = (size_t)isc_loopmgr_nloops();
(size_t)isc_loopmgr_nloops(listener->worker->netmgr->loopmgr);
/* Update the TLS context reference for every worker thread. */ /* Update the TLS context reference for every worker thread. */
for (size_t i = 0; i < nworkers; i++) { for (size_t i = 0; i < nworkers; i++) {
isc__networker_t *worker = 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(VALID_NMSOCK(listener));
REQUIRE(ctx != NULL); REQUIRE(ctx != NULL);
nworkers = nworkers = (size_t)isc_loopmgr_nloops();
(size_t)isc_loopmgr_nloops(listener->worker->netmgr->loopmgr);
INSIST(nworkers > 0); INSIST(nworkers > 0);
listener->tlsstream.listener_tls_ctx = isc_mem_cget( listener->tlsstream.listener_tls_ctx = isc_mem_cget(

View File

@ -20,15 +20,12 @@
#include "loop_p.h" #include "loop_p.h"
isc_signal_t * isc_signal_t *
isc_signal_new(isc_loopmgr_t *loopmgr, isc_signal_cb cb, void *cbarg, isc_signal_new(isc_signal_cb cb, void *cbarg, int signum) {
int signum) {
isc_loop_t *loop = NULL;
isc_signal_t *signal = NULL;
int r; 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){ *signal = (isc_signal_t){
.magic = SIGNAL_MAGIC, .magic = SIGNAL_MAGIC,
.cb = cb, .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) { isc_timer_t **timerp) {
int r; int r;
isc_timer_t *timer; isc_timer_t *timer;
isc_loopmgr_t *loopmgr = NULL;
REQUIRE(cb != NULL); REQUIRE(cb != NULL);
REQUIRE(timerp != NULL && *timerp == NULL); REQUIRE(timerp != NULL && *timerp == NULL);
REQUIRE(VALID_LOOP(loop)); REQUIRE(VALID_LOOP(loop));
loopmgr = loop->loopmgr;
REQUIRE(VALID_LOOPMGR(loopmgr));
REQUIRE(loop == isc_loop()); REQUIRE(loop == isc_loop());
timer = isc_mem_get(loop->mctx, sizeof(*timer)); timer = isc_mem_get(loop->mctx, sizeof(*timer));
@ -113,7 +108,6 @@ timer_cb(uv_timer_t *handle) {
void void
isc_timer_start(isc_timer_t *timer, isc_timertype_t type, isc_timer_start(isc_timer_t *timer, isc_timertype_t type,
const isc_interval_t *interval) { const isc_interval_t *interval) {
isc_loopmgr_t *loopmgr = NULL;
isc_loop_t *loop = NULL; isc_loop_t *loop = NULL;
int r; int r;
@ -125,10 +119,6 @@ isc_timer_start(isc_timer_t *timer, isc_timertype_t type,
REQUIRE(VALID_LOOP(loop)); REQUIRE(VALID_LOOP(loop));
loopmgr = loop->loopmgr;
REQUIRE(VALID_LOOPMGR(loopmgr));
switch (type) { switch (type) {
case isc_timertype_once: case isc_timertype_once:
timer->timeout = isc_interval_ms(interval); 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_REFCOUNT_IMPL(ns_clientmgr, clientmgr_destroy);
isc_result_t isc_result_t
ns_clientmgr_create(ns_server_t *sctx, isc_loopmgr_t *loopmgr, ns_clientmgr_create(ns_server_t *sctx, dns_aclenv_t *aclenv, isc_tid_t tid,
dns_aclenv_t *aclenv, isc_tid_t tid,
ns_clientmgr_t **managerp) { ns_clientmgr_t **managerp) {
ns_clientmgr_t *manager = NULL; ns_clientmgr_t *manager = NULL;
isc_mem_t *mctx = NULL; isc_mem_t *mctx = NULL;
@ -2676,7 +2675,7 @@ ns_clientmgr_create(ns_server_t *sctx, isc_loopmgr_t *loopmgr,
.tid = tid, .tid = tid,
.recursing = ISC_LIST_INITIALIZER, .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); isc_mutex_init(&manager->reclock);
dns_aclenv_attach(aclenv, &manager->aclenv); dns_aclenv_attach(aclenv, &manager->aclenv);
isc_refcount_init(&manager->references, 1); 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 isc_result_t
ns_clientmgr_create(ns_server_t *sctx, isc_loopmgr_t *loopmgr, ns_clientmgr_create(ns_server_t *sctx, dns_aclenv_t *aclenv, isc_tid_t tid,
dns_aclenv_t *aclenv, isc_tid_t tid,
ns_clientmgr_t **managerp); ns_clientmgr_t **managerp);
/*%< /*%<
* Create a client manager. * Create a client manager.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -78,8 +78,8 @@ mkres(dns_resolver_t **resolverp) {
isc_result_t result; isc_result_t result;
isc_tlsctx_cache_create(mctx, &tlsctx_cache); isc_tlsctx_cache_create(mctx, &tlsctx_cache);
result = dns_resolver_create(view, loopmgr, netmgr, 0, tlsctx_cache, result = dns_resolver_create(view, netmgr, 0, tlsctx_cache, dispatch,
dispatch, NULL, resolverp); NULL, resolverp);
assert_int_equal(result, ISC_R_SUCCESS); assert_int_equal(result, ISC_R_SUCCESS);
} }
@ -98,7 +98,7 @@ ISC_LOOP_TEST_IMPL(create) {
mkres(&resolver); mkres(&resolver);
destroy_resolver(&resolver); destroy_resolver(&resolver);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
/* dns_resolver_gettimeout */ /* dns_resolver_gettimeout */
@ -112,7 +112,7 @@ ISC_LOOP_TEST_IMPL(gettimeout) {
assert_true(timeout > 0); assert_true(timeout > 0);
destroy_resolver(&resolver); destroy_resolver(&resolver);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
/* dns_resolver_settimeout */ /* dns_resolver_settimeout */
@ -128,7 +128,7 @@ ISC_LOOP_TEST_IMPL(settimeout) {
assert_true(timeout == default_timeout + 1); assert_true(timeout == default_timeout + 1);
destroy_resolver(&resolver); destroy_resolver(&resolver);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
/* dns_resolver_settimeout */ /* dns_resolver_settimeout */
@ -149,7 +149,7 @@ ISC_LOOP_TEST_IMPL(settimeout_default) {
assert_int_equal(timeout, default_timeout); assert_int_equal(timeout, default_timeout);
destroy_resolver(&resolver); destroy_resolver(&resolver);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
/* dns_resolver_settimeout below minimum */ /* dns_resolver_settimeout below minimum */
@ -166,7 +166,7 @@ ISC_LOOP_TEST_IMPL(settimeout_belowmin) {
assert_in_range(timeout, default_timeout, 3999999); assert_in_range(timeout, default_timeout, 3999999);
destroy_resolver(&resolver); destroy_resolver(&resolver);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
/* dns_resolver_settimeout over maximum */ /* dns_resolver_settimeout over maximum */
@ -183,7 +183,7 @@ ISC_LOOP_TEST_IMPL(settimeout_overmax) {
assert_in_range(timeout, default_timeout, 3999999); assert_in_range(timeout, default_timeout, 3999999);
destroy_resolver(&resolver); destroy_resolver(&resolver);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
ISC_TEST_LIST_START 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(&src_addrv6, &in6addr_loopback, src_port);
isc_sockaddr_fromin6(&dst_addrv6, &in6addr_loopback, dst_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); BACKOFF_ELGIBLE_S);
dns_unreachcache_add(uc, &dst_addrv4, &src_addrv4); dns_unreachcache_add(uc, &dst_addrv4, &src_addrv4);
dns_unreachcache_add(uc, &dst_addrv6, &src_addrv6); dns_unreachcache_add(uc, &dst_addrv6, &src_addrv6);
@ -96,7 +96,7 @@ ISC_LOOP_TEST_IMPL(basic) {
dns_unreachcache_destroy(&uc); dns_unreachcache_destroy(&uc);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
ISC_LOOP_TEST_IMPL(expire) { 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(&src_addrv4, &localhost4, src_port);
isc_sockaddr_fromin(&dst_addrv4, &localhost4, dst_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); BACKOFF_ELGIBLE_S);
/* Two adds to "confirm" the addition. */ /* Two adds to "confirm" the addition. */
dns_unreachcache_add(uc, &dst_addrv4, &src_addrv4); dns_unreachcache_add(uc, &dst_addrv4, &src_addrv4);
@ -147,7 +147,7 @@ ISC_LOOP_TEST_IMPL(expire) {
dns_unreachcache_destroy(&uc); dns_unreachcache_destroy(&uc);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
ISC_LOOP_TEST_IMPL(flush) { 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(&src_addrv4, &localhost4, src_port);
isc_sockaddr_fromin(&dst_addrv4, &localhost4, dst_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); BACKOFF_ELGIBLE_S);
/* Two adds to "confirm" the addition. */ /* Two adds to "confirm" the addition. */
dns_unreachcache_add(uc, &dst_addrv4, &src_addrv4); dns_unreachcache_add(uc, &dst_addrv4, &src_addrv4);
@ -177,7 +177,7 @@ ISC_LOOP_TEST_IMPL(flush) {
dns_unreachcache_destroy(&uc); dns_unreachcache_destroy(&uc);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
ISC_TEST_LIST_START ISC_TEST_LIST_START

View File

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

View File

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

View File

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

View File

@ -30,13 +30,11 @@
#include <isc/util.h> #include <isc/util.h>
#include <isc/uv.h> #include <isc/uv.h>
extern isc_mem_t *mctx; extern isc_mem_t *mctx;
extern isc_loop_t *mainloop; extern isc_nm_t *netmgr;
extern isc_loopmgr_t *loopmgr; extern int ncpus;
extern isc_nm_t *netmgr; extern unsigned int workers;
extern int ncpus; extern bool debug;
extern unsigned int workers;
extern bool debug;
int int
setup_mctx(void **state); setup_mctx(void **state);
@ -125,21 +123,22 @@ teardown_managers(void **state);
} \ } \
; ;
#define ISC_LOOP_TEST_CUSTOM_IMPL(name, setup, teardown) \ #define ISC_LOOP_TEST_CUSTOM_IMPL(name, setup, teardown) \
void run_test_##name(void **state ISC_ATTR_UNUSED); \ void run_test_##name(void **state ISC_ATTR_UNUSED); \
void loop_test_##name(void *arg ISC_ATTR_UNUSED); \ void loop_test_##name(void *arg ISC_ATTR_UNUSED); \
void run_test_##name(void **state ISC_ATTR_UNUSED) { \ void run_test_##name(void **state ISC_ATTR_UNUSED) { \
isc_job_cb setup_loop = setup; \ isc_job_cb setup_loop = setup; \
isc_job_cb teardown_loop = teardown; \ isc_job_cb teardown_loop = teardown; \
if (setup_loop != NULL) { \ if (setup_loop != NULL) { \
isc_loop_setup(mainloop, setup_loop, state); \ isc_loop_setup(isc_loop_main(), setup_loop, state); \
} \ } \
if (teardown_loop != NULL) { \ 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) void loop_test_##name(void *arg ISC_ATTR_UNUSED)
#define ISC_LOOP_TEST_IMPL(name) ISC_LOOP_TEST_CUSTOM_IMPL(name, NULL, NULL) #define ISC_LOOP_TEST_IMPL(name) ISC_LOOP_TEST_CUSTOM_IMPL(name, NULL, NULL)

View File

@ -40,35 +40,31 @@
static atomic_uint scheduled = 0; static atomic_uint scheduled = 0;
static void static void
async_cb(void *arg) { async_cb(void *arg ISC_ATTR_UNUSED) {
isc_tid_t tid = isc_tid(); isc_tid_t tid = isc_tid();
UNUSED(arg);
atomic_fetch_add(&scheduled, 1); atomic_fetch_add(&scheduled, 1);
if (tid > 0) { if (tid > 0) {
isc_loop_t *loop = isc_loop_get(loopmgr, tid - 1); isc_loop_t *loop = isc_loop_get(tid - 1);
isc_async_run(loop, async_cb, loopmgr); isc_async_run(loop, async_cb, NULL);
} else { } else {
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
} }
static void static void
async_setup_cb(void *arg) { async_setup_cb(void *arg ISC_ATTR_UNUSED) {
isc_tid_t tid = isc_loopmgr_nloops(loopmgr) - 1; 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);
UNUSED(arg); isc_async_run(loop, async_cb, NULL);
isc_async_run(loop, async_cb, loopmgr);
} }
ISC_RUN_TEST_IMPL(isc_async_run) { ISC_RUN_TEST_IMPL(isc_async_run) {
isc_loop_setup(isc_loop_main(loopmgr), async_setup_cb, loopmgr); isc_loop_setup(isc_loop_main(), async_setup_cb, 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 char string[32] = ""; static char string[32] = "";
@ -82,23 +78,21 @@ append(void *arg) {
} }
static void static void
async_multiple(void *arg) { async_multiple(void *arg ISC_ATTR_UNUSED) {
isc_loop_t *loop = isc_loop(); isc_loop_t *loop = isc_loop();
UNUSED(arg);
isc_async_run(loop, append, &n1); isc_async_run(loop, append, &n1);
isc_async_run(loop, append, &n2); isc_async_run(loop, append, &n2);
isc_async_run(loop, append, &n3); isc_async_run(loop, append, &n3);
isc_async_run(loop, append, &n4); isc_async_run(loop, append, &n4);
isc_async_run(loop, append, &n5); isc_async_run(loop, append, &n5);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
ISC_RUN_TEST_IMPL(isc_async_multiple) { ISC_RUN_TEST_IMPL(isc_async_multiple) {
string[0] = '\0'; string[0] = '\0';
isc_loop_setup(isc_loop_main(loopmgr), async_multiple, loopmgr); isc_loop_setup(isc_loop_main(), async_multiple, NULL);
isc_loopmgr_run(loopmgr); isc_loopmgr_run();
assert_string_equal(string, "12345"); 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])); nm = isc_mem_cget(mctx, MAX_NM, sizeof(nm[0]));
for (size_t i = 0; i < MAX_NM; i++) { 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]); 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) || if (have_expected_csends(atomic_fetch_add(&csends, 1) + 1) ||
have_expected_creads(atomic_fetch_add(&creads, 1) + 1)) have_expected_creads(atomic_fetch_add(&creads, 1) + 1))
{ {
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
} else { } else {
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
} }
@ -518,7 +518,7 @@ ISC_LOOP_TEST_IMPL(mock_doh_uv_tcp_bind) {
RESET_RETURN; RESET_RETURN;
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
static void static void
@ -546,7 +546,7 @@ doh_noop(void *arg ISC_ATTR_UNUSED) {
&tcp_listen_addr, 0, NULL, NULL, endpoints, &tcp_listen_addr, 0, NULL, NULL, endpoints,
0, get_proxy_type(), &listen_sock); 0, get_proxy_type(), &listen_sock);
assert_int_equal(result, ISC_R_SUCCESS); 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), sockaddr_to_url(&tcp_listen_addr, false, req_url, sizeof(req_url),
ISC_NM_HTTP_DEFAULT_PATH); ISC_NM_HTTP_DEFAULT_PATH);
@ -555,7 +555,7 @@ doh_noop(void *arg ISC_ATTR_UNUSED) {
.length = send_msg.len }, .length = send_msg.len },
noop_read_cb, NULL, atomic_load(&use_TLS), 30000); 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(&csends));
assert_int_equal(0, atomic_load(&creads)); 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, &tcp_listen_addr, 0, NULL, NULL, endpoints,
0, get_proxy_type(), &listen_sock); 0, get_proxy_type(), &listen_sock);
assert_int_equal(result, ISC_R_SUCCESS); 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), sockaddr_to_url(&tcp_listen_addr, false, req_url, sizeof(req_url),
ISC_NM_HTTP_DEFAULT_PATH); ISC_NM_HTTP_DEFAULT_PATH);
@ -598,7 +598,7 @@ doh_noresponse(void *arg ISC_ATTR_UNUSED) {
.length = send_msg.len }, .length = send_msg.len },
noop_read_cb, NULL, atomic_load(&use_TLS), 30000); noop_read_cb, NULL, atomic_load(&use_TLS), 30000);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
ISC_LOOP_TEST_IMPL(doh_noresponse_POST) { 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_nmhandle_detach(&handle);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
static void static void
@ -681,7 +681,7 @@ doh_timeout_recovery(void *arg ISC_ATTR_UNUSED) {
&tcp_listen_addr, 0, NULL, NULL, endpoints, &tcp_listen_addr, 0, NULL, NULL, endpoints,
0, get_proxy_type(), &listen_sock); 0, get_proxy_type(), &listen_sock);
assert_int_equal(result, ISC_R_SUCCESS); 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 * 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); isc_async_current(doh_connect_thread, connect_nm);
} }
if (sends <= 0) { if (sends <= 0) {
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
} }
@ -787,7 +787,7 @@ doh_connect_thread(void *arg) {
atomic_load(&use_TLS), 30000); atomic_load(&use_TLS), 30000);
if (sends <= 0) { 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), doh_receive_reply_cb, NULL, atomic_load(&use_TLS),
30000); 30000);
isc_loop_teardown(mainloop, listen_sock_close, listen_sock); isc_loop_teardown(isc_loop_main(), listen_sock_close, listen_sock);
} }
static int static int
@ -954,7 +954,7 @@ doh_recv_two(void *arg ISC_ATTR_UNUSED) {
NULL, ctx, NULL, client_sess_cache, 5000, NULL, ctx, NULL, client_sess_cache, 5000,
get_proxy_type(), NULL); 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 static int
@ -1027,7 +1027,7 @@ doh_recv_send(void *arg ISC_ATTR_UNUSED) {
isc_nm_t *connect_nm = nm[1]; isc_nm_t *connect_nm = nm[1];
isc_result_t result = ISC_R_SUCCESS; isc_result_t result = ISC_R_SUCCESS;
isc_nmsocket_t *listen_sock = NULL; 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); isc_quota_t *quotap = init_listener_quota(workers);
atomic_store(&total_sends, 1000); atomic_store(&total_sends, 1000);
@ -1044,11 +1044,10 @@ doh_recv_send(void *arg ISC_ATTR_UNUSED) {
assert_int_equal(result, ISC_R_SUCCESS); assert_int_equal(result, ISC_R_SUCCESS);
for (size_t i = 0; i < nthreads; i++) { for (size_t i = 0; i < nthreads; i++) {
isc_async_run(isc_loop_get(loopmgr, i), doh_connect_thread, isc_async_run(isc_loop_get(i), doh_connect_thread, connect_nm);
connect_nm);
} }
isc_loop_teardown(mainloop, listen_sock_close, listen_sock); isc_loop_teardown(isc_loop_main(), listen_sock_close, listen_sock);
} }
static int static int
@ -1168,7 +1167,7 @@ ISC_LOOP_TEST_IMPL(doh_bad_connect_uri) {
.length = send_msg.len }, .length = send_msg.len },
doh_receive_reply_cb, NULL, true, 30000); 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) { 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_mem_put(mctx, ta, sizeof(*ta));
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
static void static void
@ -86,9 +86,9 @@ ISC_RUN_TEST_IMPL(isc_job_run) {
atomic_init(&scheduled, 0); atomic_init(&scheduled, 0);
atomic_init(&executed, 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)); assert_int_equal(atomic_load(&scheduled), atomic_load(&executed));
} }
@ -110,22 +110,20 @@ append(void *arg) {
} }
static void static void
job_multiple(void *arg) { job_multiple(void *arg ISC_ATTR_UNUSED) {
UNUSED(arg);
/* These will be processed in normal order */ /* These will be processed in normal order */
isc_job_run(mainloop, &n1.job, append, &n1); isc_job_run(isc_loop_main(), &n1.job, append, &n1);
isc_job_run(mainloop, &n2.job, append, &n2); isc_job_run(isc_loop_main(), &n2.job, append, &n2);
isc_job_run(mainloop, &n3.job, append, &n3); isc_job_run(isc_loop_main(), &n3.job, append, &n3);
isc_job_run(mainloop, &n4.job, append, &n4); isc_job_run(isc_loop_main(), &n4.job, append, &n4);
isc_job_run(mainloop, &n5.job, append, &n5); isc_job_run(isc_loop_main(), &n5.job, append, &n5);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
ISC_RUN_TEST_IMPL(isc_job_multiple) { ISC_RUN_TEST_IMPL(isc_job_multiple) {
string[0] = '\0'; string[0] = '\0';
isc_loop_setup(isc_loop_main(loopmgr), job_multiple, loopmgr); isc_loop_setup(isc_loop_main(), job_multiple, NULL);
isc_loopmgr_run(loopmgr); isc_loopmgr_run();
assert_string_equal(string, "12345"); assert_string_equal(string, "12345");
} }

View File

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

View File

@ -26,6 +26,8 @@
*/ */
#include <openssl/err.h> #include <openssl/err.h>
#include "isc/loop.h"
#define UNIT_TESTING #define UNIT_TESTING
#include <cmocka.h> #include <cmocka.h>
@ -176,7 +178,7 @@ setup_netmgr_test(void **state) {
isc_nonce_buf(&send_magic, sizeof(send_magic)); isc_nonce_buf(&send_magic, sizeof(send_magic));
setup_loopmgr(state); setup_loopmgr(state);
isc_netmgr_create(mctx, loopmgr, &listen_nm); isc_netmgr_create(mctx, &listen_nm);
assert_non_null(listen_nm); assert_non_null(listen_nm);
isc_nm_setinitialtimeout(listen_nm, T_INIT); isc_nm_setinitialtimeout(listen_nm, T_INIT);
isc_nm_setprimariestimeout(listen_nm, T_PRIMARIES); 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_setkeepalivetimeout(listen_nm, T_KEEPALIVE);
isc_nm_setadvertisedtimeout(listen_nm, T_ADVERTISED); 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); assert_non_null(connect_nm);
isc_nm_setinitialtimeout(connect_nm, T_INIT); isc_nm_setinitialtimeout(connect_nm, T_INIT);
isc_nm_setprimariestimeout(connect_nm, T_PRIMARIES); 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; break;
case ISC_R_SUCCESS: case ISC_R_SUCCESS:
if (have_expected_csends(atomic_fetch_add(&csends, 1) + 1)) { if (have_expected_csends(atomic_fetch_add(&csends, 1) + 1)) {
do_csends_shutdown(loopmgr); do_csends_shutdown();
} }
break; break;
default: default:
@ -344,7 +346,7 @@ connect_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
assert_true(magic == send_magic); assert_true(magic == send_magic);
if (have_expected_creads(atomic_fetch_add(&creads, 1) + 1)) { if (have_expected_creads(atomic_fetch_add(&creads, 1) + 1)) {
do_creads_shutdown(loopmgr); do_creads_shutdown();
} }
if (magic == send_magic && allow_send_back) { 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 */ /* We are finished, initiate the shutdown */
if (have_expected_cconnects(atomic_fetch_add(&cconnects, 1) + 1)) { if (have_expected_cconnects(atomic_fetch_add(&cconnects, 1) + 1)) {
do_cconnects_shutdown(loopmgr); do_cconnects_shutdown();
} else if (do_send) { } else if (do_send) {
isc_async_current(stream_recv_send_connect, isc_async_current(stream_recv_send_connect,
cbarg == NULL cbarg == NULL
@ -426,7 +428,7 @@ listen_send_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) {
break; break;
case ISC_R_SUCCESS: case ISC_R_SUCCESS:
if (have_expected_ssends(atomic_fetch_add(&ssends, 1) + 1)) { if (have_expected_ssends(atomic_fetch_add(&ssends, 1) + 1)) {
do_ssends_shutdown(loopmgr); do_ssends_shutdown();
} }
break; break;
default: default:
@ -459,7 +461,7 @@ listen_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
assert_true(magic == send_magic); assert_true(magic == send_magic);
if (have_expected_sreads(atomic_fetch_add(&sreads, 1) + 1)) { if (have_expected_sreads(atomic_fetch_add(&sreads, 1) + 1)) {
do_sreads_shutdown(loopmgr); do_sreads_shutdown();
} }
assert_true(region->length >= sizeof(magic)); 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)) { 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 }); 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)) { if (have_expected_saccepts(atomic_fetch_add(&saccepts, 1) + 1)) {
do_saccepts_shutdown(loopmgr); do_saccepts_shutdown();
} }
if (stream_use_PROXY) { 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_refcount_decrement(&active_creads);
isc_nmhandle_detach(&handle); isc_nmhandle_detach(&handle);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
isc_quota_t * 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); assert_int_equal(eresult, ISC_R_SUCCESS);
if (have_expected_cconnects(atomic_fetch_add(&cconnects, 1) + 1)) { if (have_expected_cconnects(atomic_fetch_add(&cconnects, 1) + 1)) {
do_cconnects_shutdown(loopmgr); do_cconnects_shutdown();
return; return;
} }
} }
@ -764,7 +766,7 @@ stream_noop(void **state ISC_ATTR_UNUSED) {
result = stream_listen(noop_accept_cb, NULL, 128, NULL, &listen_sock); result = stream_listen(noop_accept_cb, NULL, 128, NULL, &listen_sock);
assert_int_equal(result, ISC_R_SUCCESS); 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; connect_readcb = NULL;
stream_connect(connect_success_cb, NULL, T_CONNECT); 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_refcount_decrement(&active_creads);
isc_nmhandle_detach(&handle); isc_nmhandle_detach(&handle);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
static void static void
@ -893,7 +895,7 @@ stream_noresponse(void **state ISC_ATTR_UNUSED) {
result = stream_listen(noop_accept_cb, NULL, 128, NULL, &listen_sock); result = stream_listen(noop_accept_cb, NULL, 128, NULL, &listen_sock);
assert_int_equal(result, ISC_R_SUCCESS); 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); stream_connect(noresponse_connectcb, NULL, T_CONNECT);
} }
@ -1027,7 +1029,7 @@ stream_timeout_recovery(void **state ISC_ATTR_UNUSED) {
noanswer = true; noanswer = true;
result = stream_listen(stream_accept_cb, NULL, 128, NULL, &listen_sock); result = stream_listen(stream_accept_cb, NULL, 128, NULL, &listen_sock);
assert_int_equal(result, ISC_R_SUCCESS); 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. * 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, result = stream_listen(stream_accept_cb, NULL, 128, quotap,
&listen_sock); &listen_sock);
assert_int_equal(result, ISC_R_SUCCESS); 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); 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, result = stream_listen(stream_accept_cb, NULL, 128, quotap,
&listen_sock); &listen_sock);
assert_int_equal(result, ISC_R_SUCCESS); 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); 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, result = stream_listen(stream_accept_cb, NULL, 128, quotap,
&listen_sock); &listen_sock);
assert_int_equal(result, ISC_R_SUCCESS); 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++) { for (size_t i = 0; i < workers; i++) {
isc_async_run(isc_loop_get(loopmgr, i), isc_async_run(isc_loop_get(i), stream_recv_send_connect,
stream_recv_send_connect,
get_stream_connect_function()); 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); 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 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 (have_expected_csends(atomic_fetch_add(&csends, 1) + 1)) {
if (csends_shutdown) { if (csends_shutdown) {
isc_nm_cancelread(handle); isc_nm_cancelread(handle);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
} }
break; break;
@ -1448,7 +1449,7 @@ udp__connect_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
assert_true(magic == send_magic); assert_true(magic == send_magic);
if (have_expected_creads(atomic_fetch_add(&creads, 1) + 1)) { if (have_expected_creads(atomic_fetch_add(&creads, 1) + 1)) {
do_creads_shutdown(loopmgr); do_creads_shutdown();
} }
if (magic == send_magic && allow_send_back) { 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) + if (have_expected_cconnects(atomic_fetch_add(&cconnects, 1) +
1)) 1))
{ {
do_cconnects_shutdown(loopmgr); do_cconnects_shutdown();
} else if (do_send) { } else if (do_send) {
isc_async_current(udp_enqueue_connect, cbarg); 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_nmhandle_detach(&handle);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
static void static void
@ -1720,7 +1721,7 @@ udp_timeout_recovery_read_cb(isc_nmhandle_t *handle, isc_result_t eresult,
isc_nmhandle_detach(&handle); isc_nmhandle_detach(&handle);
atomic_fetch_add(&creads, 1); atomic_fetch_add(&creads, 1);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
static void static void
@ -1858,7 +1859,7 @@ udp_shutdown_connect_teardown(void **state) {
void void
udp_shutdown_connect(void **arg ISC_ATTR_UNUSED) { 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 * isc_nm_udpconnect() is synchronous, so we need to launch this on the
* async loop. * async loop.
@ -1910,7 +1911,7 @@ udp_shutdown_read_send_cb(isc_nmhandle_t *handle, isc_result_t eresult,
atomic_fetch_add(&csends, 1); atomic_fetch_add(&csends, 1);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
isc_nmhandle_detach(&handle); isc_nmhandle_detach(&handle);
isc_refcount_decrement(&active_csends); 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: case ISC_R_CANCELED:
/* The read has been canceled */ /* The read has been canceled */
atomic_fetch_add(&creads, 1); atomic_fetch_add(&creads, 1);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
break; break;
default: default:
UNREACHABLE(); UNREACHABLE();
@ -2269,8 +2270,7 @@ udp_recv_send(void **arg ISC_ATTR_UNUSED) {
udp_start_listening(ISC_NM_LISTEN_ALL, udp_listen_read_cb); udp_start_listening(ISC_NM_LISTEN_ALL, udp_listen_read_cb);
for (size_t i = 0; i < workers; i++) { for (size_t i = 0; i < workers; i++) {
isc_async_run(isc_loop_get(loopmgr, i), udp_enqueue_connect, isc_async_run(isc_loop_get(i), udp_enqueue_connect, NULL);
NULL);
} }
} }
@ -2299,7 +2299,7 @@ udp_double_read_send_cb(isc_nmhandle_t *handle, isc_result_t eresult,
switch (eresult) { switch (eresult) {
case ISC_R_SUCCESS: case ISC_R_SUCCESS:
if (have_expected_ssends(atomic_fetch_add(&ssends, 1) + 1)) { if (have_expected_ssends(atomic_fetch_add(&ssends, 1) + 1)) {
do_ssends_shutdown(loopmgr); do_ssends_shutdown();
} else { } else {
isc_nmhandle_t *sendhandle = NULL; isc_nmhandle_t *sendhandle = NULL;
isc_nmhandle_attach(handle, &sendhandle); 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); assert_true(magic == send_magic);
if (have_expected_creads(atomic_fetch_add(&creads, 1) + 1)) { if (have_expected_creads(atomic_fetch_add(&creads, 1) + 1)) {
do_creads_shutdown(loopmgr); do_creads_shutdown();
detach = true; detach = true;
} }

View File

@ -42,14 +42,14 @@ typedef struct rlstat {
ISC_LOOP_TEST_IMPL(ratelimiter_create) { ISC_LOOP_TEST_IMPL(ratelimiter_create) {
assert_null(rl); assert_null(rl);
expect_assert_failure(isc_ratelimiter_create(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); assert_null(rl);
isc_ratelimiter_create(mainloop, &rl); isc_ratelimiter_create(isc_loop_main(), &rl);
isc_ratelimiter_shutdown(rl); isc_ratelimiter_shutdown(rl);
isc_ratelimiter_detach(&rl); isc_ratelimiter_detach(&rl);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
ISC_LOOP_TEST_IMPL(ratelimiter_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(NULL));
expect_assert_failure(isc_ratelimiter_shutdown(rl)); expect_assert_failure(isc_ratelimiter_shutdown(rl));
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
ISC_LOOP_TEST_IMPL(ratelimiter_detach) { 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(NULL));
expect_assert_failure(isc_ratelimiter_detach(&rl)); expect_assert_failure(isc_ratelimiter_detach(&rl));
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
static int ticks = 0; static int ticks = 0;
@ -87,14 +87,14 @@ tick(void *arg) {
isc_ratelimiter_shutdown(rl); isc_ratelimiter_shutdown(rl);
isc_ratelimiter_detach(&rl); isc_ratelimiter_detach(&rl);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
ISC_LOOP_SETUP_IMPL(ratelimiter_common) { ISC_LOOP_SETUP_IMPL(ratelimiter_common) {
assert_null(rl); assert_null(rl);
isc_time_set(&tick_time, 0, 0); isc_time_set(&tick_time, 0, 0);
start_time = isc_time_now(); start_time = isc_time_now();
isc_ratelimiter_create(mainloop, &rl); isc_ratelimiter_create(isc_loop_main(), &rl);
} }
ISC_LOOP_SETUP_IMPL(ratelimiter_enqueue) { 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_t *rlstat = isc_mem_get(mctx, sizeof(*rlstat));
*rlstat = (rlstat_t){ 0 }; *rlstat = (rlstat_t){ 0 };
result = isc_ratelimiter_enqueue(rl, mainloop, tick, rlstat, result = isc_ratelimiter_enqueue(rl, isc_loop_main(), tick, rlstat,
&rlstat->event); &rlstat->event);
assert_int_equal(result, ISC_R_SUCCESS); assert_int_equal(result, ISC_R_SUCCESS);
assert_non_null(rlstat->event); assert_non_null(rlstat->event);
@ -129,23 +129,23 @@ ISC_LOOP_TEST_SETUP_TEARDOWN_IMPL(ratelimiter_enqueue_shutdown) {
rlstat_t *rlstat = isc_mem_get(mctx, sizeof(*rlstat)); rlstat_t *rlstat = isc_mem_get(mctx, sizeof(*rlstat));
*rlstat = (rlstat_t){ 0 }; *rlstat = (rlstat_t){ 0 };
expect_assert_failure( expect_assert_failure(isc_ratelimiter_enqueue(NULL, isc_loop_main(),
isc_ratelimiter_enqueue(NULL, mainloop, tick, NULL, &event)); tick, NULL, &event));
expect_assert_failure( expect_assert_failure(
isc_ratelimiter_enqueue(rl, NULL, tick, NULL, &event)); isc_ratelimiter_enqueue(rl, NULL, tick, NULL, &event));
expect_assert_failure( 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, assert_int_equal(isc_ratelimiter_enqueue(rl, isc_loop_main(), tick,
&rlstat->event), rlstat, &rlstat->event),
ISC_R_SUCCESS); ISC_R_SUCCESS);
assert_non_null(rlstat->event); assert_non_null(rlstat->event);
isc_ratelimiter_shutdown(rl); isc_ratelimiter_shutdown(rl);
assert_int_equal( assert_int_equal(isc_ratelimiter_enqueue(rl, isc_loop_main(), tick,
isc_ratelimiter_enqueue(rl, mainloop, tick, NULL, &event), NULL, &event),
ISC_R_SHUTTINGDOWN); ISC_R_SHUTTINGDOWN);
assert_null(event); 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_t *rlstat = isc_mem_get(mctx, sizeof(*rlstat));
*rlstat = (rlstat_t){ 0 }; *rlstat = (rlstat_t){ 0 };
assert_int_equal(isc_ratelimiter_enqueue(rl, mainloop, tick, rlstat, assert_int_equal(isc_ratelimiter_enqueue(rl, isc_loop_main(), tick,
&rlstat->event), rlstat, &rlstat->event),
ISC_R_SUCCESS); ISC_R_SUCCESS);
assert_int_equal(isc_ratelimiter_dequeue(rl, &rlstat->event), assert_int_equal(isc_ratelimiter_dequeue(rl, &rlstat->event),
ISC_R_SUCCESS); 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 */ /* Set up a mock ratelimiter event that isn't actually scheduled */
*fake = (isc_rlevent_t){ .link = ISC_LINK_INITIALIZER }; *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); isc_ratelimiter_attach(rl, &fake->rl);
assert_int_equal(isc_ratelimiter_dequeue(rl, &fake), ISC_R_NOTFOUND); assert_int_equal(isc_ratelimiter_dequeue(rl, &fake), ISC_R_NOTFOUND);
isc_loop_detach(&fake->loop); isc_loop_detach(&fake->loop);
@ -182,7 +182,7 @@ ISC_LOOP_TEST_SETUP_TEARDOWN_IMPL(ratelimiter_dequeue) {
isc_ratelimiter_shutdown(rl); isc_ratelimiter_shutdown(rl);
isc_ratelimiter_detach(&rl); isc_ratelimiter_detach(&rl);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
static isc_time_t tock_time; 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 = isc_mem_get(mctx, sizeof(*rlstat));
*rlstat = (rlstat_t){ 0 }; *rlstat = (rlstat_t){ 0 };
assert_int_equal(isc_ratelimiter_enqueue(rl, mainloop, tock, rlstat, assert_int_equal(isc_ratelimiter_enqueue(rl, isc_loop_main(), tock,
&rlstat->event), rlstat, &rlstat->event),
ISC_R_SUCCESS); ISC_R_SUCCESS);
rlstat = isc_mem_get(mctx, sizeof(*rlstat)); rlstat = isc_mem_get(mctx, sizeof(*rlstat));
*rlstat = (rlstat_t){ 0 }; *rlstat = (rlstat_t){ 0 };
assert_int_equal(isc_ratelimiter_enqueue(rl, mainloop, tick, rlstat, assert_int_equal(isc_ratelimiter_enqueue(rl, isc_loop_main(), tick,
&rlstat->event), rlstat, &rlstat->event),
ISC_R_SUCCESS); ISC_R_SUCCESS);
} }
@ -266,14 +266,14 @@ ISC_LOOP_TEST_SETUP_TEARDOWN_IMPL(ratelimiter_pushpop) {
rlstat = isc_mem_get(mctx, sizeof(*rlstat)); rlstat = isc_mem_get(mctx, sizeof(*rlstat));
*rlstat = (rlstat_t){ 0 }; *rlstat = (rlstat_t){ 0 };
assert_int_equal(isc_ratelimiter_enqueue(rl, mainloop, tock, rlstat, assert_int_equal(isc_ratelimiter_enqueue(rl, isc_loop_main(), tock,
&rlstat->event), rlstat, &rlstat->event),
ISC_R_SUCCESS); ISC_R_SUCCESS);
rlstat = isc_mem_get(mctx, sizeof(*rlstat)); rlstat = isc_mem_get(mctx, sizeof(*rlstat));
*rlstat = (rlstat_t){ 0 }; *rlstat = (rlstat_t){ 0 };
assert_int_equal(isc_ratelimiter_enqueue(rl, mainloop, tick, rlstat, assert_int_equal(isc_ratelimiter_enqueue(rl, isc_loop_main(), tick,
&rlstat->event), rlstat, &rlstat->event),
ISC_R_SUCCESS); 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, isc_result_t result = stream_listen(stream_accept_cb, NULL, 128, NULL,
&listen_sock); &listen_sock);
assert_int_equal(result, ISC_R_SUCCESS); 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 */ /* Schedule the shutdown before the connect */
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
stream_connect(shutdownconnect_connectcb, NULL, T_CONNECT); 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); atomic_fetch_add(&cconnects, 1);
/* Schedule the shutdown before read and send */ /* Schedule the shutdown before read and send */
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
isc_refcount_increment0(&active_creads); isc_refcount_increment0(&active_creads);
isc_nmhandle_ref(handle); 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, isc_result_t result = stream_listen(stream_accept_cb, NULL, 128, NULL,
&listen_sock); &listen_sock);
assert_int_equal(result, ISC_R_SUCCESS); 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); 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); NULL, 128, NULL, NULL, get_proxy_type(), &listen_sock);
assert_int_equal(result, ISC_R_SUCCESS); 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 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); start_listening(ISC_NM_LISTEN_ALL, listen_accept_cb, listen_read_cb);
for (size_t i = 0; i < workers; i++) { for (size_t i = 0; i < workers; i++) {
isc_async_run(isc_loop_get(loopmgr, i), isc_async_run(isc_loop_get(i), stream_recv_send_connect,
stream_recv_send_connect, tcpdns_connect); tcpdns_connect);
} }
} }

View File

@ -70,7 +70,7 @@ setup_test_run(void *data) {
lasttime = isc_time_now(); lasttime = isc_time_now();
UNLOCK(&lasttime_mx); 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); 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); atomic_store(&errcnt, ISC_R_SUCCESS);
isc_loop_setup(mainloop, setup_test_run, &arg); isc_loop_setup(isc_loop_main(), setup_test_run, &arg);
isc_loopmgr_run(loopmgr); isc_loopmgr_run();
assert_int_equal(atomic_load(&errcnt), ISC_R_SUCCESS); assert_int_equal(atomic_load(&errcnt), ISC_R_SUCCESS);
@ -168,7 +168,7 @@ ticktock(void *arg) {
if (atomic_load(&eventcnt) == nevents) { if (atomic_load(&eventcnt) == nevents) {
endtime = isc_time_now(); endtime = isc_time_now();
isc_timer_destroy(&timer); 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_mutex_unlock(&lasttime_mx);
isc_timer_destroy(&timer); isc_timer_destroy(&timer);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
/* timer type once idles out */ /* timer type once idles out */
@ -300,7 +300,7 @@ test_reset(void *arg) {
} }
} else { } else {
isc_timer_destroy(&timer); isc_timer_destroy(&timer);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
} }
@ -345,7 +345,7 @@ tick_event(void *arg) {
*/ */
if (tick == 0) { if (tick == 0) {
isc_timer_destroy(&tickertimer); 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); isc_interval_set(&interval, seconds, 0);
tickertimer = NULL; 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); isc_timer_start(tickertimer, isc_timertype_ticker, &interval);
oncetimer = NULL; oncetimer = NULL;
isc_interval_set(&interval, (seconds * 2) + 1, 0); 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); isc_timer_start(oncetimer, isc_timertype_once, &interval);
} }
@ -423,7 +423,7 @@ static void
timer_event(void *arg ISC_ATTR_UNUSED) { timer_event(void *arg ISC_ATTR_UNUSED) {
if (--timer_ticks == 0) { if (--timer_ticks == 0) {
isc_timer_destroy(&timer); isc_timer_destroy(&timer);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
timer_stop = isc_loop_now(isc_loop()); timer_stop = isc_loop_now(isc_loop());
} else { } else {
isc_timer_start(timer, timer_type, &timer_interval); 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, ISC_LOOP_TEST_CUSTOM_IMPL(reschedule_up, setup_loop_reschedule_up,
teardown_loop_timer_expect) { 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 */ /* Schedule the timer to fire immediately */
isc_interval_set(&timer_interval, 0, 0); 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, ISC_LOOP_TEST_CUSTOM_IMPL(reschedule_down, setup_loop_reschedule_down,
teardown_loop_timer_expect) { 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 */ /* Schedule the timer to fire at 10 seconds */
isc_interval_set(&timer_interval, 10, 0); 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, ISC_LOOP_TEST_CUSTOM_IMPL(reschedule_from_callback,
setup_loop_reschedule_from_callback, setup_loop_reschedule_from_callback,
teardown_loop_timer_expect) { 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_interval_set(&timer_interval, 0, NS_PER_SEC / 2);
isc_timer_start(timer, timer_type, &timer_interval); 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_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) */ /* Schedule the timer to fire immediately (in the next event loop) */
isc_interval_set(&timer_interval, 0, 0); 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, ISC_LOOP_TEST_CUSTOM_IMPL(reschedule_ticker, setup_loop_reschedule_ticker,
teardown_loop_timer_expect) { 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) */ /* Schedule the timer to fire immediately (in the next event loop) */
isc_interval_set(&timer_interval, 0, 0); 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); &listen_sock);
assert_int_equal(result, ISC_R_SUCCESS); 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 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); start_listening(ISC_NM_LISTEN_ALL, listen_accept_cb, listen_read_cb);
for (size_t i = 0; i < workers; i++) { for (size_t i = 0; i < workers; i++) {
isc_async_run(isc_loop_get(loopmgr, i), isc_async_run(isc_loop_get(i), stream_recv_send_connect,
stream_recv_send_connect, tlsdns_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); isc_refcount_decrement(&active_cconnects);
assert_int_equal(eresult, ISC_R_NOMEMORY); assert_int_equal(eresult, ISC_R_NOMEMORY);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
/* UDP */ /* UDP */
@ -87,7 +87,7 @@ ISC_LOOP_TEST_IMPL(mock_listenudp_uv_udp_open) {
RESET_RETURN; RESET_RETURN;
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
ISC_LOOP_TEST_IMPL(mock_listenudp_uv_udp_bind) { ISC_LOOP_TEST_IMPL(mock_listenudp_uv_udp_bind) {
@ -102,7 +102,7 @@ ISC_LOOP_TEST_IMPL(mock_listenudp_uv_udp_bind) {
RESET_RETURN; RESET_RETURN;
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
ISC_LOOP_TEST_IMPL(mock_listenudp_uv_udp_recv_start) { 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; RESET_RETURN;
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
ISC_LOOP_TEST_IMPL(mock_udpconnect_uv_udp_open) { 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_refcount_increment0(&active_cconnects);
isc_nm_udpconnect(netmgr, &udp_connect_addr, &udp_listen_addr, isc_nm_udpconnect(netmgr, &udp_connect_addr, &udp_listen_addr,
udp_connect_nomemory_cb, NULL, UDP_T_CONNECT); udp_connect_nomemory_cb, NULL, UDP_T_CONNECT);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
RESET_RETURN; RESET_RETURN;
} }
@ -137,7 +137,7 @@ ISC_LOOP_TEST_IMPL(mock_udpconnect_uv_udp_bind) {
isc_refcount_increment0(&active_cconnects); isc_refcount_increment0(&active_cconnects);
isc_nm_udpconnect(netmgr, &udp_connect_addr, &udp_listen_addr, isc_nm_udpconnect(netmgr, &udp_connect_addr, &udp_listen_addr,
udp_connect_nomemory_cb, NULL, UDP_T_CONNECT); udp_connect_nomemory_cb, NULL, UDP_T_CONNECT);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
RESET_RETURN; RESET_RETURN;
} }
@ -148,7 +148,7 @@ ISC_LOOP_TEST_IMPL(mock_udpconnect_uv_udp_connect) {
isc_refcount_increment0(&active_cconnects); isc_refcount_increment0(&active_cconnects);
isc_nm_udpconnect(netmgr, &udp_connect_addr, &udp_listen_addr, isc_nm_udpconnect(netmgr, &udp_connect_addr, &udp_listen_addr,
udp_connect_nomemory_cb, NULL, UDP_T_CONNECT); udp_connect_nomemory_cb, NULL, UDP_T_CONNECT);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
RESET_RETURN; RESET_RETURN;
} }
@ -159,7 +159,7 @@ ISC_LOOP_TEST_IMPL(mock_udpconnect_uv_recv_buffer_size) {
isc_refcount_increment0(&active_cconnects); isc_refcount_increment0(&active_cconnects);
isc_nm_udpconnect(netmgr, &udp_connect_addr, &udp_listen_addr, isc_nm_udpconnect(netmgr, &udp_connect_addr, &udp_listen_addr,
connect_success_cb, NULL, UDP_T_CONNECT); connect_success_cb, NULL, UDP_T_CONNECT);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
RESET_RETURN; RESET_RETURN;
} }
@ -170,7 +170,7 @@ ISC_LOOP_TEST_IMPL(mock_udpconnect_uv_send_buffer_size) {
isc_refcount_increment0(&active_cconnects); isc_refcount_increment0(&active_cconnects);
isc_nm_udpconnect(netmgr, &udp_connect_addr, &udp_listen_addr, isc_nm_udpconnect(netmgr, &udp_connect_addr, &udp_listen_addr,
connect_success_cb, NULL, UDP_T_CONNECT); connect_success_cb, NULL, UDP_T_CONNECT);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
RESET_RETURN; RESET_RETURN;
} }

View File

@ -40,38 +40,33 @@
static atomic_uint scheduled = 0; static atomic_uint scheduled = 0;
static void static void
work_cb(void *arg) { work_cb(void *arg ISC_ATTR_UNUSED) {
UNUSED(arg);
atomic_fetch_add(&scheduled, 1); atomic_fetch_add(&scheduled, 1);
assert_int_equal(isc_tid(), ISC_TID_UNKNOWN); assert_int_equal(isc_tid(), ISC_TID_UNKNOWN);
} }
static void static void
after_work_cb(void *arg) { after_work_cb(void *arg ISC_ATTR_UNUSED) {
UNUSED(arg);
assert_int_equal(atomic_load(&scheduled), 1); assert_int_equal(atomic_load(&scheduled), 1);
isc_loopmgr_shutdown(loopmgr); isc_loopmgr_shutdown();
} }
static void static void
work_enqueue_cb(void *arg) { work_enqueue_cb(void *arg ISC_ATTR_UNUSED) {
UNUSED(arg); isc_tid_t tid = isc_loopmgr_nloops() - 1;
isc_tid_t tid = isc_loopmgr_nloops(loopmgr) - 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) { ISC_RUN_TEST_IMPL(isc_work_enqueue) {
atomic_init(&scheduled, 0); 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); 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; dns_dispatchmgr_t *dispatchmgr = NULL;
if (with_dispatchmgr) { if (with_dispatchmgr) {
result = dns_dispatchmgr_create(mctx, loopmgr, netmgr, result = dns_dispatchmgr_create(mctx, netmgr, &dispatchmgr);
&dispatchmgr);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
return result; return result;
} }
} }
dns_view_create(mctx, loopmgr, dispatchmgr, dns_rdataclass_in, name, dns_view_create(mctx, dispatchmgr, dns_rdataclass_in, name, &view);
&view);
if (dispatchmgr != NULL) { if (dispatchmgr != NULL) {
dns_dispatchmgr_detach(&dispatchmgr); dns_dispatchmgr_detach(&dispatchmgr);
} }
if (with_cache) { if (with_cache) {
result = dns_cache_create(loopmgr, dns_rdataclass_in, "", mctx, result = dns_cache_create(dns_rdataclass_in, "", mctx, &cache);
&cache);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {
dns_view_detach(&view); dns_view_detach(&view);
return result; return result;

View File

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

View File

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

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