From: Evan Hunt Date: Sat, 29 Oct 2022 21:22:56 +0000 (-0700) Subject: remove isc_task completely X-Git-Tag: v9.19.11~51^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a52b17d39b7c535b7c4182eb6786a7574b148b72;p=thirdparty%2Fbind9.git remove isc_task completely as there is no further use of isc_task in BIND, this commit removes it, along with isc_taskmgr, isc_event, and all other related types. functions that accepted taskmgr as a parameter have been cleaned up. as a result of this change, some functions can no longer fail, so they've been changed to type void, and their callers have been updated accordingly. the tasks table has been removed from the statistics channel and the stats version has been updated. dns_dyndbctx has been changed to reference the loopmgr instead of taskmgr, and DNS_DYNDB_VERSION has been udpated as well. --- diff --git a/bin/check/named-checkzone.c b/bin/check/named-checkzone.c index a5d61836177..795624651ad 100644 --- a/bin/check/named-checkzone.c +++ b/bin/check/named-checkzone.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include diff --git a/bin/delv/delv.c b/bin/delv/delv.c index 82bdef98458..7fa6eb86794 100644 --- a/bin/delv/delv.c +++ b/bin/delv/delv.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -83,7 +82,6 @@ static isc_log_t *lctx = NULL; /* Managers */ static isc_nm_t *netmgr = NULL; static isc_loopmgr_t *loopmgr = NULL; -static isc_taskmgr_t *taskmgr = NULL; /* TLS */ static isc_tlsctx_cache_t *tlsctx_client_cache = NULL; @@ -1813,7 +1811,7 @@ main(int argc, char *argv[]) { argc--; argv++; - isc_managers_create(&mctx, 1, &loopmgr, &netmgr, &taskmgr); + isc_managers_create(&mctx, 1, &loopmgr, &netmgr); result = dst_lib_init(mctx, NULL); if (result != ISC_R_SUCCESS) { @@ -1871,7 +1869,7 @@ cleanup: dst_lib_destroy(); - isc_managers_destroy(&mctx, &loopmgr, &netmgr, &taskmgr); + isc_managers_destroy(&mctx, &loopmgr, &netmgr); return (0); } diff --git a/bin/dig/dig.c b/bin/dig/dig.c index 0d1814cda50..06940123dc0 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 25c3bdde333..5c73e28522d 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -51,7 +51,6 @@ #include #include #include -#include #include #include #include @@ -104,7 +103,6 @@ unsigned int extrabytes; isc_mem_t *mctx = NULL; isc_log_t *lctx = NULL; isc_nm_t *netmgr = NULL; -isc_taskmgr_t *taskmgr = NULL; isc_loopmgr_t *loopmgr = NULL; isc_loop_t *mainloop = NULL; isc_sockaddr_t localaddr; @@ -1369,7 +1367,7 @@ setup_libs(void) { fatal("can't find either v4 or v6 networking"); } - isc_managers_create(&mctx, 1, &loopmgr, &netmgr, &taskmgr); + isc_managers_create(&mctx, 1, &loopmgr, &netmgr); isc_log_create(mctx, &lctx, &logconfig); isc_log_setcontext(lctx); @@ -4716,7 +4714,7 @@ destroy_libs(void) { isc_mem_stats(mctx, stderr); } - isc_managers_destroy(&mctx, &loopmgr, &netmgr, &taskmgr); + isc_managers_destroy(&mctx, &loopmgr, &netmgr); #if ENABLE_LEAK_DETECTION isc__tls_setdestroycheck(true); diff --git a/bin/dig/dighost.h b/bin/dig/dighost.h index 4c12260338a..5daffbc5002 100644 --- a/bin/dig/dighost.h +++ b/bin/dig/dighost.h @@ -263,7 +263,6 @@ extern const dns_name_t *hmacname; extern unsigned int digestbits; extern dns_tsigkey_t *tsigkey; extern bool validated; -extern isc_taskmgr_t *taskmgr; extern isc_loopmgr_t *loopmgr; extern isc_loop_t *mainloop; extern bool free_now; diff --git a/bin/dig/host.c b/bin/dig/host.c index 42b567f0e71..35ef45e8195 100644 --- a/bin/dig/host.c +++ b/bin/dig/host.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include diff --git a/bin/dig/nslookup.c b/bin/dig/nslookup.c index 7c21225af25..2d5f0b890d4 100644 --- a/bin/dig/nslookup.c +++ b/bin/dig/nslookup.c @@ -20,13 +20,11 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index 215e44ebe08..ac21797bc31 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -56,7 +55,6 @@ #include #include #include -#include #include #include #include @@ -140,7 +138,6 @@ static const char *directory = NULL, *dsdir = NULL; static isc_mutex_t namelock, statslock; static isc_nm_t *netmgr = NULL; static isc_loopmgr_t *loopmgr = NULL; -static isc_taskmgr_t *taskmgr = NULL; static dns_db_t *gdb; /* The database */ static dns_dbversion_t *gversion; /* The database version */ static dns_dbiterator_t *gdbiter; /* The database iterator */ @@ -3636,7 +3633,7 @@ main(int argc, char *argv[]) { directory = "."; } - isc_managers_create(&mctx, nloops, &loopmgr, &netmgr, &taskmgr); + isc_managers_create(&mctx, nloops, &loopmgr, &netmgr); result = dst_lib_init(mctx, engine); if (result != ISC_R_SUCCESS) { @@ -4021,7 +4018,7 @@ main(int argc, char *argv[]) { isc_mem_stats(mctx, stdout); } - isc_managers_destroy(&mctx, &loopmgr, &netmgr, &taskmgr); + isc_managers_destroy(&mctx, &loopmgr, &netmgr); if (printstats) { TIME_NOW(&timer_finish); diff --git a/bin/dnssec/dnssec-verify.c b/bin/dnssec/dnssec-verify.c index 9e51547ae73..539b1552753 100644 --- a/bin/dnssec/dnssec-verify.c +++ b/bin/dnssec/dnssec-verify.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include diff --git a/bin/named/bind9.xsl b/bin/named/bind9.xsl index f86bf871412..91f59440d2b 100644 --- a/bin/named/bind9.xsl +++ b/bin/named/bind9.xsl @@ -156,29 +156,6 @@ background-color: #99ddff; } - table.tasks { - border: 1px solid grey; - width: 500px; - } - table.tasks th { - text-align: center; - border: 1px solid grey; - width: 150px; - } - table.tasks td { - text-align: right; - font-family: monospace; - } - table.tasks td:nth-child(2) { - text-align: center; - } - table.tasks td:nth-child(4) { - text-align: center; - } - table.tasks tr:hover{ - background-color: #99ddff; - } - table.netstat { border: 1px solid grey; width: 500px; @@ -327,7 +304,6 @@ Server, Zones, Network, - Tasks, Memory and Traffic Size


@@ -931,85 +907,6 @@ - -

Task Manager Configuration

- - - - - - - - - - - - - - - - - - - - - -
Thread-Model - -
Worker Threads - -
Default Quantum - -
Tasks Running - -
Tasks Ready - -
-
-
- -

Tasks

- - - - - - - - - - - - - - even - odd - - - - - - - - - - - -
IDNameReferencesStateQuantumEvents
- - - - - - - - - - - -
-
-

Memory Usage Summary

diff --git a/bin/named/control.c b/bin/named/control.c index 71863587932..47749644b6f 100644 --- a/bin/named/control.c +++ b/bin/named/control.c @@ -15,7 +15,6 @@ #include -#include #include #include #include diff --git a/bin/named/include/named/globals.h b/bin/named/include/named/globals.h index ddcd81179ab..40b37143bc1 100644 --- a/bin/named/include/named/globals.h +++ b/bin/named/include/named/globals.h @@ -50,7 +50,6 @@ EXTERN isc_mem_t *named_g_mctx INIT(NULL); EXTERN unsigned int named_g_cpus INIT(0); EXTERN unsigned int named_g_udpdisp INIT(0); -EXTERN isc_taskmgr_t *named_g_taskmgr INIT(NULL); EXTERN isc_loop_t *named_g_mainloop INIT(NULL); EXTERN isc_loopmgr_t *named_g_loopmgr INIT(NULL); EXTERN dns_dispatchmgr_t *named_g_dispatchmgr INIT(NULL); diff --git a/bin/named/include/named/server.h b/bin/named/include/named/server.h index 57b29d4206b..4d87fc99c18 100644 --- a/bin/named/include/named/server.h +++ b/bin/named/include/named/server.h @@ -38,14 +38,6 @@ #include -#define NAMED_EVENTCLASS ISC_EVENTCLASS(0x4E43) -#define NAMED_EVENT_RELOAD (NAMED_EVENTCLASS + 0) -#define NAMED_EVENT_DELZONE (NAMED_EVENTCLASS + 1) -#define NAMED_EVENT_COMMAND (NAMED_EVENTCLASS + 2) -#define NAMED_EVENT_TATSEND (NAMED_EVENTCLASS + 3) -#define NAMED_EVENT_RUN (NAMED_EVENTCLASS + 4) -#define NAMED_EVENT_SHUTDOWN (NAMED_EVENTCLASS + 5) - /*% * Name server state. Better here than in lots of separate global variables. */ @@ -55,8 +47,6 @@ struct named_server { ns_server_t *sctx; - isc_task_t *task; - char *statsfile; /*%< Statistics file name */ char *dumpfile; /*%< Dump file name */ char *secrootsfile; /*%< Secroots file name */ diff --git a/bin/named/main.c b/bin/named/main.c index f09f655d235..42b550d3bdf 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -1026,7 +1025,7 @@ create_managers(void) { named_g_udpdisp == 1 ? "" : "s"); isc_managers_create(&named_g_mctx, named_g_cpus, &named_g_loopmgr, - &named_g_netmgr, &named_g_taskmgr); + &named_g_netmgr); isc_nm_maxudp(named_g_netmgr, maxudp); @@ -1543,8 +1542,7 @@ main(int argc, char *argv[]) { } } - isc_managers_destroy(&named_g_mctx, &named_g_loopmgr, &named_g_netmgr, - &named_g_taskmgr); + isc_managers_destroy(&named_g_mctx, &named_g_loopmgr, &named_g_netmgr); #if ENABLE_LEAK_DETECTION isc__tls_setdestroycheck(true); diff --git a/bin/named/server.c b/bin/named/server.c index 47713427c83..bf4b3e10c7a 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -58,7 +58,6 @@ #include #include #include -#include #include #include @@ -73,7 +72,6 @@ #include #include #include -#include #include #include #include @@ -216,12 +214,12 @@ } \ } while (0) -#define CHECKFATAL(op, msg) \ - { \ - result = (op); \ - if (result != ISC_R_SUCCESS) { \ - fatal(server, msg, result); \ - } \ +#define CHECKFATAL(op, msg) \ + { \ + result = (op); \ + if (result != ISC_R_SUCCESS) { \ + fatal(msg, result); \ + } \ } /*% @@ -404,7 +402,7 @@ const char *empty_zones[] = { }; noreturn static void -fatal(named_server_t *server, const char *msg, isc_result_t result); +fatal(const char *msg, isc_result_t result); static void named_server_reload(void *arg); @@ -9145,16 +9143,7 @@ load_configuration(const char *filename, named_server_t *server, (void)cfg_map_get(config, "view", &views); /* - * Create the views and count all the configured zones in - * order to correctly size the zone manager's task table. - * (We only count zones for configured views; the built-in - * "bind" view can be ignored as it only adds a negligible - * number of zones.) - * - * If we're allowing new zones, we need to be able to find the - * new zone file and count those as well. So we setup the new - * zone configuration context, but otherwise view configuration - * waits until after the zone manager's task list has been sized. + * Create the views. */ for (element = cfg_list_first(views); element != NULL; element = cfg_list_next(element)) @@ -9977,10 +9966,8 @@ run_server(void *arg) { named_server_t *server = (named_server_t *)arg; dns_geoip_databases_t *geoip = NULL; - CHECKFATAL(dns_zonemgr_create(named_g_mctx, named_g_loopmgr, - named_g_taskmgr, named_g_netmgr, - &server->zonemgr), - "dns_zonemgr_create"); + dns_zonemgr_create(named_g_mctx, named_g_loopmgr, named_g_netmgr, + &server->zonemgr); CHECKFATAL(dns_dispatchmgr_create(named_g_mctx, named_g_netmgr, &named_g_dispatchmgr), @@ -9994,10 +9981,10 @@ run_server(void *arg) { geoip = NULL; #endif /* if defined(HAVE_GEOIP2) */ - CHECKFATAL(ns_interfacemgr_create( - named_g_mctx, server->sctx, named_g_loopmgr, - named_g_taskmgr, named_g_netmgr, named_g_dispatchmgr, - server->task, geoip, true, &server->interfacemgr), + CHECKFATAL(ns_interfacemgr_create(named_g_mctx, server->sctx, + named_g_loopmgr, named_g_netmgr, + named_g_dispatchmgr, geoip, true, + &server->interfacemgr), "creating interface manager"); /* @@ -10145,8 +10132,6 @@ shutdown_server(void *arg) { dns_db_detach(&server->in_roothints); isc_loopmgr_resume(named_g_loopmgr); - - isc_task_detach(&server->task); } /*% @@ -10226,16 +10211,6 @@ named_server_create(isc_mem_t *mctx, named_server_t **serverp) { atomic_init(&server->reload_status, NAMED_RELOAD_IN_PROGRESS); - /* - * Setup the server task, which is responsible for coordinating - * startup and shutdown of the server, as well as all exclusive - * tasks. - */ - CHECKFATAL(isc_task_create(named_g_taskmgr, &server->task, 0), - "creating server task"); - isc_task_setname(server->task, "server", server); - isc_taskmgr_setexcltask(named_g_taskmgr, server->task); - CHECKFATAL(ns_server_create(mctx, get_matching_view, &server->sctx), "creating server context"); @@ -10355,15 +10330,8 @@ named_server_destroy(named_server_t **serverp) { } static void -fatal(named_server_t *server, const char *msg, isc_result_t result) { - if (server != NULL && server->task != NULL) { - /* - * Prevent races between the OpenSSL on_exit registered - * function and any other OpenSSL calls from other tasks - * by requesting exclusive access to the task manager. - */ - isc_loopmgr_pause(named_g_loopmgr); - } +fatal(const char *msg, isc_result_t result) { + isc_loopmgr_pause(named_g_loopmgr); isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER, ISC_LOG_CRITICAL, "%s: %s", msg, isc_result_totext(result)); @@ -12440,7 +12408,6 @@ named_server_tsigdelete(named_server_t *server, isc_lex_t *lex, RWUNLOCK(&view->dynamickeys->lock, isc_rwlocktype_write); if (result != ISC_R_SUCCESS) { - isc_task_endexclusive(server->task); isc_loopmgr_resume(named_g_loopmgr); return (result); } diff --git a/bin/named/statschannel.c b/bin/named/statschannel.c index aafdecbfbbb..180f75581c3 100644 --- a/bin/named/statschannel.c +++ b/bin/named/statschannel.c @@ -77,13 +77,12 @@ struct named_statschannel { isc_mem_t *mctx; /* - * Locked by channel lock: can be referenced and modified by both - * the server task and the channel task. + * Locked by channel lock */ isc_mutex_t lock; dns_acl_t *acl; - /* Locked by server task */ + /* Locked by main loop. */ ISC_LINK(struct named_statschannel) link; }; @@ -1778,7 +1777,6 @@ cleanup: #define STATS_XML_STATUS 0x00 /* display only common statistics */ #define STATS_XML_SERVER 0x01 #define STATS_XML_ZONES 0x02 -#define STATS_XML_TASKS 0x04 #define STATS_XML_NET 0x08 #define STATS_XML_MEM 0x10 #define STATS_XML_TRAFFIC 0x20 @@ -2334,12 +2332,6 @@ generatexml(named_server_t *server, uint32_t flags, int *buflen, } TRY0(xmlTextWriterEndElement(writer)); /* /views */ - if ((flags & STATS_XML_TASKS) != 0) { - TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "taskmgr")); - TRY0(isc_taskmgr_renderxml(named_g_taskmgr, writer)); - TRY0(xmlTextWriterEndElement(writer)); /* /taskmgr */ - } - if ((flags & STATS_XML_MEM) != 0) { TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "memory")); TRY0(isc_mem_renderxml(writer)); @@ -2461,17 +2453,6 @@ render_xml_net(const isc_httpd_t *httpd, const isc_httpdurl_t *urlinfo, freecb, freecb_args)); } -static isc_result_t -render_xml_tasks(const isc_httpd_t *httpd, const isc_httpdurl_t *urlinfo, - void *arg, unsigned int *retcode, const char **retmsg, - const char **mimetype, isc_buffer_t *b, - isc_httpdfree_t **freecb, void **freecb_args) { - UNUSED(httpd); - UNUSED(urlinfo); - return (render_xml(STATS_XML_TASKS, arg, retcode, retmsg, mimetype, b, - freecb, freecb_args)); -} - static isc_result_t render_xml_mem(const isc_httpd_t *httpd, const isc_httpdurl_t *urlinfo, void *arg, unsigned int *retcode, const char **retmsg, @@ -2503,7 +2484,6 @@ render_xml_traffic(const isc_httpd_t *httpd, const isc_httpdurl_t *urlinfo, #define STATS_JSON_STATUS 0x00 /* display only common statistics */ #define STATS_JSON_SERVER 0x01 #define STATS_JSON_ZONES 0x02 -#define STATS_JSON_TASKS 0x04 #define STATS_JSON_NET 0x08 #define STATS_JSON_MEM 0x10 #define STATS_JSON_TRAFFIC 0x20 @@ -3138,19 +3118,6 @@ generatejson(named_server_t *server, size_t *msglen, const char **msg, } } - if ((flags & STATS_JSON_TASKS) != 0) { - json_object *tasks = json_object_new_object(); - CHECKMEM(tasks); - - result = isc_taskmgr_renderjson(named_g_taskmgr, tasks); - if (result != ISC_R_SUCCESS) { - json_object_put(tasks); - goto cleanup; - } - - json_object_object_add(bindstats, "taskmgr", tasks); - } - if ((flags & STATS_JSON_MEM) != 0) { json_object *memory = json_object_new_object(); CHECKMEM(memory); @@ -3403,17 +3370,6 @@ render_json_mem(const isc_httpd_t *httpd, const isc_httpdurl_t *urlinfo, freecb, freecb_args)); } -static isc_result_t -render_json_tasks(const isc_httpd_t *httpd, const isc_httpdurl_t *urlinfo, - void *arg, unsigned int *retcode, const char **retmsg, - const char **mimetype, isc_buffer_t *b, - isc_httpdfree_t **freecb, void **freecb_args) { - UNUSED(httpd); - UNUSED(urlinfo); - return (render_json(STATS_JSON_TASKS, arg, retcode, retmsg, mimetype, b, - freecb, freecb_args)); -} - static isc_result_t render_json_net(const isc_httpd_t *httpd, const isc_httpdurl_t *urlinfo, void *arg, unsigned int *retcode, const char **retmsg, @@ -3611,9 +3567,6 @@ add_listener(named_server_t *server, named_statschannel_t **listenerp, isc_httpdmgr_addurl(listener->httpdmgr, "/xml/v" STATS_XML_VERSION_MAJOR "/net", false, render_xml_net, server); - isc_httpdmgr_addurl(listener->httpdmgr, - "/xml/v" STATS_XML_VERSION_MAJOR "/tasks", false, - render_xml_tasks, server); isc_httpdmgr_addurl(listener->httpdmgr, "/xml/v" STATS_XML_VERSION_MAJOR "/mem", false, render_xml_mem, server); @@ -3636,9 +3589,6 @@ add_listener(named_server_t *server, named_statschannel_t **listenerp, isc_httpdmgr_addurl(listener->httpdmgr, "/json/v" STATS_JSON_VERSION_MAJOR "/zones", false, render_json_zones, server); - isc_httpdmgr_addurl(listener->httpdmgr, - "/json/v" STATS_JSON_VERSION_MAJOR "/tasks", false, - render_json_tasks, server); isc_httpdmgr_addurl(listener->httpdmgr, "/json/v" STATS_JSON_VERSION_MAJOR "/net", false, render_json_net, server); diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c index 0e81a99532f..58b36619a4e 100644 --- a/bin/nsupdate/nsupdate.c +++ b/bin/nsupdate/nsupdate.c @@ -125,7 +125,6 @@ static bool use_win2k_gsstsig = false; static bool tried_other_gsstsig = false; static bool local_only = false; static isc_nm_t *netmgr = NULL; -static isc_taskmgr_t *taskmgr = NULL; static isc_loopmgr_t *loopmgr = NULL; static isc_log_t *glctx = NULL; static isc_mem_t *gmctx = NULL; @@ -3443,9 +3442,6 @@ cleanup(void) { } #ifdef HAVE_GSSAPI - /* - * Cleanup GSSAPI resources after taskmgr has been destroyed. - */ if (kserver != NULL) { isc_mem_put(gmctx, kserver, sizeof(isc_sockaddr_t)); kserver = NULL; @@ -3479,7 +3475,7 @@ cleanup(void) { } ddebug("Shutting down managers"); - isc_managers_destroy(&gmctx, &loopmgr, &netmgr, &taskmgr); + isc_managers_destroy(&gmctx, &loopmgr, &netmgr); } static void @@ -3526,7 +3522,7 @@ main(int argc, char **argv) { pre_parse_args(argc, argv); - isc_managers_create(&gmctx, 1, &loopmgr, &netmgr, &taskmgr); + isc_managers_create(&gmctx, 1, &loopmgr, &netmgr); parse_args(argc, argv); diff --git a/bin/rndc/rndc.c b/bin/rndc/rndc.c index 04f6705a2ec..3d226ac03ce 100644 --- a/bin/rndc/rndc.c +++ b/bin/rndc/rndc.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include @@ -59,9 +58,7 @@ const char *progname = NULL; bool verbose; static isc_nm_t *netmgr = NULL; -static isc_taskmgr_t *taskmgr = NULL; static isc_loopmgr_t *loopmgr = NULL; -static isc_task_t *rndc_task = NULL; static const char *admin_conffile = NULL; static const char *admin_keyfile = NULL; @@ -307,7 +304,6 @@ rndc_senddone(isc_nmhandle_t *handle, isc_result_t result, void *arg) { atomic_load_acquire(&recvs) == 0) { shuttingdown = true; - isc_task_detach(&rndc_task); isc_loopmgr_shutdown(loopmgr); } } @@ -393,7 +389,6 @@ rndc_recvdone(isc_nmhandle_t *handle, isc_result_t result, void *arg) { atomic_load_acquire(&sends) == 0) { shuttingdown = true; - isc_task_detach(&rndc_task); isc_loopmgr_shutdown(loopmgr); } } @@ -1025,10 +1020,9 @@ main(int argc, char **argv) { serial = isc_random32(); - isc_managers_create(&rndc_mctx, 1, &loopmgr, &netmgr, &taskmgr); - isc_loopmgr_setup(loopmgr, rndc_start, rndc_task); + isc_managers_create(&rndc_mctx, 1, &loopmgr, &netmgr); + isc_loopmgr_setup(loopmgr, rndc_start, NULL); - DO("create task", isc_task_create(taskmgr, &rndc_task, 0)); isc_log_create(rndc_mctx, &log, &logconfig); isc_log_setcontext(log); isc_log_settag(logconfig, progname); @@ -1098,7 +1092,7 @@ main(int argc, char **argv) { isc_mem_stats(rndc_mctx, stderr); } - isc_managers_destroy(&rndc_mctx, &loopmgr, &netmgr, &taskmgr); + isc_managers_destroy(&rndc_mctx, &loopmgr, &netmgr); if (failed) { return (1); diff --git a/bin/tests/system/dyndb/driver/instance.c b/bin/tests/system/dyndb/driver/instance.c index 046f9e8ebb9..4ce0d1b31be 100644 --- a/bin/tests/system/dyndb/driver/instance.c +++ b/bin/tests/system/dyndb/driver/instance.c @@ -37,7 +37,6 @@ #include "instance.h" -#include #include #include diff --git a/bin/tests/system/dyndb/driver/zone.c b/bin/tests/system/dyndb/driver/zone.c index 564ed73d7da..a8d36058d7f 100644 --- a/bin/tests/system/dyndb/driver/zone.c +++ b/bin/tests/system/dyndb/driver/zone.c @@ -35,7 +35,6 @@ #include #include -#include #include #include diff --git a/bin/tests/system/pipelined/pipequeries.c b/bin/tests/system/pipelined/pipequeries.c index 7c1fa8ab685..8d8cb453725 100644 --- a/bin/tests/system/pipelined/pipequeries.c +++ b/bin/tests/system/pipelined/pipequeries.c @@ -29,11 +29,9 @@ #include #include #include -#include #include #include -#include #include #include #include @@ -194,7 +192,6 @@ main(int argc, char *argv[]) { isc_log_t *lctx = NULL; isc_logconfig_t *lcfg = NULL; isc_nm_t *netmgr = NULL; - isc_taskmgr_t *taskmgr = NULL; dns_dispatchmgr_t *dispatchmgr = NULL; dns_dispatch_t *dispatchv4 = NULL; dns_view_t *view = NULL; @@ -247,7 +244,7 @@ main(int argc, char *argv[]) { } isc_sockaddr_fromin(&dstaddr, &inaddr, port); - isc_managers_create(&mctx, 1, &loopmgr, &netmgr, &taskmgr); + isc_managers_create(&mctx, 1, &loopmgr, &netmgr); isc_log_create(mctx, &lctx, &lcfg); @@ -277,7 +274,7 @@ main(int argc, char *argv[]) { isc_log_destroy(&lctx); - isc_managers_destroy(&mctx, &loopmgr, &netmgr, &taskmgr); + isc_managers_destroy(&mctx, &loopmgr, &netmgr); return (0); } diff --git a/bin/tests/system/statistics/tests.sh b/bin/tests/system/statistics/tests.sh index edfce8b3ebd..0fc1b6b71d9 100644 --- a/bin/tests/system/statistics/tests.sh +++ b/bin/tests/system/statistics/tests.sh @@ -215,8 +215,6 @@ if $FEATURETEST --have-libxml2 && "${CURL}" --http1.1 http://10.53.0.3:${EXTRAPO # grep "

Glue cache statistics

" xsltproc.out.${n} >/dev/null || ret=1 grep "

View _default" xsltproc.out.${n} >/dev/null || ret=1 grep "

Zone example" xsltproc.out.${n} >/dev/null || ret=1 - # grep "

Task Manager Configuration

" xsltproc.out.${n} >/dev/null || ret=1 - grep "

Tasks

" xsltproc.out.${n} >/dev/null || ret=1 grep "

Memory Usage Summary

" xsltproc.out.${n} >/dev/null || ret=1 grep "

Memory Contexts

" xsltproc.out.${n} >/dev/null || ret=1 else diff --git a/bin/tests/system/tkey/keycreate.c b/bin/tests/system/tkey/keycreate.c index 86e0c4fc674..d4c01d19c02 100644 --- a/bin/tests/system/tkey/keycreate.c +++ b/bin/tests/system/tkey/keycreate.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include @@ -183,7 +182,6 @@ int main(int argc, char *argv[]) { char *ourkeyname = NULL; isc_nm_t *netmgr = NULL; - isc_taskmgr_t *taskmgr = NULL; isc_sockaddr_t bind_any; dns_dispatchmgr_t *dispatchmgr = NULL; dns_dispatch_t *dispatchv4 = NULL; @@ -208,7 +206,7 @@ main(int argc, char *argv[]) { isc_mem_debugging = ISC_MEM_DEBUGRECORD; - isc_managers_create(&mctx, 1, &loopmgr, &netmgr, &taskmgr); + isc_managers_create(&mctx, 1, &loopmgr, &netmgr); isc_log_create(mctx, &log, &logconfig); @@ -256,7 +254,7 @@ main(int argc, char *argv[]) { dst_lib_destroy(); - isc_managers_destroy(&mctx, &loopmgr, &netmgr, &taskmgr); + isc_managers_destroy(&mctx, &loopmgr, &netmgr); return (0); } diff --git a/bin/tests/system/tkey/keydelete.c b/bin/tests/system/tkey/keydelete.c index d6530bb43d0..eb1bef1af18 100644 --- a/bin/tests/system/tkey/keydelete.c +++ b/bin/tests/system/tkey/keydelete.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include @@ -127,7 +126,6 @@ int main(int argc, char **argv) { char *keyname = NULL; isc_nm_t *netmgr = NULL; - isc_taskmgr_t *taskmgr = NULL; isc_sockaddr_t bind_any; dns_dispatchmgr_t *dispatchmgr = NULL; dns_dispatch_t *dispatchv4 = NULL; @@ -151,7 +149,7 @@ main(int argc, char **argv) { port = atoi(argv[2]); keyname = argv[3]; - isc_managers_create(&mctx, 1, &loopmgr, &netmgr, &taskmgr); + isc_managers_create(&mctx, 1, &loopmgr, &netmgr); isc_log_create(mctx, &log, &logconfig); @@ -198,7 +196,7 @@ main(int argc, char **argv) { dst_lib_destroy(); - isc_managers_destroy(&mctx, &loopmgr, &netmgr, &taskmgr); + isc_managers_destroy(&mctx, &loopmgr, &netmgr); return (0); } diff --git a/bin/tests/test_client.c b/bin/tests/test_client.c index eaecb83ef89..872651cd697 100644 --- a/bin/tests/test_client.c +++ b/bin/tests/test_client.c @@ -53,7 +53,6 @@ static const char *protocols[] = { "udp", "tcp", static isc_mem_t *mctx = NULL; static isc_loopmgr_t *loopmgr = NULL; static isc_nm_t *netmgr = NULL; -static isc_taskmgr_t *taskmgr = NULL; static protocol_t protocol; static const char *address; @@ -287,7 +286,7 @@ parse_options(int argc, char **argv) { static void setup(void) { - isc_managers_create(&mctx, workers, &loopmgr, &netmgr, &taskmgr); + isc_managers_create(&mctx, workers, &loopmgr, &netmgr); } static void @@ -300,7 +299,7 @@ teardown(void) { isc_tlsctx_free(&tls_ctx); } - isc_managers_destroy(&mctx, &loopmgr, &netmgr, &taskmgr); + isc_managers_destroy(&mctx, &loopmgr, &netmgr); } static void diff --git a/bin/tests/test_server.c b/bin/tests/test_server.c index 05acf8430a5..e0d3bb45ec8 100644 --- a/bin/tests/test_server.c +++ b/bin/tests/test_server.c @@ -35,7 +35,6 @@ static const char *protocols[] = { "udp", "tcp", "dot", "https", "http-plain" }; static isc_mem_t *mctx = NULL; static isc_loopmgr_t *loopmgr = NULL; static isc_nm_t *netmgr = NULL; -static isc_taskmgr_t *taskmgr = NULL; static protocol_t protocol; static in_port_t port; @@ -168,7 +167,7 @@ parse_options(int argc, char **argv) { static void setup(void) { - isc_managers_create(&mctx, workers, &loopmgr, &netmgr, &taskmgr); + isc_managers_create(&mctx, workers, &loopmgr, &netmgr); } static void @@ -177,7 +176,7 @@ teardown(void) { isc_tlsctx_free(&tls_ctx); } - isc_managers_destroy(&mctx, &loopmgr, &netmgr, &taskmgr); + isc_managers_destroy(&mctx, &loopmgr, &netmgr); } static void diff --git a/bin/tools/mdig.c b/bin/tools/mdig.c index 4e3187dfbae..f519696af42 100644 --- a/bin/tools/mdig.c +++ b/bin/tools/mdig.c @@ -34,13 +34,11 @@ #include #include #include -#include #include #include #include #include -#include #include #include #include @@ -2080,7 +2078,6 @@ main(int argc, char *argv[]) { isc_log_t *lctx = NULL; isc_logconfig_t *lcfg = NULL; isc_nm_t *netmgr = NULL; - isc_taskmgr_t *taskmgr = NULL; dns_dispatchmgr_t *dispatchmgr = NULL; dns_dispatch_t *dispatchvx = NULL; dns_view_t *view = NULL; @@ -2099,7 +2096,7 @@ main(int argc, char *argv[]) { preparse_args(argc, argv); - isc_managers_create(&mctx, 1, &loopmgr, &netmgr, &taskmgr); + isc_managers_create(&mctx, 1, &loopmgr, &netmgr); isc_log_create(mctx, &lctx, &lcfg); RUNCHECK(dst_lib_init(mctx, NULL)); @@ -2215,6 +2212,6 @@ main(int argc, char *argv[]) { isc_mem_free(mctx, default_query.ecs_addr); } - isc_managers_destroy(&mctx, &loopmgr, &netmgr, &taskmgr); + isc_managers_destroy(&mctx, &loopmgr, &netmgr); return (0); } diff --git a/doc/arm/reference.rst b/doc/arm/reference.rst index 97459524037..4a159e72efb 100644 --- a/doc/arm/reference.rst +++ b/doc/arm/reference.rst @@ -5756,7 +5756,6 @@ reconfiguration time), http://127.0.0.1:8888/xml/v3/server (server and resolver statistics), http://127.0.0.1:8888/xml/v3/zones (zone statistics), http://127.0.0.1:8888/xml/v3/net (network status and socket statistics), http://127.0.0.1:8888/xml/v3/mem (memory manager -statistics), http://127.0.0.1:8888/xml/v3/tasks (task manager statistics), and http://127.0.0.1:8888/xml/v3/traffic (traffic sizes). The full set of statistics can also be read in JSON format at @@ -5766,7 +5765,6 @@ reconfiguration time), http://127.0.0.1:8888/json/v1/server (server and resolver statistics), http://127.0.0.1:8888/json/v1/zones (zone statistics), http://127.0.0.1:8888/json/v1/net (network status and socket statistics), http://127.0.0.1:8888/json/v1/mem (memory manager -statistics), http://127.0.0.1:8888/json/v1/tasks (task manager statistics), and http://127.0.0.1:8888/json/v1/traffic (traffic sizes). :any:`tls` Block Grammar diff --git a/lib/dns/Makefile.am b/lib/dns/Makefile.am index 4f657192aba..c15de0d57a1 100644 --- a/lib/dns/Makefile.am +++ b/lib/dns/Makefile.am @@ -73,7 +73,6 @@ libdns_la_HEADERS = \ include/dns/dyndb.h \ include/dns/ecs.h \ include/dns/edns.h \ - include/dns/events.h \ include/dns/fixedname.h \ include/dns/forward.h \ include/dns/geoip.h \ diff --git a/lib/dns/adb.c b/lib/dns/adb.c index 02e713df1c6..df88cbd5b11 100644 --- a/lib/dns/adb.c +++ b/lib/dns/adb.c @@ -29,13 +29,11 @@ #include #include #include -#include #include #include #include #include -#include #include #include #include @@ -379,6 +377,8 @@ destroy(dns_adb_t *); static void shutdown_names(dns_adb_t *); static void +shutdown_entries(dns_adb_t *); +static void water(void *, int); static void dump_entry(FILE *, dns_adb_t *, dns_adbentry_t *, bool, isc_stdtime_t); diff --git a/lib/dns/byaddr.c b/lib/dns/byaddr.c index b4d7b79b37d..df53ebdab4c 100644 --- a/lib/dns/byaddr.c +++ b/lib/dns/byaddr.c @@ -19,12 +19,10 @@ #include #include #include -#include #include #include #include -#include #include #include #include diff --git a/lib/dns/catz.c b/lib/dns/catz.c index 2f1b900b921..1b5b8c2029a 100644 --- a/lib/dns/catz.c +++ b/lib/dns/catz.c @@ -27,7 +27,6 @@ #include #include -#include #include #include #include diff --git a/lib/dns/client.c b/lib/dns/client.c index 72588ce0e63..c6f94acab54 100644 --- a/lib/dns/client.c +++ b/lib/dns/client.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/dns/dnstap.c b/lib/dns/dnstap.c index 52115520dc1..6e8f8319254 100644 --- a/lib/dns/dnstap.c +++ b/lib/dns/dnstap.c @@ -69,7 +69,6 @@ #include #include -#include #include #include #include diff --git a/lib/dns/include/dns/byaddr.h b/lib/dns/include/dns/byaddr.h index 4c18ddad282..718221f084a 100644 --- a/lib/dns/include/dns/byaddr.h +++ b/lib/dns/include/dns/byaddr.h @@ -40,7 +40,6 @@ *\li Drafts: TBS */ -#include #include #include diff --git a/lib/dns/include/dns/client.h b/lib/dns/include/dns/client.h index 3bfde55f00a..166822433ba 100644 --- a/lib/dns/include/dns/client.h +++ b/lib/dns/include/dns/client.h @@ -39,7 +39,6 @@ * security issue specific to this module is anticipated. */ -#include #include #include #include diff --git a/lib/dns/include/dns/dyndb.h b/lib/dns/include/dns/dyndb.h index f3020b87f57..82026d154eb 100644 --- a/lib/dns/include/dns/dyndb.h +++ b/lib/dns/include/dns/dyndb.h @@ -55,7 +55,7 @@ struct dns_dyndbctx { * if not, set DNS_DYNDB_AGE to 0. */ #ifndef DNS_DYNDB_VERSION -#define DNS_DYNDB_VERSION 1 +#define DNS_DYNDB_VERSION 2 #define DNS_DYNDB_AGE 0 #endif /* ifndef DNS_DYNDB_VERSION */ diff --git a/lib/dns/include/dns/events.h b/lib/dns/include/dns/events.h deleted file mode 100644 index 19655aa5815..00000000000 --- a/lib/dns/include/dns/events.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * SPDX-License-Identifier: MPL-2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -#pragma once - -#include - -/*! \file dns/events.h - * \brief - * Registry of DNS event numbers. - */ - -#define DNS_EVENT_FETCHCONTROL (ISC_EVENTCLASS_DNS + 0) -#define DNS_EVENT_FETCHDONE (ISC_EVENTCLASS_DNS + 1) -/* #define DNS_EVENT_VIEWRESSHUTDOWN (ISC_EVENTCLASS_DNS + 2) */ -/* #define DNS_EVENT_VIEWADBSHUTDOWN (ISC_EVENTCLASS_DNS + 3) */ -#define DNS_EVENT_UPDATE (ISC_EVENTCLASS_DNS + 4) -#define DNS_EVENT_UPDATEDONE (ISC_EVENTCLASS_DNS + 5) -#define DNS_EVENT_DISPATCH (ISC_EVENTCLASS_DNS + 6) -#define DNS_EVENT_TCPMSG (ISC_EVENTCLASS_DNS + 7) -#define DNS_EVENT_ADBMOREADDRESSES (ISC_EVENTCLASS_DNS + 8) -#define DNS_EVENT_ADBNOMOREADDRESSES (ISC_EVENTCLASS_DNS + 9) -#define DNS_EVENT_ADBCANCELED (ISC_EVENTCLASS_DNS + 10) -#define DNS_EVENT_ADBNAMEDELETED (ISC_EVENTCLASS_DNS + 11) -#define DNS_EVENT_ADBSHUTDOWN (ISC_EVENTCLASS_DNS + 12) -#define DNS_EVENT_ADBEXPIRED (ISC_EVENTCLASS_DNS + 13) -#define DNS_EVENT_ADBCONTROL (ISC_EVENTCLASS_DNS + 14) -#define DNS_EVENT_CACHECLEAN (ISC_EVENTCLASS_DNS + 15) -#define DNS_EVENT_BYADDRDONE (ISC_EVENTCLASS_DNS + 16) -#define DNS_EVENT_ZONECONTROL (ISC_EVENTCLASS_DNS + 17) -#define DNS_EVENT_DBDESTROYED (ISC_EVENTCLASS_DNS + 18) -#define DNS_EVENT_VALIDATORDONE (ISC_EVENTCLASS_DNS + 19) -#define DNS_EVENT_REQUESTDONE (ISC_EVENTCLASS_DNS + 20) -#define DNS_EVENT_VALIDATORSTART (ISC_EVENTCLASS_DNS + 21) -/* #define DNS_EVENT_VIEWREQSHUTDOWN (ISC_EVENTCLASS_DNS + 22) */ -#define DNS_EVENT_NOTIFYSENDTOADDR (ISC_EVENTCLASS_DNS + 23) -#define DNS_EVENT_ZONE (ISC_EVENTCLASS_DNS + 24) -#define DNS_EVENT_ZONESTARTXFRIN (ISC_EVENTCLASS_DNS + 25) -/* #define DNS_EVENT_MASTERQUANTUM (ISC_EVENTCLASS_DNS + 26) */ -#define DNS_EVENT_CACHEOVERMEM (ISC_EVENTCLASS_DNS + 27) -#define DNS_EVENT_MASTERNEXTZONE (ISC_EVENTCLASS_DNS + 28) -#define DNS_EVENT_IOREADY (ISC_EVENTCLASS_DNS + 29) -#define DNS_EVENT_LOOKUPDONE (ISC_EVENTCLASS_DNS + 30) -#define DNS_EVENT_RBTDEADNODES (ISC_EVENTCLASS_DNS + 31) -#define DNS_EVENT_DISPATCHCONTROL (ISC_EVENTCLASS_DNS + 32) -#define DNS_EVENT_REQUESTCONTROL (ISC_EVENTCLASS_DNS + 33) -#define DNS_EVENT_DUMPQUANTUM (ISC_EVENTCLASS_DNS + 34) -/* #define DNS_EVENT_IMPORTRECVDONE (ISC_EVENTCLASS_DNS + 35) */ -#define DNS_EVENT_FREESTORAGE (ISC_EVENTCLASS_DNS + 36) -/* #define DNS_EVENT_VIEWACACHESHUTDOWN (ISC_EVENTCLASS_DNS + 37) */ -#define DNS_EVENT_ACACHECONTROL (ISC_EVENTCLASS_DNS + 38) -#define DNS_EVENT_ACACHECLEAN (ISC_EVENTCLASS_DNS + 39) -#define DNS_EVENT_ACACHEOVERMEM (ISC_EVENTCLASS_DNS + 40) -#define DNS_EVENT_RBTPRUNE (ISC_EVENTCLASS_DNS + 41) -#define DNS_EVENT_MANAGEKEYS (ISC_EVENTCLASS_DNS + 42) -#define DNS_EVENT_CLIENTRESDONE (ISC_EVENTCLASS_DNS + 43) -#define DNS_EVENT_CLIENTREQDONE (ISC_EVENTCLASS_DNS + 44) -#define DNS_EVENT_ADBGROWENTRIES (ISC_EVENTCLASS_DNS + 45) -#define DNS_EVENT_ADBGROWNAMES (ISC_EVENTCLASS_DNS + 46) -#define DNS_EVENT_ZONESECURESERIAL (ISC_EVENTCLASS_DNS + 47) -#define DNS_EVENT_ZONESECUREDB (ISC_EVENTCLASS_DNS + 48) -/* #define DNS_EVENT_ZONELOAD (ISC_EVENTCLASS_DNS + 49) */ -#define DNS_EVENT_KEYDONE (ISC_EVENTCLASS_DNS + 50) -#define DNS_EVENT_SETNSEC3PARAM (ISC_EVENTCLASS_DNS + 51) -#define DNS_EVENT_SETSERIAL (ISC_EVENTCLASS_DNS + 52) -#define DNS_EVENT_CATZUPDATED (ISC_EVENTCLASS_DNS + 53) -#define DNS_EVENT_CATZADDZONE (ISC_EVENTCLASS_DNS + 54) -#define DNS_EVENT_CATZMODZONE (ISC_EVENTCLASS_DNS + 55) -#define DNS_EVENT_CATZDELZONE (ISC_EVENTCLASS_DNS + 56) -#define DNS_EVENT_RPZUPDATED (ISC_EVENTCLASS_DNS + 57) -#define DNS_EVENT_STARTUPDATE (ISC_EVENTCLASS_DNS + 58) -#define DNS_EVENT_TRYSTALE (ISC_EVENTCLASS_DNS + 59) -#define DNS_EVENT_ZONEFLUSH (ISC_EVENTCLASS_DNS + 60) -#define DNS_EVENT_CHECKDSSENDTOADDR (ISC_EVENTCLASS_DNS + 61) -#define DNS_EVENT_CACHESHUTDOWN (ISC_EVENTCLASS_DNS + 62) diff --git a/lib/dns/include/dns/request.h b/lib/dns/include/dns/request.h index e6213514edc..e33119742b6 100644 --- a/lib/dns/include/dns/request.h +++ b/lib/dns/include/dns/request.h @@ -36,7 +36,6 @@ #include -#include #include #include diff --git a/lib/dns/include/dns/rpz.h b/lib/dns/include/dns/rpz.h index a11dd1c63af..d28d6e14b93 100644 --- a/lib/dns/include/dns/rpz.h +++ b/lib/dns/include/dns/rpz.h @@ -21,7 +21,6 @@ #include #include -#include #include #include #include diff --git a/lib/dns/include/dns/validator.h b/lib/dns/include/dns/validator.h index 704b8307992..c00e60bf78a 100644 --- a/lib/dns/include/dns/validator.h +++ b/lib/dns/include/dns/validator.h @@ -48,7 +48,6 @@ #include -#include #include #include diff --git a/lib/dns/include/dns/view.h b/lib/dns/include/dns/view.h index f315def13cf..30d1a174da0 100644 --- a/lib/dns/include/dns/view.h +++ b/lib/dns/include/dns/view.h @@ -57,7 +57,6 @@ #include #include -#include #include #include #include diff --git a/lib/dns/include/dns/zone.h b/lib/dns/include/dns/zone.h index e7a162d3b4b..4969c910854 100644 --- a/lib/dns/include/dns/zone.h +++ b/lib/dns/include/dns/zone.h @@ -480,7 +480,7 @@ dns_zone_iattach(dns_zone_t *source, dns_zone_t **target); * object from being freed but not from shutting down. * * Require: - *\li The caller is running in the context of the zone's task. + *\li The caller is running in the context of the zone's loop. *\li 'zone' to be a valid zone. *\li 'target' to be non NULL and '*target' to be NULL. */ @@ -493,7 +493,7 @@ dns_zone_idetach(dns_zone_t **zonep); * zone, it will be freed. * * Require: - *\li The caller is running in the context of the zone's task. + *\li The caller is running in the context of the zone's loop. *\li 'zonep' to point to a valid zone. */ @@ -1587,16 +1587,14 @@ dns_zone_getdnsseckeys(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver, *\li Error */ -isc_result_t -dns_zonemgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, - isc_taskmgr_t *taskmgr, isc_nm_t *netmgr, +void +dns_zonemgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t *netmgr, dns_zonemgr_t **zmgrp); /*%< * Create a zone manager. * * Requires: *\li 'mctx' to be a valid memory context. - *\li 'taskmgr' to be a valid task manager. *\li 'zmgrp' to point to a NULL pointer. */ @@ -1681,12 +1679,6 @@ dns_zonemgr_releasezone(dns_zonemgr_t *zmgr, dns_zone_t *zone); *\li 'zone->zmgr' == NULL; */ -isc_taskmgr_t * -dns_zonemgr_gettaskmgr(dns_zonemgr_t *zmgr); -/*% - * Get the tasmkgr object attached to 'zmgr'. - */ - void dns_zonemgr_settransfersin(dns_zonemgr_t *zmgr, uint32_t value); /*%< diff --git a/lib/dns/include/dns/zt.h b/lib/dns/include/dns/zt.h index 037d0a9495b..afe13ead858 100644 --- a/lib/dns/include/dns/zt.h +++ b/lib/dns/include/dns/zt.h @@ -34,8 +34,7 @@ typedef isc_result_t (*dns_zt_allloaded_t)(void *arg); * this signature. */ -typedef isc_result_t (*dns_zt_zoneloaded_t)(dns_zt_t *zt, dns_zone_t *zone, - isc_task_t *task); +typedef isc_result_t (*dns_zt_zoneloaded_t)(dns_zt_t *zt, dns_zone_t *zone); /*%< * Method prototype: when a zone finishes loading, the zt object * can be informed via a callback function with this signature. diff --git a/lib/dns/master.c b/lib/dns/master.c index 4808002d2e4..6df8fc298d9 100644 --- a/lib/dns/master.c +++ b/lib/dns/master.c @@ -18,7 +18,6 @@ #include #include -#include #include #include #include @@ -33,7 +32,6 @@ #include #include -#include #include #include #include diff --git a/lib/dns/masterdump.c b/lib/dns/masterdump.c index c3c1d5428b5..728b1d3dde5 100644 --- a/lib/dns/masterdump.c +++ b/lib/dns/masterdump.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -36,7 +35,6 @@ #include #include -#include #include #include #include diff --git a/lib/dns/nta.c b/lib/dns/nta.c index 5096ce658a4..0b44f643395 100644 --- a/lib/dns/nta.c +++ b/lib/dns/nta.c @@ -18,14 +18,12 @@ #include #include -#include #include #include #include #include #include #include -#include #include #include #include diff --git a/lib/dns/rpz.c b/lib/dns/rpz.c index bcb0b222bdf..92ab5980d39 100644 --- a/lib/dns/rpz.c +++ b/lib/dns/rpz.c @@ -28,14 +28,12 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include #include diff --git a/lib/dns/update.c b/lib/dns/update.c index 9f1c66279ea..d3899e8e511 100644 --- a/lib/dns/update.c +++ b/lib/dns/update.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/dns/validator.c b/lib/dns/validator.c index 53b35c1e8db..baffeb3b9c0 100644 --- a/lib/dns/validator.c +++ b/lib/dns/validator.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/dns/view.c b/lib/dns/view.c index cc5315e96d3..35ce0d824b3 100644 --- a/lib/dns/view.c +++ b/lib/dns/view.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include @@ -41,7 +40,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/dns/xfrin.c b/lib/dns/xfrin.c index 8115cbb7172..05e505b188f 100644 --- a/lib/dns/xfrin.c +++ b/lib/dns/xfrin.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 48b9221dffb..36cdfe3619b 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -51,7 +50,6 @@ #include #include #include -#include #include #include #include @@ -318,9 +316,6 @@ struct dns_zone { dns_remote_t notify; dns_notifytype_t notifytype; isc_sockaddr_t notifyfrom; - - isc_task_t *task; - isc_sockaddr_t notifysrc4; isc_sockaddr_t notifysrc6; isc_sockaddr_t parentalsrc4; @@ -328,8 +323,7 @@ struct dns_zone { isc_sockaddr_t xfrsource4; isc_sockaddr_t xfrsource6; isc_sockaddr_t sourceaddr; - - dns_xfrin_ctx_t *xfr; /* task locked */ + dns_xfrin_ctx_t *xfr; /* loop locked */ dns_tsigkey_t *tsigkey; /* key used for xfr */ dns_transport_t *transport; /* transport used for xfr */ /* Access Control Lists */ @@ -592,10 +586,8 @@ struct dns_zonemgr { isc_mem_t *mctx; isc_refcount_t refs; isc_loopmgr_t *loopmgr; - isc_taskmgr_t *taskmgr; isc_nm_t *netmgr; uint32_t workers; - isc_task_t **zonetasks; isc_mem_t **mctxpool; isc_ratelimiter_t *checkdsrl; isc_ratelimiter_t *notifyrl; @@ -1189,10 +1181,6 @@ zone_free(dns_zone_t *zone) { INSIST(zone->view == NULL); INSIST(zone->prev_view == NULL); - if (zone->task != NULL) { - isc_task_detach(&zone->task); - } - /* Unmanaged objects */ for (struct np3 *npe = ISC_LIST_HEAD(zone->setnsec3param_queue); npe != NULL; npe = ISC_LIST_HEAD(zone->setnsec3param_queue)) @@ -2247,7 +2235,7 @@ zone_load(dns_zone_t *zone, unsigned int flags, bool locked) { "no master file"); } zone->refreshtime = now; - if (zone->task != NULL) { + if (zone->loop != NULL) { zone_settimer(zone, &now); } result = ISC_R_SUCCESS; @@ -2351,7 +2339,7 @@ zone_asyncload(void *arg) { /* Inform the zone table we've finished loading */ if (asl->loaded != NULL) { - (asl->loaded)(asl->loaded_arg, zone, zone->task); + (asl->loaded)(asl->loaded_arg, zone); } isc_mem_put(zone->mctx, asl, sizeof(*asl)); @@ -3657,7 +3645,7 @@ zone_addnsec3chain(dns_zone_t *zone, dns_rdata_nsec3param_t *nsec3param) { if (isc_time_isepoch(&zone->nsec3chaintime)) { TIME_NOW(&now); zone->nsec3chaintime = now; - if (zone->task != NULL) { + if (zone->loop != NULL) { zone_settimer(zone, &now); } } @@ -5144,7 +5132,7 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, } } - if (zone->task != NULL) { + if (zone->loop != NULL) { if (zone->type == dns_zone_primary) { set_resigntime(zone); resume_signingwithkey(zone); @@ -5260,7 +5248,7 @@ cleanup: /* Mark the zone for immediate refresh. */ zone->refreshtime = now; - if (zone->task != NULL) { + if (zone->loop != NULL) { zone_settimer(zone, &now); } result = ISC_R_SUCCESS; @@ -5295,7 +5283,7 @@ done: * due to DNS_ZONEFLG_LOADPENDING being set when * zone_maintenance was called. */ - if (zone->secure->task != NULL) { + if (zone->secure->loop != NULL) { zone_settimer(zone->secure, &now); } } @@ -11000,7 +10988,7 @@ zone_maintenance(dns_zone_t *zone) { } UNLOCK_ZONE(zone); if (!dumping) { - result = zone_dump(zone, true); /* task locked */ + result = zone_dump(zone, true); /* loop locked */ if (result != ISC_R_SUCCESS) { dns_zone_log(zone, ISC_LOG_WARNING, "dump failed: %s", @@ -11156,7 +11144,7 @@ again: /* XXXMPA make separate call back */ if (result == ISC_R_SUCCESS) { set_resigntime(zone); - if (zone->task != NULL) { + if (zone->loop != NULL) { isc_time_t now; TIME_NOW(&now); zone_settimer(zone, &now); @@ -11442,7 +11430,7 @@ dns_zone_flush(dns_zone_t *zone) { } UNLOCK_ZONE(zone); if (!dumping) { - result = zone_dump(zone, true); /* Unknown task. */ + result = zone_dump(zone, true); } return (result); } @@ -11458,7 +11446,7 @@ dns_zone_dump(dns_zone_t *zone) { dumping = was_dumping(zone); UNLOCK_ZONE(zone); if (!dumping) { - result = zone_dump(zone, false); /* Unknown task. */ + result = zone_dump(zone, false); } return (result); } @@ -11495,7 +11483,7 @@ zone_needdump(dns_zone_t *zone, unsigned int delay) { { zone->dumptime = dumptime; } - if (zone->task != NULL) { + if (zone->loop != NULL) { zone_settimer(zone, &now); } } @@ -11636,7 +11624,7 @@ zone_dump(dns_zone_t *zone, bool compact) { dns_masterrawheader_t rawdata; /* - * 'compact' MUST only be set if we are task locked. + * 'compact' MUST only be set if we are loop locked. */ REQUIRE(DNS_ZONE_VALID(zone)); @@ -14488,7 +14476,7 @@ zone_shutdown(void *arg) { } /* - * In task context, no locking required. See zone_xfrdone(). + * In loop context, no locking required. See zone_xfrdone(). */ if (zone->xfr != NULL) { /* The final detach will happen in zone_xfrdone() */ @@ -17354,7 +17342,7 @@ dns_zone_setsigresigninginterval(dns_zone_t *zone, uint32_t interval) { LOCK_ZONE(zone); zone->sigresigninginterval = interval; set_resigntime(zone); - if (zone->task != NULL) { + if (zone->loop != NULL) { TIME_NOW(&now); zone_settimer(zone, &now); } @@ -17999,17 +17987,14 @@ zonemgr_keymgmt_delete(dns_zonemgr_t *zmgr, dns_keyfileio_t **deleted) { RWUNLOCK(&mgmt->lock, isc_rwlocktype_write); } -isc_result_t -dns_zonemgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, - isc_taskmgr_t *taskmgr, isc_nm_t *netmgr, +void +dns_zonemgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t *netmgr, dns_zonemgr_t **zmgrp) { - dns_zonemgr_t *zmgr; - isc_result_t result; + dns_zonemgr_t *zmgr = NULL; isc_loop_t *loop = isc_loop_current(loopmgr); REQUIRE(mctx != NULL); REQUIRE(loopmgr != NULL); - REQUIRE(taskmgr != NULL); REQUIRE(netmgr != NULL); REQUIRE(zmgrp != NULL && *zmgrp == NULL); @@ -18017,7 +18002,6 @@ dns_zonemgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, *zmgr = (dns_zonemgr_t){ .loopmgr = loopmgr, - .taskmgr = taskmgr, .netmgr = netmgr, .workers = isc_loopmgr_nloops(loopmgr), .transfersin = 10, @@ -18045,17 +18029,6 @@ dns_zonemgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_ratelimiter_create(loop, &zmgr->startupnotifyrl); isc_ratelimiter_create(loop, &zmgr->startuprefreshrl); - zmgr->zonetasks = isc_mem_getx( - zmgr->mctx, zmgr->workers * sizeof(zmgr->zonetasks[0]), - ISC_MEM_ZERO); - for (size_t i = 0; i < zmgr->workers; i++) { - result = isc_task_create(zmgr->taskmgr, &zmgr->zonetasks[i], i); - if (result != ISC_R_SUCCESS) { - goto free_zonetasks; - } - isc_task_setname(zmgr->zonetasks[i], "zonemgr-zonetasks", NULL); - } - zmgr->mctxpool = isc_mem_getx(zmgr->mctx, zmgr->workers * sizeof(zmgr->mctxpool[0]), ISC_MEM_ZERO); @@ -18081,38 +18054,6 @@ dns_zonemgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, zmgr->magic = ZONEMGR_MAGIC; *zmgrp = zmgr; - return (ISC_R_SUCCESS); - -#if 0 - free_iolock: - isc_mutex_destroy(&zmgr->iolock); -#endif /* if 0 */ - -free_zonetasks: - for (size_t i = 0; i < zmgr->workers; i++) { - if (zmgr->zonetasks[i] != NULL) { - isc_task_detach(&zmgr->zonetasks[i]); - } - } - isc_mem_put(zmgr->mctx, zmgr->zonetasks, - zmgr->workers * sizeof(zmgr->zonetasks[0])); - - isc_ratelimiter_shutdown(zmgr->startuprefreshrl); - isc_ratelimiter_detach(&zmgr->startuprefreshrl); - isc_ratelimiter_shutdown(zmgr->startupnotifyrl); - isc_ratelimiter_detach(&zmgr->startupnotifyrl); - isc_ratelimiter_shutdown(zmgr->refreshrl); - isc_ratelimiter_detach(&zmgr->refreshrl); - isc_ratelimiter_shutdown(zmgr->notifyrl); - isc_ratelimiter_detach(&zmgr->notifyrl); - isc_ratelimiter_shutdown(zmgr->checkdsrl); - isc_ratelimiter_detach(&zmgr->checkdsrl); - - isc_rwlock_destroy(&zmgr->urlock); - isc_rwlock_destroy(&zmgr->rwlock); - isc_mem_put(zmgr->mctx, zmgr, sizeof(*zmgr)); - isc_mem_detach(&mctx); - return (result); } isc_result_t @@ -18150,25 +18091,11 @@ dns_zonemgr_managezone(dns_zonemgr_t *zmgr, dns_zone_t *zone) { REQUIRE(DNS_ZONE_VALID(zone)); REQUIRE(DNS_ZONEMGR_VALID(zmgr)); - if (zmgr->zonetasks == NULL) { - return (ISC_R_FAILURE); - } - RWLOCK(&zmgr->rwlock, isc_rwlocktype_write); LOCK_ZONE(zone); - REQUIRE(zone->task == NULL); REQUIRE(zone->timer == NULL); REQUIRE(zone->zmgr == NULL); - isc_task_attach(zmgr->zonetasks[zone->tid], &zone->task); - - /* - * Set the task name. The tag will arbitrarily point to one - * of the zones sharing the task (in practice, the one - * to be managed last). - */ - isc_task_setname(zone->task, "zone", zone); - zone->loop = isc_loop_get(zmgr->loopmgr, zone->tid); zonemgr_keymgmt_add(zmgr, zone, &zone->kfio); @@ -18287,10 +18214,6 @@ dns_zonemgr_shutdown(dns_zonemgr_t *zmgr) { isc_mem_detach(&zmgr->mctxpool[i]); } - for (size_t i = 0; i < zmgr->workers; i++) { - isc_task_detach(&zmgr->zonetasks[i]); - } - RWLOCK(&zmgr->rwlock, isc_rwlocktype_read); for (zone = ISC_LIST_HEAD(zmgr->zones); zone != NULL; zone = ISC_LIST_NEXT(zone, link)) @@ -18317,8 +18240,6 @@ zonemgr_free(dns_zonemgr_t *zmgr) { isc_mem_put(zmgr->mctx, zmgr->mctxpool, zmgr->workers * sizeof(zmgr->mctxpool[0])); - isc_mem_put(zmgr->mctx, zmgr->zonetasks, - zmgr->workers * sizeof(zmgr->zonetasks[0])); isc_rwlock_destroy(&zmgr->urlock); isc_rwlock_destroy(&zmgr->rwlock); @@ -18359,13 +18280,6 @@ dns_zonemgr_gettransfersperns(dns_zonemgr_t *zmgr) { return (zmgr->transfersperns); } -isc_taskmgr_t * -dns_zonemgr_gettaskmgr(dns_zonemgr_t *zmgr) { - REQUIRE(DNS_ZONEMGR_VALID(zmgr)); - - return (zmgr->taskmgr); -} - /* * Try to start a new incoming zone transfer to fill a quota * slot that was just vacated. @@ -18434,7 +18348,7 @@ zmgr_start_xfrin_ifquota(dns_zonemgr_t *zmgr, dns_zone_t *zone) { /* * If we are exiting just pretend we got quota so the zone will - * be cleaned up in the zone's task context. + * be cleaned up in the zone's loop context. */ LOCK_ZONE(zone); if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING)) { @@ -19271,7 +19185,7 @@ zone_signwithkey(dns_zone_t *zone, dns_secalg_t algorithm, uint16_t keyid, signing = NULL; if (isc_time_isepoch(&zone->signingtime)) { zone->signingtime = now; - if (zone->task != NULL) { + if (zone->loop != NULL) { zone_settimer(zone, &now); } } @@ -21039,7 +20953,7 @@ void dns_zone_rekey(dns_zone_t *zone, bool fullsign) { isc_time_t now; - if (zone->type == dns_zone_primary && zone->task != NULL) { + if (zone->type == dns_zone_primary && zone->loop != NULL) { LOCK_ZONE(zone); if (fullsign) { @@ -21418,12 +21332,12 @@ dns_zone_link(dns_zone_t *zone, dns_zone_t *raw) { REQUIRE(DNS_ZONE_VALID(zone)); REQUIRE(zone->zmgr != NULL); - REQUIRE(zone->task != NULL); + REQUIRE(zone->loop != NULL); REQUIRE(zone->raw == NULL); REQUIRE(DNS_ZONE_VALID(raw)); REQUIRE(raw->zmgr == NULL); - REQUIRE(raw->task == NULL); + REQUIRE(raw->loop == NULL); REQUIRE(raw->secure == NULL); REQUIRE(zone != raw); @@ -21445,8 +21359,6 @@ dns_zone_link(dns_zone_t *zone, dns_zone_t *raw) { /* dns_zone_iattach(zone, &raw->secure); */ zone_iattach(zone, &raw->secure); - isc_task_attach(zone->task, &raw->task); - ISC_LIST_APPEND(zmgr->zones, raw, link); raw->zmgr = zmgr; isc_refcount_increment(&zmgr->refs); @@ -21675,7 +21587,7 @@ failure: } /* - * Called from the zone task's queue after the relevant event is posted by + * Called from the zone loop's queue after the relevant event is posted by * dns_zone_setnsec3param(). */ static void @@ -22157,7 +22069,7 @@ failure: * in the "data" field of the nsec3param_t structure. * * Once the nsec3param_t structure is prepared, post an event to the zone's - * task which will cause setnsec3param() to be called with the prepared + * loop which will cause setnsec3param() to be called with the prepared * structure passed as an argument. */ isc_result_t diff --git a/lib/dns/zt.c b/lib/dns/zt.c index da4eac74ce5..48713d207f9 100644 --- a/lib/dns/zt.c +++ b/lib/dns/zt.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include @@ -78,7 +77,7 @@ static isc_result_t freezezones(dns_zone_t *zone, void *uap); static isc_result_t -doneloading(dns_zt_t *zt, dns_zone_t *zone, isc_task_t *task); +doneloading(dns_zt_t *zt, dns_zone_t *zone); isc_result_t dns_zt_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, dns_zt_t **ztp) { @@ -585,12 +584,11 @@ cleanup: * dns_zt_asyncload(). */ static isc_result_t -doneloading(dns_zt_t *zt, dns_zone_t *zone, isc_task_t *task) { - UNUSED(zone); - UNUSED(task); - +doneloading(dns_zt_t *zt, dns_zone_t *zone) { REQUIRE(VALID_ZT(zt)); + UNUSED(zone); + if (isc_refcount_decrement(&zt->loads_pending) == 1) { call_loaddone(zt); } diff --git a/lib/isc/Makefile.am b/lib/isc/Makefile.am index 55eac3a7c98..dff12e76c9e 100644 --- a/lib/isc/Makefile.am +++ b/lib/isc/Makefile.am @@ -27,8 +27,6 @@ libisc_la_HEADERS = \ include/isc/entropy.h \ include/isc/errno.h \ include/isc/error.h \ - include/isc/event.h \ - include/isc/eventclass.h \ include/isc/file.h \ include/isc/formatcheck.h \ include/isc/fsaccess.h \ @@ -87,7 +85,6 @@ libisc_la_HEADERS = \ include/isc/string.h \ include/isc/symtab.h \ include/isc/syslog.h \ - include/isc/task.h \ include/isc/thread.h \ include/isc/tid.h \ include/isc/time.h \ @@ -129,7 +126,6 @@ libisc_la_SOURCES = \ errno2result.c \ errno2result.h \ error.c \ - event.c \ file.c \ fsaccess.c \ fsaccess_common.c \ @@ -191,7 +187,6 @@ libisc_la_SOURCES = \ string.c \ symtab.c \ syslog.c \ - task.c \ thread.c \ tid.c \ time.c \ diff --git a/lib/isc/event.c b/lib/isc/event.c deleted file mode 100644 index cf5bdee5583..00000000000 --- a/lib/isc/event.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * SPDX-License-Identifier: MPL-2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -/*! - * \file - */ - -#include -#include -#include - -/*** - *** Events. - ***/ - -static void -destroy(isc_event_t *event) { - isc_mem_t *mctx = event->ev_destroy_arg; - - isc_mem_put(mctx, event, event->ev_size); -} - -isc_event_t * -isc__event_allocate(isc_mem_t *mctx, void *sender, isc_eventtype_t type, - isc_taskaction_t action, void *arg, - size_t size ISC__EVENT_FLARG) { - isc_event_t *event; - - REQUIRE(size >= sizeof(struct isc_event)); - REQUIRE(action != NULL); - - event = isc_mem_get(mctx, size); - - ISC_EVENT_INIT_PASS(event, size, 0, type, action, arg, sender, destroy, - mctx); - - return (event); -} - -void -isc_event_free(isc_event_t **eventp) { - isc_event_t *event; - - REQUIRE(eventp != NULL); - event = *eventp; - *eventp = NULL; - REQUIRE(event != NULL); - - REQUIRE(!ISC_LINK_LINKED(event, ev_link)); - REQUIRE(!ISC_LINK_LINKED(event, ev_ratelink)); - - if (event->ev_destroy != NULL) { - (event->ev_destroy)(event); - } -} diff --git a/lib/isc/include/isc/event.h b/lib/isc/include/isc/event.h deleted file mode 100644 index b7a8be35f0c..00000000000 --- a/lib/isc/include/isc/event.h +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * SPDX-License-Identifier: MPL-2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -#pragma once - -/*! \file isc/event.h */ - -#include -#include -#include -#include -#include - -/***** -***** Events. -*****/ - -typedef void (*isc_eventdestructor_t)(isc_event_t *); - -#if TASKMGR_TRACE -#define ISC__EVENT_TRACE_SIZE 8 -#define ISC__EVENT_FILELINE , __func__, __FILE__, __LINE__ -#define ISC__EVENT_FLARG , const char *func, const char *file, unsigned int line - -#define ISC_EVENT_COMMON(ltype) \ - size_t ev_size; \ - unsigned int ev_attributes; \ - isc_eventtype_t ev_type; \ - isc_taskaction_t ev_action; \ - void *ev_arg; \ - void *ev_sender; \ - isc_eventdestructor_t ev_destroy; \ - void *ev_destroy_arg; \ - void *backtrace[ISC__EVENT_TRACE_SIZE]; \ - int backtrace_size; \ - char func[PATH_MAX]; \ - char file[PATH_MAX]; \ - unsigned int line; \ - ISC_LINK(ltype) ev_link; \ - ISC_LINK(ltype) ev_ratelink - -#define ISC_EVENT_INIT(event, sz, at, ty, ac, ar, sn, df, da) \ - ISC__EVENT_INIT(event, sz, at, ty, ac, ar, sn, df, da, __func__, \ - __FILE__, __LINE__) - -#define ISC_EVENT_INIT_PASS(event, sz, at, ty, ac, ar, sn, df, da) \ - ISC__EVENT_INIT(event, sz, at, ty, ac, ar, sn, df, da, func, file, line) - -#define ISC__EVENT_INIT(event, sz, at, ty, ac, ar, sn, df, da, fn, fl, ln) \ - { \ - (event)->ev_size = (sz); \ - (event)->ev_attributes = (at); \ - (event)->ev_type = (ty); \ - (event)->ev_action = (ac); \ - (event)->ev_arg = (ar); \ - (event)->ev_sender = (sn); \ - (event)->ev_destroy = (df); \ - (event)->ev_destroy_arg = (da); \ - ISC_LINK_INIT((event), ev_link); \ - ISC_LINK_INIT((event), ev_ratelink); \ - strlcpy((event)->func, fn, sizeof((event)->func)); \ - strlcpy((event)->file, fl, sizeof((event)->file)); \ - (event)->line = ln; \ - (event)->backtrace_size = isc_backtrace( \ - (event)->backtrace, ISC__EVENT_TRACE_SIZE); \ - } - -#else -#define ISC__EVENT_FILELINE -#define ISC__EVENT_FLARG -#define ISC__EVENT_FLARG_PASS - -#define ISC_EVENT_COMMON(ltype) \ - size_t ev_size; \ - unsigned int ev_attributes; \ - isc_eventtype_t ev_type; \ - isc_taskaction_t ev_action; \ - void *ev_arg; \ - void *ev_sender; \ - isc_eventdestructor_t ev_destroy; \ - void *ev_destroy_arg; \ - ISC_LINK(ltype) ev_link; \ - ISC_LINK(ltype) ev_ratelink - -#define ISC_EVENT_INIT(event, sz, at, ty, ac, ar, sn, df, da) \ - { \ - (event)->ev_size = (sz); \ - (event)->ev_attributes = (at); \ - (event)->ev_type = (ty); \ - (event)->ev_action = (ac); \ - (event)->ev_arg = (ar); \ - (event)->ev_sender = (sn); \ - (event)->ev_destroy = (df); \ - (event)->ev_destroy_arg = (da); \ - ISC_LINK_INIT((event), ev_link); \ - ISC_LINK_INIT((event), ev_ratelink); \ - } - -#define ISC_EVENT_INIT_PASS ISC_EVENT_INIT - -#endif - -/*% - * Attributes matching a mask of 0x000000ff are reserved for the task library's - * definition. Attributes of 0xffffff00 may be used by the application - * or non-ISC libraries. - */ - -/*% - * The ISC_EVENTATTR_CANCELED attribute is intended to indicate - * that an event is delivered as a result of a canceled operation - * rather than successful completion, by mutual agreement - * between the sender and receiver. It is not set or used by - * the task system. - */ -#define ISC_EVENTATTR_CANCELED 0x00000002 - -/*% - * This structure is public because "subclassing" it may be useful when - * defining new event types. - */ -struct isc_event { - ISC_EVENT_COMMON(struct isc_event); -}; - -#define ISC_EVENT_PTR(p) ((isc_event_t **)(void *)(p)) - -ISC_LANG_BEGINDECLS - -#define isc_event_allocate(mctx, sender, type, action, arg, size) \ - isc__event_allocate(mctx, sender, type, action, arg, \ - size ISC__EVENT_FILELINE) - -isc_event_t * -isc__event_allocate(isc_mem_t *mctx, void *sender, isc_eventtype_t type, - isc_taskaction_t action, void *arg, - size_t size ISC__EVENT_FLARG); -/*%< - * Allocate an event structure. - * - * Allocate and initialize in a structure with initial elements - * defined by: - * - * \code - * struct { - * ISC_EVENT_COMMON(struct isc_event); - * ... - * }; - * \endcode - * - * Requires: - *\li 'size' >= sizeof(struct isc_event) - *\li 'action' to be non NULL - * - * Returns: - *\li a pointer to a initialized structure of the requested size. - *\li NULL if unable to allocate memory. - */ - -void -isc_event_free(isc_event_t **); - -ISC_LANG_ENDDECLS diff --git a/lib/isc/include/isc/eventclass.h b/lib/isc/include/isc/eventclass.h deleted file mode 100644 index f9c4c079e40..00000000000 --- a/lib/isc/include/isc/eventclass.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * SPDX-License-Identifier: MPL-2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -#pragma once - -/*! \file isc/eventclass.h - ***** Registry of Predefined Event Type Classes - *****/ - -/*% - * An event class is an unsigned 16 bit number. Each class may contain up - * to 65536 events. An event type is formed by adding the event number - * within the class to the class number. - * - */ - -#define ISC_EVENTCLASS(eclass) ((eclass) << 16) - -/*@{*/ -/*! - * Classes < 1024 are reserved for ISC use. - * Event classes >= 1024 and <= 65535 are reserved for application use. - */ - -#define ISC_EVENTCLASS_TASK ISC_EVENTCLASS(0) -#define ISC_EVENTCLASS_TIMER ISC_EVENTCLASS(1) -#define ISC_EVENTCLASS_SOCKET ISC_EVENTCLASS(2) -#define ISC_EVENTCLASS_FILE ISC_EVENTCLASS(3) -#define ISC_EVENTCLASS_DNS ISC_EVENTCLASS(4) -#define ISC_EVENTCLASS_OMAPI ISC_EVENTCLASS(5) -#define ISC_EVENTCLASS_RATELIMITER ISC_EVENTCLASS(6) -#define ISC_EVENTCLASS_ISCCC ISC_EVENTCLASS(7) -#define ISC_EVENTCLASS_NS ISC_EVENTCLASS(8) -/*@}*/ diff --git a/lib/isc/include/isc/httpd.h b/lib/isc/include/isc/httpd.h index 1f69a4c99d1..23472d0f821 100644 --- a/lib/isc/include/isc/httpd.h +++ b/lib/isc/include/isc/httpd.h @@ -17,10 +17,7 @@ #include -#include -#include #include -#include #include #include #include diff --git a/lib/isc/include/isc/managers.h b/lib/isc/include/isc/managers.h index 3f2061d0c68..9b7e0311ea0 100644 --- a/lib/isc/include/isc/managers.h +++ b/lib/isc/include/isc/managers.h @@ -16,16 +16,14 @@ #include #include #include -#include #include typedef struct isc_managers isc_managers_t; void isc_managers_create(isc_mem_t **mctx, uint32_t workers, - isc_loopmgr_t **loopmgrp, isc_nm_t **netmgrp, - isc_taskmgr_t **taskmgrp); + isc_loopmgr_t **loopmgrp, isc_nm_t **netmgrp); void isc_managers_destroy(isc_mem_t **mctx, isc_loopmgr_t **loopmgrp, - isc_nm_t **netmgrp, isc_taskmgr_t **taskmgrp); + isc_nm_t **netmgrp); diff --git a/lib/isc/include/isc/netmgr.h b/lib/isc/include/isc/netmgr.h index e41bbdf8591..2221897a9a3 100644 --- a/lib/isc/include/isc/netmgr.h +++ b/lib/isc/include/isc/netmgr.h @@ -292,20 +292,6 @@ isc_nm_stoplistening(isc_nmsocket_t *sock); * Stop listening on socket 'sock'. */ -void -isc_nm_pause(isc_nm_t *mgr); -/*%< - * Pause all processing, equivalent to taskmgr exclusive tasks. - * It won't return until all workers have been paused. - */ - -void -isc_nm_resume(isc_nm_t *mgr); -/*%< - * Resume paused processing. It will return immediately after signalling - * workers to resume. - */ - void isc_nm_read(isc_nmhandle_t *handle, isc_nm_recv_cb_t cb, void *cbarg); /* diff --git a/lib/isc/include/isc/task.h b/lib/isc/include/isc/task.h deleted file mode 100644 index 09d20b5fd97..00000000000 --- a/lib/isc/include/isc/task.h +++ /dev/null @@ -1,356 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * SPDX-License-Identifier: MPL-2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -#pragma once - -/***** - ***** Module Info - *****/ - -/*! \file isc/task.h - * \brief The task system provides a lightweight execution context, which is - * basically an event queue. - * - * When a task's event queue is non-empty, the - * task is runnable. A small work crew of threads, typically one per CPU, - * execute runnable tasks by dispatching the events on the tasks' event - * queues. Context switching between tasks is fast. - * - * \li MP: - * The module ensures appropriate synchronization of data structures it - * creates and manipulates. - * The caller must ensure that isc_taskmgr_destroy() is called only - * once for a given manager. - * - * \li Reliability: - * No anticipated impact. - * - * \li Resources: - * TBS - * - * \li Security: - * No anticipated impact. - * - * \li Standards: - * None. - * - * \section purge Purging and Unsending - * - * Events which have been queued for a task but not delivered may be removed - * from the task's event queue by purging the event. - * - * Purging calls isc_event_free() on the matching events. - * - */ - -/*** - *** Imports. - ***/ - -#include - -#include -#include -#include -#include -#include -#include -#include - -#if TASKMGR_TRACE -#define ISC__TASKTRACE_SIZE 8 -#define ISC__TASKFILELINE , __func__, __FILE__, __LINE__ -#define ISC__TASKFLARG , const char *func, const char *file, unsigned int line - -#else -#define ISC__TASKFILELINE -#define ISC__TASKFLARG -#endif - -#define ISC_TASKEVENT_SHUTDOWN (ISC_EVENTCLASS_TASK + 0) -#define ISC_TASKEVENT_TEST (ISC_EVENTCLASS_TASK + 1) - -/***** - ***** Tasks. - *****/ - -ISC_LANG_BEGINDECLS - -/*** - *** Types - ***/ - -#define isc_task_create(manager, taskp, tid) \ - isc__task_create(manager, taskp, tid ISC__TASKFILELINE) - -isc_result_t -isc__task_create(isc_taskmgr_t *manager, isc_task_t **taskp, - int tid ISC__TASKFLARG); -/*%< - * Create a task, bound to a particular thread id. - * - * Requires: - * - *\li 'manager' is a valid task manager. - * - *\li taskp != NULL && *taskp == NULL - * - * Ensures: - * - *\li On success, '*taskp' is bound to the new task. - * - * Returns: - * - *\li #ISC_R_SUCCESS - *\li #ISC_R_UNEXPECTED - *\li #ISC_R_SHUTTINGDOWN - */ - -ISC_REFCOUNT_DECL(isc_task); - -void -isc_task_send(isc_task_t *task, isc_event_t **eventp); -/*%< - * Send '*event' to 'task'. - * - * Requires: - * - *\li 'task' is a valid task. - *\li eventp != NULL && *eventp != NULL. - * - * Ensures: - * - *\li *eventp == NULL. - */ - -void -isc_task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp); -/*%< - * Send '*event' to '*taskp' and then detach '*taskp' from its - * task. - * - * Requires: - * - *\li '*taskp' is a valid task. - *\li eventp != NULL && *eventp != NULL. - * - * Ensures: - * - *\li *eventp == NULL. - * - *\li *taskp == NULL. - * - *\li If '*taskp' is the last reference to the task, the task is - * idle (has an empty event queue), and has not been shutdown, - * the task will be shutdown. - * - *\li If '*taskp' is the last reference to the task and - * the task has been shutdown, - * all resources used by the task will be freed. - */ - -void -isc_task_setname(isc_task_t *task, const char *name, void *tag); -/*%< - * Name 'task'. - * - * Notes: - * - *\li Only the first 15 characters of 'name' will be copied. - * - *\li Naming a task is currently only useful for debugging purposes. - * - * Requires: - * - *\li 'task' is a valid task. - */ - -isc_loopmgr_t * -isc_task_getloopmgr(isc_task_t *task); - -const char * -isc_task_getname(isc_task_t *task); -/*%< - * Get the name of 'task', as previously set using isc_task_setname(). - * - * Notes: - *\li This function is for debugging purposes only. - * - * Requires: - *\li 'task' is a valid task. - * - * Returns: - *\li A non-NULL pointer to a null-terminated string. - * If the task has not been named, the string is - * empty. - * - */ - -void * -isc_task_gettag(isc_task_t *task); -/*%< - * Get the tag value for 'task', as previously set using isc_task_settag(). - * - * Notes: - *\li This function is for debugging purposes only. - * - * Requires: - *\li 'task' is a valid task. - */ - -void -isc_task_beginexclusive(isc_task_t *task); -/*%< - * Request exclusive access for 'task', which must be the calling - * task. Waits for any other concurrently executing tasks to finish their - * current event, and prevents any new events from executing in any of the - * tasks sharing a task manager with 'task'. - * It also pauses processing of network events in netmgr if it was provided - * when taskmgr was created. - * - * The exclusive access must be relinquished by calling - * isc_task_endexclusive() before returning from the current event handler. - * - * Requires: - *\li 'task' is the calling task. - * - * Returns: - *\li #ISC_R_SUCCESS The current task now has exclusive access. - *\li #ISC_R_LOCKBUSY Another task has already requested exclusive - * access. - */ - -void -isc_task_endexclusive(isc_task_t *task); -/*%< - * Relinquish the exclusive access obtained by - *isc_task_beginexclusive(), allowing other tasks to execute. - * - * Requires: - *\li 'task' is the calling task, and has obtained - * exclusive access by calling isc_task_spl(). - */ - -/***** - ***** Task Manager. - *****/ - -void -isc_taskmgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, - isc_taskmgr_t **managerp); -/*%< - * Create a new task manager. - * - * Notes: - * - *\li This is meant to be called from isc_managers_create(). - * - * Requires: - * - *\li 'mctx' is a valid memory context. - - *\li 'loopmgr' is a valid loop manager. - * - *\li managerp != NULL && *managerp == NULL - * - * Ensures: - * - *\li On success, '*managerp' will be attached to the newly created task - * manager. - * - * Returns: - * - *\li #ISC_R_SUCCESS - *\li #ISC_R_NOMEMORY - *\li #ISC_R_NOTHREADS No threads could be created. - *\li #ISC_R_UNEXPECTED An unexpected error occurred. - *\li #ISC_R_SHUTTINGDOWN The non-threaded, shared, task - * manager shutting down. - */ - -void -isc_taskmgr_destroy(isc_taskmgr_t **managerp); -/*%< - * Destroy '*managerp'. - * - * Notes: - * - *\li Calling isc__taskmgr_destroy() will shut down all tasks managed by - * *managerp that haven't already been shutdown. The call will block - * until all tasks have entered the done state. - * - *\li isc__taskmgr_destroy() must not be called by a task event action, - * because it would block forever waiting for the event action to - * complete. An event action that wants to cause task manager shutdown - * should request some non-event action thread of execution to do the - * shutdown, e.g. by signaling a condition variable or using - * isc_loopmgr_shutdown(). - * - *\li The task manager is reference counted and will be destroyed when - * the last reference is detached. The only difference between this - * function and isc_task_detach() is that this one will assert if - * more than 1 reference is held. This function is only meant to be - * called from isc_managers_destroy(), by which time all other - * references should have been detached. If any are still being held, - * it's a programming error, and we want to crash. - * - * Requires: - * - *\li '*managerp' is a valid task manager. - * - *\li No other references to the task manager are being held. - */ - -void -isc_taskmgr_attach(isc_taskmgr_t *, isc_taskmgr_t **); -void -isc_taskmgr_detach(isc_taskmgr_t **); -/*%< - * Attach/detach the task manager. - */ - -void -isc_taskmgr_setexcltask(isc_taskmgr_t *mgr, isc_task_t *task); -/*%< - * Set a task which will be used for all task-exclusive operations. - * - * Requires: - *\li 'manager' is a valid task manager. - * - *\li 'task' is a valid task. - */ - -isc_result_t -isc_taskmgr_excltask(isc_taskmgr_t *mgr, isc_task_t **taskp); -/*%< - * Attach '*taskp' to the task set by isc_taskmgr_getexcltask(). - * This task should be used whenever running in task-exclusive mode, - * so as to prevent deadlock between two exclusive tasks. - * - * Requires: - *\li 'manager' is a valid task manager. - * - *\li taskp != NULL && *taskp == NULL - */ - -#ifdef HAVE_LIBXML2 -int -isc_taskmgr_renderxml(isc_taskmgr_t *mgr, void *writer0); -#endif /* ifdef HAVE_LIBXML2 */ - -#ifdef HAVE_JSON_C -isc_result_t -isc_taskmgr_renderjson(isc_taskmgr_t *mgr, void *tasksobj0); -#endif /* HAVE_JSON_C */ - -ISC_LANG_ENDDECLS diff --git a/lib/isc/include/isc/types.h b/lib/isc/include/isc/types.h index 8e3e9b5b19c..e8c08043bff 100644 --- a/lib/isc/include/isc/types.h +++ b/lib/isc/include/isc/types.h @@ -38,12 +38,9 @@ typedef struct isc_constregion isc_constregion_t; /*%< Const region */ typedef struct isc_consttextregion isc_consttextregion_t; /*%< Const Text Region */ typedef struct isc_counter isc_counter_t; /*%< Counter */ -typedef struct isc_event isc_event_t; /*%< Event */ -typedef ISC_LIST(isc_event_t) isc_eventlist_t; /*%< Event List */ -typedef unsigned int isc_eventtype_t; /*%< Event Type */ -typedef uint32_t isc_fsaccess_t; /*%< FS Access */ -typedef struct isc_hash isc_hash_t; /*%< Hash */ -typedef struct isc_httpd isc_httpd_t; /*%< HTTP client */ +typedef uint32_t isc_fsaccess_t; /*%< FS Access */ +typedef struct isc_hash isc_hash_t; /*%< Hash */ +typedef struct isc_httpd isc_httpd_t; /*%< HTTP client */ typedef void(isc_httpdfree_t)(isc_buffer_t *, void *); /*%< HTTP free function */ typedef struct isc_httpdmgr isc_httpdmgr_t; /*%< HTTP manager */ @@ -78,8 +75,6 @@ typedef ISC_LIST(isc_sockaddr_t) isc_sockaddrlist_t; /*%< Socket Address List typedef struct isc_stats isc_stats_t; /*%< Statistics */ typedef int_fast64_t isc_statscounter_t; typedef struct isc_symtab isc_symtab_t; /*%< Symbol Table */ -typedef struct isc_task isc_task_t; /*%< Task */ -typedef struct isc_taskmgr isc_taskmgr_t; /*%< Task Manager */ typedef struct isc_textregion isc_textregion_t; /*%< Text Region */ typedef struct isc_time isc_time_t; /*%< Time */ typedef struct isc_timer isc_timer_t; /*%< Timer */ @@ -91,8 +86,6 @@ typedef struct isc_nm_http_endpoints isc_nm_http_endpoints_t; /*%< HTTP endpoints set */ #endif /* HAVE_LIBNGHTTP2 */ -typedef void (*isc_taskaction_t)(isc_task_t *, isc_event_t *); - /*% Statistics formats (text file or XML) */ typedef enum { isc_statsformat_file, diff --git a/lib/isc/loop.c b/lib/isc/loop.c index e8eb88cc06a..6482b6be504 100644 --- a/lib/isc/loop.c +++ b/lib/isc/loop.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -484,6 +485,12 @@ void isc_loopmgr_pause(isc_loopmgr_t *loopmgr) { REQUIRE(VALID_LOOPMGR(loopmgr)); + if (isc_log_wouldlog(isc_lctx, ISC_LOG_DEBUG(1))) { + isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, + ISC_LOGMODULE_OTHER, ISC_LOG_DEBUG(1), + "loop exclusive mode: starting"); + } + for (size_t i = 0; i < loopmgr->nloops; i++) { isc_loop_t *loop = &loopmgr->loops[i]; @@ -499,15 +506,33 @@ isc_loopmgr_pause(isc_loopmgr_t *loopmgr) { RUNTIME_CHECK(atomic_compare_exchange_strong(&loopmgr->paused, &(bool){ false }, true)); pause_loop(CURRENT_LOOP(loopmgr)); + + if (isc_log_wouldlog(isc_lctx, ISC_LOG_DEBUG(1))) { + isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, + ISC_LOGMODULE_OTHER, ISC_LOG_DEBUG(1), + "loop exclusive mode: started"); + } } void isc_loopmgr_resume(isc_loopmgr_t *loopmgr) { REQUIRE(VALID_LOOPMGR(loopmgr)); + if (isc_log_wouldlog(isc_lctx, ISC_LOG_DEBUG(1))) { + isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, + ISC_LOGMODULE_OTHER, ISC_LOG_DEBUG(1), + "loop exclusive mode: ending"); + } + RUNTIME_CHECK(atomic_compare_exchange_strong(&loopmgr->paused, &(bool){ true }, false)); resume_loop(CURRENT_LOOP(loopmgr)); + + if (isc_log_wouldlog(isc_lctx, ISC_LOG_DEBUG(1))) { + isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, + ISC_LOGMODULE_OTHER, ISC_LOG_DEBUG(1), + "loop exclusive mode: ended"); + } } void diff --git a/lib/isc/managers.c b/lib/isc/managers.c index 9fcade3e619..5471122300a 100644 --- a/lib/isc/managers.c +++ b/lib/isc/managers.c @@ -18,8 +18,7 @@ void isc_managers_create(isc_mem_t **mctxp, uint32_t workers, - isc_loopmgr_t **loopmgrp, isc_nm_t **netmgrp, - isc_taskmgr_t **taskmgrp) { + isc_loopmgr_t **loopmgrp, isc_nm_t **netmgrp) { REQUIRE(mctxp != NULL && *mctxp == NULL); isc_mem_create(mctxp); INSIST(*mctxp != NULL); @@ -32,26 +31,20 @@ isc_managers_create(isc_mem_t **mctxp, uint32_t workers, isc_netmgr_create(*mctxp, *loopmgrp, netmgrp); INSIST(*netmgrp != NULL); - REQUIRE(taskmgrp != NULL && *taskmgrp == NULL); - isc_taskmgr_create(*mctxp, *loopmgrp, taskmgrp); - INSIST(*taskmgrp != NULL); - isc_rwlock_setworkers(workers); } void isc_managers_destroy(isc_mem_t **mctxp, isc_loopmgr_t **loopmgrp, - isc_nm_t **netmgrp, isc_taskmgr_t **taskmgrp) { + isc_nm_t **netmgrp) { REQUIRE(mctxp != NULL && *mctxp != NULL); REQUIRE(loopmgrp != NULL && *loopmgrp != NULL); REQUIRE(netmgrp != NULL && *netmgrp != NULL); - REQUIRE(taskmgrp != NULL && *taskmgrp != NULL); /* * The sequence of operations here is important: */ - isc_taskmgr_destroy(taskmgrp); isc_netmgr_destroy(netmgrp); isc_loopmgr_destroy(loopmgrp); isc_mem_destroy(mctxp); diff --git a/lib/isc/netmgr/netmgr.c b/lib/isc/netmgr/netmgr.c index fbd3c89f9c9..cf9601e5be4 100644 --- a/lib/isc/netmgr/netmgr.c +++ b/lib/isc/netmgr/netmgr.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/isc/ratelimiter.c b/lib/isc/ratelimiter.c index 8873600acc9..a7c59152117 100644 --- a/lib/isc/ratelimiter.c +++ b/lib/isc/ratelimiter.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/isc/task.c b/lib/isc/task.c deleted file mode 100644 index 8b75e4938da..00000000000 --- a/lib/isc/task.c +++ /dev/null @@ -1,939 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * SPDX-License-Identifier: MPL-2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -/*! \file */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_LIBXML2 -#include -#define ISC_XMLCHAR (const xmlChar *) -#endif /* HAVE_LIBXML2 */ - -#ifdef HAVE_JSON_C -#include -#endif /* HAVE_JSON_C */ - -#include "loop_p.h" - -/* - * Task manager is built around 'as little locking as possible' concept. - * Each thread has his own queue of tasks to be run, if a task is in running - * state it will stay on the runner it's currently on - that helps with data - * locality on CPU. - * - * To make load even some tasks (from task pools) are bound to specific - * queues using isc_task_create. This way load balancing between - * CPUs/queues happens on the higher layer. - */ - -#ifdef ISC_TASK_TRACE -#define XTRACE(m) \ - fprintf(stderr, "task %p.tid %zu thread %zu: %s\n", task, \ - (size_t)task->tid, (size_t)task->tid, (m)) -#define XTTRACE(t, m) \ - fprintf(stderr, "task %p thread %zu: %s\n", (t), (size_t)isc_tid(), (m)) -#define XTHREADTRACE(m) \ - fprintf(stderr, "thread %zu: %s\n", (size_t)isc_tid(), (m)) -#else /* ifdef ISC_TASK_TRACE */ -#define XTRACE(m) -#define XTTRACE(t, m) -#define XTHREADTRACE(m) -#endif /* ifdef ISC_TASK_TRACE */ - -/*** - *** Types. - ***/ - -typedef enum { - task_state_idle, /* not doing anything, events queue empty */ - task_state_ready, /* waiting in worker's queue */ - task_state_running, /* actively processing events */ - task_state_done /* shutting down, no events or references */ -} task_state_t; - -#if defined(HAVE_LIBXML2) || defined(HAVE_JSON_C) -static const char *statenames[] = { - "idle", - "ready", - "running", - "done", -}; -#endif /* if defined(HAVE_LIBXML2) || defined(HAVE_JSON_C) */ - -#define TASK_MAGIC ISC_MAGIC('T', 'A', 'S', 'K') -#define VALID_TASK(t) ISC_MAGIC_VALID(t, TASK_MAGIC) - -#if TASKMGR_TRACE -void -isc__taskmgr_dump_active(isc_taskmgr_t *taskmgr); -#endif - -struct isc_task { - /* Not locked. */ - unsigned int magic; - isc_taskmgr_t *manager; - isc_mutex_t lock; - /* Locked by task lock. */ - isc_loop_t *loop; - uint32_t tid; - task_state_t state; - isc_refcount_t references; - isc_eventlist_t events; - unsigned int nevents; - isc_stdtime_t now; - isc_time_t tnow; - char name[16]; - void *tag; - /* Locked by task manager lock. */ -#if TASKMGR_TRACE - char func[PATH_MAX]; - char file[PATH_MAX]; - unsigned int line; - void *backtrace[ISC__TASKTRACE_SIZE]; - int backtrace_size; -#endif - LINK(isc_task_t) qlink; - LINK(isc_task_t) link; -}; - -#define TASK_SHUTTINGDOWN(t) (atomic_load_acquire(&(t)->manager->shuttingdown)) - -#define TASK_TASKMGR_MAGIC ISC_MAGIC('T', 'S', 'K', 'M') -#define VALID_TASKMGR(m) ISC_MAGIC_VALID(m, TASK_TASKMGR_MAGIC) - -typedef ISC_LIST(isc_task_t) isc_tasklist_t; - -struct isc_taskmgr { - /* Not locked. */ - unsigned int magic; - isc_refcount_t references; - isc_mem_t *mctx; - isc_mutex_t lock; - isc_loopmgr_t *loopmgr; - uint32_t nloops; - - /* Locked by task manager lock. */ - isc_mutex_t *locks; - isc_tasklist_t *tasks; - atomic_uint_fast32_t mode; - uint32_t exclusive_req; - atomic_bool shuttingdown; - isc_task_t *excl; -}; - -static void -task_setstate(isc_task_t *task, task_state_t state); - -/*** - *** Tasks. - ***/ - -static void -task_destroy(void *arg) { - isc_task_t *task = arg; - isc_loop_t *loop = task->loop; - isc_taskmgr_t *taskmgr = task->manager; - REQUIRE(EMPTY(task->events)); - - XTRACE("task_finished"); - - task_setstate(task, task_state_done); - - isc_refcount_destroy(&task->references); - - LOCK(&taskmgr->locks[task->tid]); - UNLINK(taskmgr->tasks[task->tid], task, link); - UNLOCK(&taskmgr->locks[task->tid]); - - isc_mutex_destroy(&task->lock); - task->magic = 0; - - isc_mem_put(loop->mctx, task, sizeof(*task)); - - isc_taskmgr_detach(&taskmgr); - - isc_loop_detach(&loop); -} -ISC_REFCOUNT_IMPL(isc_task, task_destroy); - -static isc_result_t -task_run(isc_task_t *task); -static void -task_ready(isc_task_t *task); -static void -task__run(void *arg); - -isc_result_t -isc__task_create(isc_taskmgr_t *taskmgr, isc_task_t **taskp, - int tid ISC__TASKFLARG) { - isc_task_t *task = NULL; - isc_loop_t *loop = NULL; - - REQUIRE(VALID_TASKMGR(taskmgr)); - REQUIRE(taskp != NULL && *taskp == NULL); - REQUIRE(tid >= 0 && tid < (int)taskmgr->nloops); - - if (atomic_load(&taskmgr->shuttingdown)) { - return (ISC_R_SHUTTINGDOWN); - } - - loop = isc_loop_get(taskmgr->loopmgr, tid); - - task = isc_mem_get(loop->mctx, sizeof(*task)); - *task = (isc_task_t){ - .tid = tid, - .state = task_state_idle, - }; - - isc_loop_attach(loop, &task->loop); - -#if TASKMGR_TRACE - strlcpy(task->func, func, sizeof(task->func)); - strlcpy(task->file, file, sizeof(task->file)); - task->line = line; - task->backtrace_size = isc_backtrace(task->backtrace, - ISC__TASKTRACE_SIZE); -#endif - - isc_taskmgr_attach(taskmgr, &task->manager); - - isc_mutex_init(&task->lock); - - isc_refcount_init(&task->references, 1); - - INIT_LIST(task->events); - - isc_time_settoepoch(&task->tnow); - - INIT_LINK(task, link); - INIT_LINK(task, qlink); - - task->magic = TASK_MAGIC; - - LOCK(&taskmgr->locks[task->tid]); - APPEND(taskmgr->tasks[task->tid], task, link); - UNLOCK(&taskmgr->locks[task->tid]); - - *taskp = task; - - return (ISC_R_SUCCESS); -} - -static void -task_setstate(isc_task_t *task, task_state_t state) { - switch (state) { - case task_state_idle: - INSIST(task->state == task_state_running); - break; - case task_state_ready: - if (task->state == task_state_idle) { - INSIST(EMPTY(task->events)); - } else { - INSIST(task->state == task_state_running); - } - break; - case task_state_running: - INSIST(task->state == task_state_ready); - break; - case task_state_done: - INSIST(task->state == task_state_ready || - task->state == task_state_running || - task->state == task_state_idle); - break; - default: - UNREACHABLE(); - } - - task->state = state; -} - -static void -task__run(void *arg) { - isc_task_t *task = arg; - isc_result_t result = task_run(task); - - switch (result) { - case ISC_R_QUOTA: - task_ready(task); - break; - case ISC_R_SUCCESS: - case ISC_R_NOMORE: - break; - default: - UNREACHABLE(); - } -} - -/* - * Moves a task onto the appropriate run queue. - * - * Caller must NOT hold queue lock. - */ -static void -task_ready(isc_task_t *task) { - isc_async_run(task->loop, task__run, task); -} - -static bool -task_send(isc_task_t *task, isc_event_t **eventp) { - bool was_idle = false; - isc_event_t *event; - - /* - * Caller must be holding the task lock. - */ - - REQUIRE(eventp != NULL); - event = *eventp; - *eventp = NULL; - REQUIRE(event != NULL); - REQUIRE(task->state != task_state_done); - REQUIRE(!ISC_LINK_LINKED(event, ev_ratelink)); - - XTRACE("task_send"); - - if (task->state == task_state_idle) { - was_idle = true; - task_setstate(task, task_state_ready); - isc_task_attach(task, &(isc_task_t *){ NULL }); - } - INSIST(task->state == task_state_ready || - task->state == task_state_running); - ENQUEUE(task->events, event, ev_link); - - return (was_idle); -} - -void -isc_task_send(isc_task_t *task, isc_event_t **eventp) { - bool was_idle; - - /* - * Send '*event' to 'task'. - */ - - REQUIRE(VALID_TASK(task)); - XTRACE("isc_task_send"); - - /* - * We're trying hard to hold locks for as short a time as possible. - * We're also trying to hold as few locks as possible. This is why - * some processing is deferred until after the lock is released. - */ - LOCK(&task->lock); - was_idle = task_send(task, eventp); - UNLOCK(&task->lock); - - if (was_idle) { - /* - * We need to add this task to the ready queue. - * - * We've waited until now to do it because making a task - * ready requires locking the manager. If we tried to do - * this while holding the task lock, we could deadlock. - * - * We've changed the state to ready, so no one else will - * be trying to add this task to the ready queue. The - * only way to leave the ready state is by executing the - * task. It thus doesn't matter if events are added, - * removed, or a shutdown is started in the interval - * between the time we released the task lock, and the time - * we add the task to the ready queue. - */ - task_ready(task); - } -} - -void -isc_task_sendanddetach(isc_task_t **taskp, isc_event_t **eventp) { - isc_task_t *task = NULL; - - REQUIRE(taskp != NULL); - - task = *taskp; - *taskp = NULL; - - REQUIRE(VALID_TASK(task)); - XTRACE("isc_task_sendanddetach"); - - isc_task_send(task, eventp); - isc_task_detach(&task); -} - -void -isc_task_setname(isc_task_t *task, const char *name, void *tag) { - /* - * Name 'task'. - */ - - REQUIRE(VALID_TASK(task)); - - LOCK(&task->lock); - strlcpy(task->name, name, sizeof(task->name)); - task->tag = tag; - UNLOCK(&task->lock); -} - -isc_loopmgr_t * -isc_task_getloopmgr(isc_task_t *task) { - REQUIRE(VALID_TASK(task)); - - return (task->manager->loopmgr); -} - -const char * -isc_task_getname(isc_task_t *task) { - REQUIRE(VALID_TASK(task)); - - return (task->name); -} - -void * -isc_task_gettag(isc_task_t *task) { - REQUIRE(VALID_TASK(task)); - - return (task->tag); -} - -/*** - *** Task Manager. - ***/ - -static isc_result_t -task_run(isc_task_t *task) { - isc_event_t *event = NULL; - isc_result_t result = ISC_R_UNSET; - isc_eventlist_t events; - - REQUIRE(VALID_TASK(task)); - - LOCK(&task->lock); - - ISC_LIST_INIT(events); - ISC_LIST_MOVE(events, task->events); - - REQUIRE(task->state == task_state_ready); - - task_setstate(task, task_state_running); - XTRACE("running"); - XTRACE(task->name); - TIME_NOW(&task->tnow); - task->now = isc_time_seconds(&task->tnow); - UNLOCK(&task->lock); - - event = ISC_LIST_HEAD(events); - while (event != NULL) { - isc_event_t *next = ISC_LIST_NEXT(event, ev_link); - ISC_LIST_UNLINK(events, event, ev_link); - - /* - * Execute the event action. - */ - XTRACE("execute action"); - XTRACE(task->name); - if (event->ev_action != NULL) { - (event->ev_action)(task, event); - } - XTRACE("execution complete"); - - event = next; - } - - LOCK(&task->lock); - if (EMPTY(task->events)) { - /* - * Nothing else to do for this task right now. - */ - XTRACE("empty"); - XTRACE("idling"); - task_setstate(task, task_state_idle); - - result = ISC_R_SUCCESS; - } else { - /* - * More tasks were scheduled. - */ - XTRACE("quantum"); - task_setstate(task, task_state_ready); - result = ISC_R_QUOTA; - } - UNLOCK(&task->lock); - - if (result == ISC_R_SUCCESS) { - isc_task_detach(&task); - } - - return (result); -} - -static void -taskmgr_destroy(isc_taskmgr_t *taskmgr) { - taskmgr->magic = 0; - - for (size_t tid = 0; tid < taskmgr->nloops; tid++) { - INSIST(EMPTY(taskmgr->tasks[tid])); - isc_mutex_destroy(&taskmgr->locks[tid]); - } - - isc_mem_put(taskmgr->mctx, taskmgr->tasks, - taskmgr->nloops * sizeof(taskmgr->tasks[0])); - isc_mem_put(taskmgr->mctx, taskmgr->locks, - taskmgr->nloops * sizeof(taskmgr->locks[0])); - - isc_refcount_destroy(&taskmgr->references); - isc_mutex_destroy(&taskmgr->lock); - isc_mem_putanddetach(&taskmgr->mctx, taskmgr, sizeof(*taskmgr)); -} - -void -isc_taskmgr_attach(isc_taskmgr_t *source, isc_taskmgr_t **targetp) { - REQUIRE(VALID_TASKMGR(source)); - REQUIRE(targetp != NULL && *targetp == NULL); - - isc_refcount_increment(&source->references); - - *targetp = source; -} - -void -isc_taskmgr_detach(isc_taskmgr_t **managerp) { - REQUIRE(managerp != NULL); - REQUIRE(VALID_TASKMGR(*managerp)); - - isc_taskmgr_t *manager = *managerp; - *managerp = NULL; - - if (isc_refcount_decrement(&manager->references) == 1) { - taskmgr_destroy(manager); - } -} - -static void -taskmgr_teardown(void *arg) { - isc_taskmgr_t *taskmgr = (void *)arg; - uint32_t tid = isc_tid(); - isc_task_t *excl = NULL; - - REQUIRE(VALID_TASKMGR(taskmgr)); - - atomic_store(&taskmgr->shuttingdown, true); - - isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, ISC_LOGMODULE_NETMGR, - ISC_LOG_DEBUG(1), "Shutting down task manager"); - - LOCK(&taskmgr->lock); - if (taskmgr->excl != NULL && taskmgr->excl->tid == tid) { - XTTRACE(taskmgr->excl, "taskmgr_teardown: excl"); - excl = taskmgr->excl; - taskmgr->excl = NULL; - } - UNLOCK(&taskmgr->lock); - if (excl != NULL) { - isc_task_detach(&excl); - } -} - -void -isc_taskmgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, - isc_taskmgr_t **taskmgrp) { - isc_taskmgr_t *taskmgr = NULL; - - /* - * Create a new task manager. - */ - - REQUIRE(taskmgrp != NULL && *taskmgrp == NULL); - - taskmgr = isc_mem_get(mctx, sizeof(*taskmgr)); - *taskmgr = (isc_taskmgr_t){ - .loopmgr = loopmgr, - .magic = TASK_TASKMGR_MAGIC, - .nloops = isc_loopmgr_nloops(loopmgr), - }; - - isc_mem_attach(mctx, &taskmgr->mctx); - - isc_mutex_init(&taskmgr->lock); - - taskmgr->tasks = isc_mem_get( - taskmgr->mctx, taskmgr->nloops * sizeof(taskmgr->tasks[0])); - taskmgr->locks = isc_mem_get( - taskmgr->mctx, taskmgr->nloops * sizeof(taskmgr->locks[0])); - - for (size_t tid = 0; tid < taskmgr->nloops; tid++) { - isc_mutex_init(&taskmgr->locks[tid]); - ISC_LIST_INIT(taskmgr->tasks[tid]); - } - - isc_loopmgr_teardown(loopmgr, taskmgr_teardown, taskmgr); - - isc_refcount_init(&taskmgr->references, 1); - - *taskmgrp = taskmgr; -} - -void -isc_taskmgr_destroy(isc_taskmgr_t **managerp) { - isc_taskmgr_t *manager = NULL; - uint_fast32_t refs; - - REQUIRE(managerp != NULL && VALID_TASKMGR(*managerp)); - XTHREADTRACE("isc_taskmgr_destroy"); - - manager = *managerp; - *managerp = NULL; - - /* - * The isc_loopmgr is not running, there's nothing that can finish now - */ - refs = isc_refcount_decrement(&manager->references); -#if TASKMGR_TRACE - if (refs > 1) { - isc__taskmgr_dump_active(*managerp); - } -#endif - INSIST(refs == 1); - taskmgr_destroy(manager); -} - -void -isc_taskmgr_setexcltask(isc_taskmgr_t *mgr, isc_task_t *task) { - REQUIRE(VALID_TASKMGR(mgr)); - REQUIRE(VALID_TASK(task)); - - LOCK(&task->lock); - REQUIRE(task->tid == 0); - UNLOCK(&task->lock); - - LOCK(&mgr->lock); - if (mgr->excl != NULL) { - isc_task_detach(&mgr->excl); - } - isc_task_attach(task, &mgr->excl); - UNLOCK(&mgr->lock); -} - -isc_result_t -isc_taskmgr_excltask(isc_taskmgr_t *mgr, isc_task_t **taskp) { - isc_result_t result; - - REQUIRE(VALID_TASKMGR(mgr)); - REQUIRE(taskp != NULL && *taskp == NULL); - - if (atomic_load(&mgr->shuttingdown)) { - return (ISC_R_SHUTTINGDOWN); - } - - LOCK(&mgr->lock); - if (mgr->excl != NULL) { - isc_task_attach(mgr->excl, taskp); - result = ISC_R_SUCCESS; - } else { - result = ISC_R_NOTFOUND; - } - UNLOCK(&mgr->lock); - - return (result); -} - -void -isc_task_beginexclusive(isc_task_t *task) { - isc_taskmgr_t *manager; - bool first; - - REQUIRE(VALID_TASK(task)); - - manager = task->manager; - - REQUIRE(task->state == task_state_running); - - LOCK(&manager->lock); - REQUIRE(task == manager->excl || - (atomic_load(&manager->shuttingdown) && manager->excl == NULL)); - first = (manager->exclusive_req++ == 0); - UNLOCK(&manager->lock); - - if (!first) { - return; - } - - if (isc_log_wouldlog(isc_lctx, ISC_LOG_DEBUG(1))) { - isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, - ISC_LOGMODULE_OTHER, ISC_LOG_DEBUG(1), - "exclusive task mode: %s", "starting"); - } - - isc_loopmgr_pause(manager->loopmgr); - - if (isc_log_wouldlog(isc_lctx, ISC_LOG_DEBUG(1))) { - isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, - ISC_LOGMODULE_OTHER, ISC_LOG_DEBUG(1), - "exclusive task mode: %s", "started"); - } -} - -void -isc_task_endexclusive(isc_task_t *task) { - isc_taskmgr_t *manager = NULL; - bool last; - - REQUIRE(VALID_TASK(task)); - REQUIRE(task->state == task_state_running); - - manager = task->manager; - - LOCK(&manager->lock); - INSIST(manager->exclusive_req > 0); - last = (--manager->exclusive_req == 0); - UNLOCK(&manager->lock); - - if (!last) { - return; - } - - if (isc_log_wouldlog(isc_lctx, ISC_LOG_DEBUG(1))) { - isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, - ISC_LOGMODULE_OTHER, ISC_LOG_DEBUG(1), - "exclusive task mode: %s", "ending"); - } - - isc_loopmgr_resume(manager->loopmgr); - - if (isc_log_wouldlog(isc_lctx, ISC_LOG_DEBUG(1))) { - isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL, - ISC_LOGMODULE_OTHER, ISC_LOG_DEBUG(1), - "exclusive task mode: %s", "ended"); - } -} - -#ifdef HAVE_LIBXML2 -#define TRY0(a) \ - do { \ - xmlrc = (a); \ - if (xmlrc < 0) \ - goto error; \ - } while (0) -int -isc_taskmgr_renderxml(isc_taskmgr_t *mgr, void *writer0) { - isc_task_t *task = NULL; - int xmlrc; - xmlTextWriterPtr writer = (xmlTextWriterPtr)writer0; - - LOCK(&mgr->lock); - - TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "tasks")); - for (size_t tid = 0; tid < mgr->nloops; tid++) { - for (task = ISC_LIST_HEAD(mgr->tasks[tid]); task != NULL; - task = ISC_LIST_NEXT(task, link)) - { - LOCK(&task->lock); - TRY0(xmlTextWriterStartElement(writer, - ISC_XMLCHAR "task")); - - if (task->name[0] != 0) { - TRY0(xmlTextWriterStartElement( - writer, ISC_XMLCHAR "name")); - TRY0(xmlTextWriterWriteFormatString( - writer, "%s", task->name)); - TRY0(xmlTextWriterEndElement(writer)); /* name - */ - } - - TRY0(xmlTextWriterStartElement(writer, - ISC_XMLCHAR "reference" - "s")); - TRY0(xmlTextWriterWriteFormatString( - writer, "%" PRIuFAST32, - isc_refcount_current(&task->references))); - TRY0(xmlTextWriterEndElement(writer)); /* references */ - - TRY0(xmlTextWriterStartElement(writer, - ISC_XMLCHAR "id")); - TRY0(xmlTextWriterWriteFormatString(writer, "%p", - task)); - TRY0(xmlTextWriterEndElement(writer)); /* id */ - - TRY0(xmlTextWriterStartElement(writer, - ISC_XMLCHAR "state")); - TRY0(xmlTextWriterWriteFormatString( - writer, "%s", statenames[task->state])); - TRY0(xmlTextWriterEndElement(writer)); /* state */ - - TRY0(xmlTextWriterEndElement(writer)); - - UNLOCK(&task->lock); - } - } - TRY0(xmlTextWriterEndElement(writer)); /* tasks */ - -error: - if (task != NULL) { - UNLOCK(&task->lock); - } - UNLOCK(&mgr->lock); - - return (xmlrc); -} -#endif /* HAVE_LIBXML2 */ - -#ifdef HAVE_JSON_C -#define CHECKMEM(m) \ - do { \ - if (m == NULL) { \ - result = ISC_R_NOMEMORY; \ - goto error; \ - } \ - } while (0) - -isc_result_t -isc_taskmgr_renderjson(isc_taskmgr_t *mgr, void *tasks0) { - isc_result_t result = ISC_R_SUCCESS; - isc_task_t *task = NULL; - json_object *obj = NULL, *array = NULL, *taskobj = NULL; - json_object *tasks = (json_object *)tasks0; - - LOCK(&mgr->lock); - - array = json_object_new_array(); - CHECKMEM(array); - - for (size_t tid = 0; tid < mgr->nloops; tid++) { - for (task = ISC_LIST_HEAD(mgr->tasks[tid]); task != NULL; - task = ISC_LIST_NEXT(task, link)) - { - char buf[255]; - - LOCK(&task->lock); - - taskobj = json_object_new_object(); - CHECKMEM(taskobj); - json_object_array_add(array, taskobj); - - snprintf(buf, sizeof(buf), "%p", task); - obj = json_object_new_string(buf); - CHECKMEM(obj); - json_object_object_add(taskobj, "id", obj); - - if (task->name[0] != 0) { - obj = json_object_new_string(task->name); - CHECKMEM(obj); - json_object_object_add(taskobj, "name", obj); - } - - obj = json_object_new_int( - isc_refcount_current(&task->references)); - CHECKMEM(obj); - json_object_object_add(taskobj, "references", obj); - - obj = json_object_new_string(statenames[task->state]); - CHECKMEM(obj); - json_object_object_add(taskobj, "state", obj); - - UNLOCK(&task->lock); - } - } - - json_object_object_add(tasks, "tasks", array); - array = NULL; - result = ISC_R_SUCCESS; - -error: - if (array != NULL) { - json_object_put(array); - } - - if (task != NULL) { - UNLOCK(&task->lock); - } - UNLOCK(&mgr->lock); - - return (result); -} -#endif /* ifdef HAVE_JSON_C */ - -#if TASKMGR_TRACE - -static void -event_dump(isc_event_t *event) { - fprintf(stderr, " - event: %p\n", event); - fprintf(stderr, " func: %s\n", event->func); - fprintf(stderr, " file: %s\n", event->file); - fprintf(stderr, " line: %u\n", event->line); - fprintf(stderr, " backtrace: |\n"); - isc_backtrace_symbols_fd(event->backtrace, event->backtrace_size, - STDERR_FILENO); -} - -static void -task_dump(isc_task_t *task) { - LOCK(&task->lock); - fprintf(stderr, "- task: %p\n", task); - fprintf(stderr, " tid: %" PRIu32 "\n", task->tid); - fprintf(stderr, " nevents: %u\n", task->nevents); - fprintf(stderr, " func: %s\n", task->func); - fprintf(stderr, " file: %s\n", task->file); - fprintf(stderr, " line: %u\n", task->line); - fprintf(stderr, " backtrace: |\n"); - isc_backtrace_symbols_fd(task->backtrace, task->backtrace_size, - STDERR_FILENO); - fprintf(stderr, "\n"); - - for (isc_event_t *event = ISC_LIST_HEAD(task->events); event != NULL; - event = ISC_LIST_NEXT(event, ev_link)) - { - event_dump(event); - } - - UNLOCK(&task->lock); -} - -void -isc__taskmgr_dump_active(isc_taskmgr_t *taskmgr) { - LOCK(&taskmgr->lock); - fprintf(stderr, "- taskmgr: %p\n", taskmgr); - - for (size_t tid = 0; tid < taskmgr->nloops; tid++) { - for (isc_task_t *task = ISC_LIST_HEAD(taskmgr->tasks[tid]); - task != NULL; task = ISC_LIST_NEXT(task, link)) - { - task_dump(task); - } - } - - UNLOCK(&taskmgr->lock); -} - -#endif diff --git a/lib/isc/timer.c b/lib/isc/timer.c index 0d9efbe5c39..e277ea7559f 100644 --- a/lib/isc/timer.c +++ b/lib/isc/timer.c @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/isccc/Makefile.am b/lib/isccc/Makefile.am index 7877bfbb180..cb70a6686bd 100644 --- a/lib/isccc/Makefile.am +++ b/lib/isccc/Makefile.am @@ -8,7 +8,6 @@ libisccc_la_HEADERS = \ include/isccc/base64.h \ include/isccc/cc.h \ include/isccc/ccmsg.h \ - include/isccc/events.h \ include/isccc/sexpr.h \ include/isccc/symtab.h \ include/isccc/symtype.h \ diff --git a/lib/isccc/ccmsg.c b/lib/isccc/ccmsg.c index 1ef5eb6ea2d..1f0d2f00dd6 100644 --- a/lib/isccc/ccmsg.c +++ b/lib/isccc/ccmsg.c @@ -38,7 +38,6 @@ #include #include -#include #define CCMSG_MAGIC ISC_MAGIC('C', 'C', 'm', 's') #define VALID_CCMSG(foo) ISC_MAGIC_VALID(foo, CCMSG_MAGIC) diff --git a/lib/isccc/include/isccc/events.h b/lib/isccc/include/isccc/events.h deleted file mode 100644 index ddbfbcd79de..00000000000 --- a/lib/isccc/include/isccc/events.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * SPDX-License-Identifier: MPL-2.0 AND ISC - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -/* - * Copyright (C) 2001 Nominum, Inc. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NOMINUM DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#pragma once - -/*! \file isccc/events.h */ - -#include - -/*% - * Registry of ISCCC event numbers. - */ - -#define ISCCC_EVENT_CCMSG (ISC_EVENTCLASS_ISCCC + 0) diff --git a/lib/ns/Makefile.am b/lib/ns/Makefile.am index eb86aebe186..37274babe55 100644 --- a/lib/ns/Makefile.am +++ b/lib/ns/Makefile.am @@ -9,7 +9,6 @@ libns_ladir = $(includedir)/ns libns_la_HEADERS = \ include/ns/client.h \ - include/ns/events.h \ include/ns/hooks.h \ include/ns/interfacemgr.h \ include/ns/listenlist.h \ diff --git a/lib/ns/client.c b/lib/ns/client.c index 335508d65b2..a5d3aa6aa05 100644 --- a/lib/ns/client.c +++ b/lib/ns/client.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -45,7 +44,6 @@ #include #include #include -#include #include #include #include @@ -82,7 +80,7 @@ * need for locking. * * If a routine is ever created that allows someone other than the client's - * task to change the client, then the client will have to be locked. + * loop to change the client, then the client will have to be locked. */ #ifdef NS_CLIENT_TRACE @@ -2392,14 +2390,16 @@ clientmgr_destroy_cb(void *arg) { ns_clientmgr_t *manager = (ns_clientmgr_t *)arg; MTRACE("clientmgr_destroy"); - isc_refcount_destroy(&manager->references); manager->magic = 0; + isc_refcount_destroy(&manager->references); + + isc_loop_detach(&manager->loop); + dns_aclenv_detach(&manager->aclenv); isc_mutex_destroy(&manager->reclock); - isc_task_detach(&manager->task); ns_server_detach(&manager->sctx); isc_mem_putanddetach(&manager->mctx, manager, sizeof(*manager)); @@ -2407,46 +2407,33 @@ clientmgr_destroy_cb(void *arg) { static void clientmgr_destroy(ns_clientmgr_t *mgr) { - isc_loop_t *loop = isc_loop_get(mgr->loopmgr, mgr->tid); - isc_async_run(loop, clientmgr_destroy_cb, mgr); + isc_async_run(mgr->loop, clientmgr_destroy_cb, mgr); } ISC_REFCOUNT_IMPL(ns_clientmgr, clientmgr_destroy); isc_result_t -ns_clientmgr_create(ns_server_t *sctx, isc_taskmgr_t *taskmgr, - isc_loopmgr_t *loopmgr, dns_aclenv_t *aclenv, int tid, - ns_clientmgr_t **managerp) { +ns_clientmgr_create(ns_server_t *sctx, isc_loopmgr_t *loopmgr, + dns_aclenv_t *aclenv, int tid, ns_clientmgr_t **managerp) { ns_clientmgr_t *manager = NULL; isc_mem_t *mctx = NULL; - isc_result_t result; isc_mem_create(&mctx); isc_mem_setname(mctx, "clientmgr"); manager = isc_mem_get(mctx, sizeof(*manager)); - *manager = (ns_clientmgr_t){ .magic = 0, .mctx = mctx }; - + *manager = (ns_clientmgr_t){ + .magic = 0, + .mctx = mctx, + .tid = tid, + .recursing = ISC_LIST_INITIALIZER, + }; + isc_loop_attach(isc_loop_get(loopmgr, tid), &manager->loop); isc_mutex_init(&manager->reclock); - - manager->taskmgr = taskmgr; - manager->loopmgr = loopmgr; - manager->tid = tid; - manager->loop = isc_loop_get(loopmgr, tid); - dns_aclenv_attach(aclenv, &manager->aclenv); - - result = isc_task_create(manager->taskmgr, &manager->task, - manager->tid); - RUNTIME_CHECK(result == ISC_R_SUCCESS); - isc_task_setname(manager->task, "clientmgr", NULL); - isc_refcount_init(&manager->references, 1); - manager->sctx = NULL; ns_server_attach(sctx, &manager->sctx); - ISC_LIST_INIT(manager->recursing); - manager->magic = MANAGER_MAGIC; MTRACE("create"); diff --git a/lib/ns/include/ns/client.h b/lib/ns/include/ns/client.h index e1701371d59..bfd4e131c40 100644 --- a/lib/ns/include/ns/client.h +++ b/lib/ns/include/ns/client.h @@ -145,11 +145,8 @@ struct ns_clientmgr { isc_mem_t *mctx; ns_server_t *sctx; - isc_taskmgr_t *taskmgr; - isc_loopmgr_t *loopmgr; isc_refcount_t references; uint32_t tid; - isc_task_t *task; isc_loop_t *loop; dns_aclenv_t *aclenv; @@ -320,9 +317,8 @@ ns_client_settimeout(ns_client_t *client, unsigned int seconds); */ isc_result_t -ns_clientmgr_create(ns_server_t *sctx, isc_taskmgr_t *taskmgr, - isc_loopmgr_t *loopmgr, dns_aclenv_t *aclenv, int tid, - ns_clientmgr_t **managerp); +ns_clientmgr_create(ns_server_t *sctx, isc_loopmgr_t *loopmgr, + dns_aclenv_t *aclenv, int tid, ns_clientmgr_t **managerp); /*%< * Create a client manager. */ diff --git a/lib/ns/include/ns/events.h b/lib/ns/include/ns/events.h deleted file mode 100644 index b65182729d3..00000000000 --- a/lib/ns/include/ns/events.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * SPDX-License-Identifier: MPL-2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -#pragma once - -#include - -/*! \file ns/events.h - * \brief - * Registry of NS event numbers. - */ - -#define NS_EVENT_CLIENTCONTROL (ISC_EVENTCLASS_NS + 0) -#define NS_EVENT_HOOKASYNCDONE (ISC_EVENTCLASS_NS + 1) -#define NS_EVENT_IFSCAN (ISC_EVENTCLASS_NS + 2) diff --git a/lib/ns/include/ns/hooks.h b/lib/ns/include/ns/hooks.h index b50327219e6..3d34a962e0d 100644 --- a/lib/ns/include/ns/hooks.h +++ b/lib/ns/include/ns/hooks.h @@ -17,7 +17,6 @@ #include -#include #include #include #include diff --git a/lib/ns/include/ns/interfacemgr.h b/lib/ns/include/ns/interfacemgr.h index 317b722405d..3da1c93d85c 100644 --- a/lib/ns/include/ns/interfacemgr.h +++ b/lib/ns/include/ns/interfacemgr.h @@ -100,10 +100,10 @@ struct ns_interface { isc_result_t ns_interfacemgr_create(isc_mem_t *mctx, ns_server_t *sctx, - isc_loopmgr_t *loopmgr, isc_taskmgr_t *taskmgr, - isc_nm_t *nm, dns_dispatchmgr_t *dispatchmgr, - isc_task_t *task, dns_geoip_databases_t *geoip, - bool scan, ns_interfacemgr_t **mgrp); + isc_loopmgr_t *loopmgr, isc_nm_t *nm, + dns_dispatchmgr_t *dispatchmgr, + dns_geoip_databases_t *geoip, bool scan, + ns_interfacemgr_t **mgrp); /*%< * Create a new interface manager. * diff --git a/lib/ns/include/ns/server.h b/lib/ns/include/ns/server.h index 2d8f19139f2..431470c2eb9 100644 --- a/lib/ns/include/ns/server.h +++ b/lib/ns/include/ns/server.h @@ -29,7 +29,6 @@ #include #include -#include #include #define NS_SERVER_LOGQUERIES 0x00000001U /*%< log queries */ diff --git a/lib/ns/interfacemgr.c b/lib/ns/interfacemgr.c index c159369a64b..bb516039607 100644 --- a/lib/ns/interfacemgr.c +++ b/lib/ns/interfacemgr.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include @@ -70,8 +69,6 @@ struct ns_interfacemgr { isc_mem_t *mctx; /*%< Memory context */ ns_server_t *sctx; /*%< Server context */ isc_loopmgr_t *loopmgr; /*%< Loop manager */ - isc_taskmgr_t *taskmgr; /*%< Task manager */ - isc_task_t *task; /*%< Task */ isc_nm_t *nm; /*%< Net manager */ uint32_t ncpus; /*%< Number of workers */ dns_dispatchmgr_t *dispatchmgr; @@ -272,15 +269,13 @@ route_connected(isc_nmhandle_t *handle, isc_result_t eresult, void *arg) { isc_result_t ns_interfacemgr_create(isc_mem_t *mctx, ns_server_t *sctx, - isc_loopmgr_t *loopmgr, isc_taskmgr_t *taskmgr, - isc_nm_t *nm, dns_dispatchmgr_t *dispatchmgr, - isc_task_t *task, dns_geoip_databases_t *geoip, - bool scan, ns_interfacemgr_t **mgrp) { + isc_loopmgr_t *loopmgr, isc_nm_t *nm, + dns_dispatchmgr_t *dispatchmgr, + dns_geoip_databases_t *geoip, bool scan, + ns_interfacemgr_t **mgrp) { isc_result_t result; ns_interfacemgr_t *mgr = NULL; - UNUSED(task); - REQUIRE(mctx != NULL); REQUIRE(mgrp != NULL); REQUIRE(*mgrp == NULL); @@ -288,7 +283,6 @@ ns_interfacemgr_create(isc_mem_t *mctx, ns_server_t *sctx, mgr = isc_mem_get(mctx, sizeof(*mgr)); *mgr = (ns_interfacemgr_t){ .loopmgr = loopmgr, - .taskmgr = taskmgr, .nm = nm, .dispatchmgr = dispatchmgr, .generation = 1, @@ -300,11 +294,6 @@ ns_interfacemgr_create(isc_mem_t *mctx, ns_server_t *sctx, isc_mutex_init(&mgr->lock); - result = isc_task_create(taskmgr, &mgr->task, 0); - if (result != ISC_R_SUCCESS) { - goto cleanup_lock; - } - atomic_init(&mgr->shuttingdown, false); ISC_LIST_INIT(mgr->interfaces); @@ -315,7 +304,7 @@ ns_interfacemgr_create(isc_mem_t *mctx, ns_server_t *sctx, */ result = ns_listenlist_create(mctx, &mgr->listenon4); if (result != ISC_R_SUCCESS) { - goto cleanup_task; + goto cleanup_lock; } ns_listenlist_attach(mgr->listenon4, &mgr->listenon6); @@ -336,8 +325,8 @@ ns_interfacemgr_create(isc_mem_t *mctx, ns_server_t *sctx, mgr->clientmgrs = isc_mem_get(mgr->mctx, mgr->ncpus * sizeof(mgr->clientmgrs[0])); for (size_t i = 0; i < mgr->ncpus; i++) { - result = ns_clientmgr_create(mgr->sctx, mgr->taskmgr, - mgr->loopmgr, mgr->aclenv, (int)i, + result = ns_clientmgr_create(mgr->sctx, mgr->loopmgr, + mgr->aclenv, (int)i, &mgr->clientmgrs[i]); RUNTIME_CHECK(result == ISC_R_SUCCESS); } @@ -361,8 +350,6 @@ ns_interfacemgr_create(isc_mem_t *mctx, ns_server_t *sctx, cleanup_listenon: ns_listenlist_detach(&mgr->listenon4); ns_listenlist_detach(&mgr->listenon6); -cleanup_task: - isc_task_detach(&mgr->task); cleanup_lock: isc_mutex_destroy(&mgr->lock); ns_server_detach(&mgr->sctx); @@ -390,7 +377,6 @@ ns_interfacemgr_destroy(ns_interfacemgr_t *mgr) { if (mgr->sctx != NULL) { ns_server_detach(&mgr->sctx); } - isc_task_detach(&mgr->task); mgr->magic = 0; isc_mem_putanddetach(&mgr->mctx, mgr, sizeof(*mgr)); } diff --git a/lib/ns/query.c b/lib/ns/query.c index 13c7a33534f..c86a97880e5 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include @@ -65,7 +64,6 @@ #include #include -#include #include #include #include diff --git a/tests/dns/rbt_test.c b/tests/dns/rbt_test.c index fc56d7dc6a9..24944e0601a 100644 --- a/tests/dns/rbt_test.c +++ b/tests/dns/rbt_test.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include diff --git a/tests/dns/resolver_test.c b/tests/dns/resolver_test.c index 99da02df55e..e5bdea7ce9c 100644 --- a/tests/dns/resolver_test.c +++ b/tests/dns/resolver_test.c @@ -23,7 +23,6 @@ #include #include -#include #include #include #include diff --git a/tests/dns/zonemgr_test.c b/tests/dns/zonemgr_test.c index 83f874659c9..b6fe475fabf 100644 --- a/tests/dns/zonemgr_test.c +++ b/tests/dns/zonemgr_test.c @@ -23,7 +23,6 @@ #include #include -#include #include #include @@ -36,7 +35,6 @@ static int setup_test(void **state) { setup_loopmgr(state); - setup_taskmgr(state); setup_netmgr(state); return (0); @@ -45,7 +43,6 @@ setup_test(void **state) { static int teardown_test(void **state) { teardown_netmgr(state); - teardown_taskmgr(state); teardown_loopmgr(state); return (0); @@ -54,12 +51,10 @@ teardown_test(void **state) { /* create zone manager */ ISC_LOOP_TEST_IMPL(zonemgr_create) { dns_zonemgr_t *myzonemgr = NULL; - isc_result_t result; UNUSED(arg); - result = dns_zonemgr_create(mctx, loopmgr, taskmgr, netmgr, &myzonemgr); - assert_int_equal(result, ISC_R_SUCCESS); + dns_zonemgr_create(mctx, loopmgr, netmgr, &myzonemgr); dns_zonemgr_shutdown(myzonemgr); dns_zonemgr_detach(&myzonemgr); @@ -76,8 +71,7 @@ ISC_LOOP_TEST_IMPL(zonemgr_managezone) { UNUSED(arg); - result = dns_zonemgr_create(mctx, loopmgr, taskmgr, netmgr, &myzonemgr); - assert_int_equal(result, ISC_R_SUCCESS); + dns_zonemgr_create(mctx, loopmgr, netmgr, &myzonemgr); result = dns_test_makezone("foo", &zone, NULL, false); assert_int_equal(result, ISC_R_SUCCESS); @@ -110,8 +104,7 @@ ISC_LOOP_TEST_IMPL(zonemgr_createzone) { UNUSED(arg); - result = dns_zonemgr_create(mctx, loopmgr, taskmgr, netmgr, &myzonemgr); - assert_int_equal(result, ISC_R_SUCCESS); + dns_zonemgr_create(mctx, loopmgr, netmgr, &myzonemgr); result = dns_zonemgr_createzone(myzonemgr, &zone); assert_int_equal(result, ISC_R_SUCCESS); @@ -142,8 +135,7 @@ ISC_LOOP_TEST_IMPL(zonemgr_unreachable) { TIME_NOW(&now); - result = dns_zonemgr_create(mctx, loopmgr, taskmgr, netmgr, &myzonemgr); - assert_int_equal(result, ISC_R_SUCCESS); + dns_zonemgr_create(mctx, loopmgr, netmgr, &myzonemgr); result = dns_test_makezone("foo", &zone, NULL, false); assert_int_equal(result, ISC_R_SUCCESS); diff --git a/tests/dns/zt_test.c b/tests/dns/zt_test.c index 00b8345dc35..70b7cbca247 100644 --- a/tests/dns/zt_test.c +++ b/tests/dns/zt_test.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -71,8 +70,7 @@ ISC_LOOP_TEST_IMPL(apply) { assert_int_equal(nzones, 1); /* These steps are necessary so the zone can be detached properly */ - result = dns_test_setupzonemgr(); - assert_int_equal(result, ISC_R_SUCCESS); + dns_test_setupzonemgr(); result = dns_test_managezone(zone); assert_int_equal(result, ISC_R_SUCCESS); dns_test_releasezone(zone); @@ -85,12 +83,11 @@ ISC_LOOP_TEST_IMPL(apply) { } static isc_result_t -load_done_last(dns_zt_t *zt, dns_zone_t *zone, isc_task_t *task) { +load_done_last(dns_zt_t *zt, dns_zone_t *zone) { isc_result_t result; UNUSED(zt); UNUSED(zone); - UNUSED(task); /* The zone should now be loaded; test it */ result = dns_zone_getdb(zone, &db); @@ -113,12 +110,11 @@ load_done_last(dns_zt_t *zt, dns_zone_t *zone, isc_task_t *task) { } static isc_result_t -load_done_new_only(dns_zt_t *zt, dns_zone_t *zone, isc_task_t *task) { +load_done_new_only(dns_zt_t *zt, dns_zone_t *zone) { isc_result_t result; UNUSED(zt); UNUSED(zone); - UNUSED(task); /* The zone should now be loaded; test it */ result = dns_zone_getdb(zone, &db); @@ -131,12 +127,11 @@ load_done_new_only(dns_zt_t *zt, dns_zone_t *zone, isc_task_t *task) { } static isc_result_t -load_done_first(dns_zt_t *zt, dns_zone_t *zone, isc_task_t *task) { +load_done_first(dns_zt_t *zt, dns_zone_t *zone) { atomic_bool *done = (atomic_bool *)zt; isc_result_t result; UNUSED(zone); - UNUSED(task); /* The zone should now be loaded; test it */ result = dns_zone_getdb(zone, &db); @@ -169,8 +164,7 @@ ISC_LOOP_TEST_IMPL(asyncload_zone) { result = dns_test_makezone("foo", &zone, NULL, true); assert_int_equal(result, ISC_R_SUCCESS); - result = dns_test_setupzonemgr(); - assert_int_equal(result, ISC_R_SUCCESS); + dns_test_setupzonemgr(); result = dns_test_managezone(zone); assert_int_equal(result, ISC_R_SUCCESS); @@ -257,8 +251,7 @@ ISC_LOOP_TEST_IMPL(asyncload_zt) { zt = view->zonetable; assert_non_null(zt); - result = dns_test_setupzonemgr(); - assert_int_equal(result, ISC_R_SUCCESS); + dns_test_setupzonemgr(); result = dns_test_managezone(zone1); assert_int_equal(result, ISC_R_SUCCESS); result = dns_test_managezone(zone2); diff --git a/tests/include/tests/dns.h b/tests/include/tests/dns.h index 583a299e140..4a3896e4e06 100644 --- a/tests/include/tests/dns.h +++ b/tests/include/tests/dns.h @@ -25,7 +25,6 @@ #include #include #include -#include #include #include @@ -73,7 +72,7 @@ isc_result_t dns_test_makezone(const char *name, dns_zone_t **zonep, dns_view_t *view, bool createview); -isc_result_t +void dns_test_setupzonemgr(void); isc_result_t diff --git a/tests/include/tests/isc.h b/tests/include/tests/isc.h index 241f32f4b2f..8d51f22bbbb 100644 --- a/tests/include/tests/isc.h +++ b/tests/include/tests/isc.h @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -34,7 +33,6 @@ extern isc_mem_t *mctx; extern isc_log_t *lctx; extern isc_loop_t *mainloop; extern isc_loopmgr_t *loopmgr; -extern isc_taskmgr_t *taskmgr; extern isc_nm_t *netmgr; extern int ncpus; extern unsigned int workers; @@ -49,11 +47,6 @@ setup_loopmgr(void **state); int teardown_loopmgr(void **state); -int -setup_taskmgr(void **state); -int -teardown_taskmgr(void **state); - int setup_netmgr(void **state); int diff --git a/tests/include/tests/ns.h b/tests/include/tests/ns.h index 8738a57fb68..90e2cf180ed 100644 --- a/tests/include/tests/ns.h +++ b/tests/include/tests/ns.h @@ -25,7 +25,6 @@ #include #include #include -#include #include #include diff --git a/tests/isc/Makefile.am b/tests/isc/Makefile.am index b0c63516360..c68c1b7da93 100644 --- a/tests/isc/Makefile.am +++ b/tests/isc/Makefile.am @@ -42,7 +42,6 @@ check_PROGRAMS = \ sockaddr_test \ stats_test \ symtab_test \ - task_test \ tcp_test \ tcpdns_test \ time_test \ @@ -101,12 +100,6 @@ random_test_LDADD = \ $(LDADD) \ -lm -task_test_CPPFLAGS = \ - $(AM_CPPFLAGS) - -task_test_LDADD = \ - $(LDADD) - tcp_test_CPPFLAGS = \ $(AM_CPPFLAGS) \ $(OPENSSL_CFLAGS) @@ -177,17 +170,6 @@ udp_test_SOURCES = \ netmgr_common.c \ uv_wrap.h -if HAVE_LIBXML2 -task_test_CPPFLAGS += $(LIBXML2_CFLAGS) -task_test_LDADD += $(LIBXML2_LIBS) -endif HAVE_LIBXML2 - -if HAVE_JSON_C -task_test_CPPFLAGS += $(JSON_C_CFLAGS) -task_test_LDADD += $(JSON_C_LIBS) -endif HAVE_JSON_C - - EXTRA_DIST = testdata include $(top_srcdir)/Makefile.tests diff --git a/tests/isc/ratelimiter_test.c b/tests/isc/ratelimiter_test.c index 848902d7b99..d260686726d 100644 --- a/tests/isc/ratelimiter_test.c +++ b/tests/isc/ratelimiter_test.c @@ -23,11 +23,9 @@ #define UNIT_TESTING #include -#include #include #include #include -#include #include #include "ratelimiter.c" @@ -279,10 +277,6 @@ setup_test(void **state) { if (r != 0) { return (r); } - r = setup_taskmgr(state); - if (r != 0) { - return (r); - } return (0); } @@ -291,10 +285,6 @@ static int teardown_test(void **state) { int r; - r = teardown_taskmgr(state); - if (r != 0) { - return (r); - } r = teardown_loopmgr(state); if (r != 0) { return (r); diff --git a/tests/isc/task_test.c b/tests/isc/task_test.c deleted file mode 100644 index 1f489f08fab..00000000000 --- a/tests/isc/task_test.c +++ /dev/null @@ -1,361 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * SPDX-License-Identifier: MPL-2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -#include -#include /* IWYU pragma: keep */ -#include -#include -#include -#include -#include -#include -#include - -#define UNIT_TESTING - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -static atomic_int_fast32_t counter; -static int active[10]; -static atomic_bool done = false; - -atomic_int_fast32_t set_a, set_b; - -static void -set(isc_task_t *task, isc_event_t *event) { - atomic_int_fast32_t *value = (atomic_int_fast32_t *)event->ev_arg; - - UNUSED(task); - - isc_event_free(&event); - atomic_store(value, atomic_fetch_add(&counter, 1)); - - if ((atomic_load(&set_a) != 0 && atomic_load(&set_b) != 0)) { - isc_loopmgr_shutdown(loopmgr); - } -} - -#include - -ISC_LOOP_TEST_IMPL(create_task) { - isc_result_t result; - isc_task_t *task = NULL; - - result = isc_task_create(taskmgr, &task, 0); - assert_int_equal(result, ISC_R_SUCCESS); - - isc_task_detach(&task); - assert_null(task); - - isc_loopmgr_shutdown(loopmgr); -} - -ISC_LOOP_SETUP_IMPL(all_events) { - atomic_init(&set_a, 0); - atomic_init(&set_b, 0); -} - -ISC_LOOP_TEARDOWN_IMPL(all_events) { - assert_int_not_equal(atomic_load(&set_a), 0); - assert_int_not_equal(atomic_load(&set_b), 0); -} - -ISC_LOOP_TEST_SETUP_TEARDOWN_IMPL(all_events) { - isc_result_t result; - isc_task_t *task = NULL; - isc_event_t *event = NULL; - - atomic_init(&counter, 1); - - result = isc_task_create(taskmgr, &task, 0); - assert_int_equal(result, ISC_R_SUCCESS); - - /* First event */ - event = isc_event_allocate(mctx, task, ISC_TASKEVENT_TEST, set, &set_a, - sizeof(isc_event_t)); - assert_non_null(event); - - assert_int_equal(atomic_load(&set_a), 0); - isc_task_send(task, &event); - - event = isc_event_allocate(mctx, task, ISC_TASKEVENT_TEST, set, &set_b, - sizeof(isc_event_t)); - assert_non_null(event); - - assert_int_equal(atomic_load(&set_b), 0); - isc_task_send(task, &event); - - isc_task_detach(&task); - assert_null(task); -} - -/* - * Basic task functions: - */ -static void -basic_cb(isc_task_t *task, isc_event_t *event) { - int i, j; - - UNUSED(task); - - j = 0; - for (i = 0; i < 1000000; i++) { - j += 100; - } - - UNUSED(j); - isc_event_free(&event); -} - -static void -basic_tick(void *arg __attribute__((__unused__))) { - /* no-op */ -} - -static char one[] = "1"; -static char two[] = "2"; -static char three[] = "3"; -static char four[] = "4"; -static char tick[] = "tick"; -static char tock[] = "tock"; - -isc_task_t *task1 = NULL; -isc_task_t *task2 = NULL; -isc_task_t *task3 = NULL; -isc_task_t *task4 = NULL; -isc_timer_t *ti1 = NULL; -isc_timer_t *ti2 = NULL; - -static void -basic_work(void *arg __attribute__((__unused__))) { - char *testarray[] = { one, one, one, one, one, one, one, one, - one, two, three, four, two, three, four, NULL }; - sleep(2); - - for (size_t i = 0; testarray[i] != NULL; i++) { - /* - * Note: (void *)1 is used as a sender here, since some - * compilers don't like casting a function pointer to a - * (void *). - * - * In a real use, it is more likely the sender would be a - * structure (socket, timer, task, etc) but this is just a - * test program. - */ - isc_event_t *event = isc_event_allocate(mctx, &task1, 1, - basic_cb, testarray[i], - sizeof(*event)); - assert_non_null(event); - isc_task_send(task1, &event); - } -} - -static void -basic_after_work(void *arg) { - UNUSED(arg); - - sleep(5); - - isc_task_detach(&task1); - isc_task_detach(&task2); - isc_task_detach(&task3); - isc_task_detach(&task4); - - sleep(5); - - isc_timer_destroy(&ti1); - isc_timer_destroy(&ti2); - - isc_loopmgr_shutdown(loopmgr); -} - -ISC_LOOP_TEST_IMPL(basic) { - isc_result_t result; - isc_interval_t interval; - - UNUSED(arg); - - result = isc_task_create(taskmgr, &task1, 0); - assert_int_equal(result, ISC_R_SUCCESS); - result = isc_task_create(taskmgr, &task2, 0); - assert_int_equal(result, ISC_R_SUCCESS); - result = isc_task_create(taskmgr, &task3, 0); - assert_int_equal(result, ISC_R_SUCCESS); - result = isc_task_create(taskmgr, &task4, 0); - assert_int_equal(result, ISC_R_SUCCESS); - - isc_interval_set(&interval, 1, 0); - isc_timer_create(mainloop, basic_tick, tick, &ti1); - isc_timer_start(ti1, isc_timertype_ticker, &interval); - - isc_interval_set(&interval, 1, 0); - isc_timer_create(mainloop, basic_tick, tock, &ti2); - isc_timer_start(ti2, isc_timertype_ticker, &interval); - - isc_work_enqueue(mainloop, basic_work, basic_after_work, NULL); -} - -/* - * Exclusive mode test: - * When one task enters exclusive mode, all other active - * tasks complete first. - */ - -static void -exclusive_cb(isc_task_t *task, isc_event_t *event) { - int taskno = *(int *)(event->ev_arg); - - /* task chosen from the middle of the range */ - if (taskno == 6) { - int i; - - isc_task_beginexclusive(task); - - for (i = 0; i < 10; i++) { - assert_int_equal(active[i], 0); - } - - isc_task_endexclusive(task); - atomic_store(&done, true); - } else { - active[taskno]++; - isc_thread_yield(); - active[taskno]--; - } - - if (atomic_load(&done)) { - isc_mem_put(event->ev_destroy_arg, event->ev_arg, sizeof(int)); - isc_event_free(&event); - atomic_fetch_sub(&counter, 1); - isc_loopmgr_shutdown(loopmgr); - } else { - isc_task_send(task, &event); - } -} - -isc_task_t *tasks[10] = { NULL }; - -ISC_LOOP_SETUP_IMPL(task_exclusive) { - isc_result_t result; - - atomic_init(&counter, 0); - atomic_init(&done, false); - - for (size_t i = 0; i < 10; i++) { - uint32_t tid = i % isc_loopmgr_nloops(loopmgr); - - if (i == 6) { - /* task chosen from the middle of the range */ - tid = 0; - result = isc_task_create(taskmgr, &tasks[i], tid); - assert_int_equal(result, ISC_R_SUCCESS); - - isc_taskmgr_setexcltask(taskmgr, tasks[i]); - } else { - result = isc_task_create(taskmgr, &tasks[i], tid); - assert_int_equal(result, ISC_R_SUCCESS); - } - } -} - -ISC_LOOP_TEST_SETUP_IMPL(task_exclusive) { - UNUSED(arg); - - for (size_t i = 0; i < 10; i++) { - isc_event_t *event = NULL; - int *v; - - v = isc_mem_get(mctx, sizeof *v); - assert_non_null(v); - - *v = i; - - event = isc_event_allocate(mctx, NULL, 1, exclusive_cb, v, - sizeof(*event)); - assert_non_null(event); - - isc_task_send(tasks[i], &event); - atomic_fetch_add(&counter, 1); - isc_task_detach(&tasks[i]); - } -} - -static void -maxtask_cb(isc_task_t *task, isc_event_t *event) { - isc_result_t result; - uintptr_t ntasks = (uintptr_t)event->ev_arg; - - if (event->ev_arg != NULL) { - isc_task_t *newtask = NULL; - - event->ev_arg = (void *)(ntasks - 1); - - /* - * Create a new task and forward the message. - */ - result = isc_task_create(taskmgr, &newtask, 0); - assert_int_equal(result, ISC_R_SUCCESS); - - isc_task_send(newtask, &event); - } else { - isc_event_free(&event); - isc_loopmgr_shutdown(loopmgr); - } - - if (task != NULL) { - isc_task_detach(&task); - } -} - -ISC_LOOP_TEST_IMPL(manytasks) { - isc_event_t *event = NULL; - uintptr_t ntasks = 10000; - - UNUSED(arg); - - event = isc_event_allocate(mctx, (void *)1, 1, maxtask_cb, - (void *)ntasks, sizeof(*event)); - assert_non_null(event); - - maxtask_cb(NULL, event); -} - -ISC_TEST_LIST_START - -ISC_TEST_ENTRY_CUSTOM(manytasks, setup_managers, teardown_managers) -ISC_TEST_ENTRY_CUSTOM(all_events, setup_managers, teardown_managers) -ISC_TEST_ENTRY_CUSTOM(basic, setup_managers, teardown_managers) -ISC_TEST_ENTRY_CUSTOM(create_task, setup_managers, teardown_managers) -ISC_TEST_ENTRY_CUSTOM(task_exclusive, setup_managers, teardown_managers) - -ISC_TEST_LIST_END - -ISC_TEST_MAIN diff --git a/tests/libtest/dns.c b/tests/libtest/dns.c index e14cfdc3db4..db99494493e 100644 --- a/tests/libtest/dns.c +++ b/tests/libtest/dns.c @@ -155,13 +155,11 @@ detach_zone: return (result); } -isc_result_t +void dns_test_setupzonemgr(void) { - isc_result_t result; REQUIRE(zonemgr == NULL); - result = dns_zonemgr_create(mctx, loopmgr, taskmgr, netmgr, &zonemgr); - return (result); + dns_zonemgr_create(mctx, loopmgr, netmgr, &zonemgr); } isc_result_t diff --git a/tests/libtest/isc.c b/tests/libtest/isc.c index 1604d66ee47..d9da8e2e610 100644 --- a/tests/libtest/isc.c +++ b/tests/libtest/isc.c @@ -27,7 +27,6 @@ #include #include #include -#include #include #include @@ -37,7 +36,6 @@ isc_mem_t *mctx = NULL; isc_log_t *lctx = NULL; isc_loop_t *mainloop = NULL; isc_loopmgr_t *loopmgr = NULL; -isc_taskmgr_t *taskmgr = NULL; isc_nm_t *netmgr = NULL; unsigned int workers = -1; @@ -91,7 +89,6 @@ setup_loopmgr(void **state __attribute__((__unused__))) { int teardown_loopmgr(void **state __attribute__((__unused__))) { - REQUIRE(taskmgr == NULL); REQUIRE(netmgr == NULL); mainloop = NULL; @@ -100,22 +97,6 @@ teardown_loopmgr(void **state __attribute__((__unused__))) { return (0); } -int -setup_taskmgr(void **state __attribute__((__unused__))) { - REQUIRE(loopmgr != NULL); - - isc_taskmgr_create(mctx, loopmgr, &taskmgr); - - return (0); -} - -int -teardown_taskmgr(void **state __attribute__((__unused__))) { - isc_taskmgr_destroy(&taskmgr); - - return (0); -} - int setup_netmgr(void **state __attribute__((__unused__))) { REQUIRE(loopmgr != NULL); @@ -139,7 +120,6 @@ teardown_netmgr(void **state __attribute__((__unused__))) { int setup_managers(void **state) { setup_loopmgr(state); - setup_taskmgr(state); setup_netmgr(state); return (0); @@ -148,7 +128,6 @@ setup_managers(void **state) { int teardown_managers(void **state) { teardown_netmgr(state); - teardown_taskmgr(state); teardown_loopmgr(state); return (0); diff --git a/tests/libtest/ns.c b/tests/libtest/ns.c index 2128b50a2b3..49c60256e20 100644 --- a/tests/libtest/ns.c +++ b/tests/libtest/ns.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include @@ -52,7 +51,6 @@ #include -isc_task_t *maintask = NULL; dns_dispatchmgr_t *dispatchmgr = NULL; ns_interfacemgr_t *interfacemgr = NULL; ns_server_t *sctx = NULL; @@ -92,8 +90,8 @@ setup_server(void **state) { goto cleanup; } - result = ns_interfacemgr_create(mctx, sctx, loopmgr, taskmgr, netmgr, - dispatchmgr, maintask, NULL, false, + result = ns_interfacemgr_create(mctx, sctx, loopmgr, netmgr, + dispatchmgr, NULL, false, &interfacemgr); if (result != ISC_R_SUCCESS) { goto cleanup; @@ -159,10 +157,7 @@ ns_test_serve_zone(const char *zonename, const char *filename, /* * Start zone manager. */ - result = dns_test_setupzonemgr(); - if (result != ISC_R_SUCCESS) { - goto free_zone; - } + dns_test_setupzonemgr(); /* * Add the zone to the zone manager. @@ -201,7 +196,6 @@ release_zone: dns_test_releasezone(served_zone); close_zonemgr: dns_test_closezonemgr(); -free_zone: dns_zone_detach(&served_zone); return (result); diff --git a/tests/ns/notify_test.c b/tests/ns/notify_test.c index ae867c9e281..615cb57a25e 100644 --- a/tests/ns/notify_test.c +++ b/tests/ns/notify_test.c @@ -25,8 +25,6 @@ #define UNIT_TESTING #include -#include -#include #include #include diff --git a/tests/ns/query_test.c b/tests/ns/query_test.c index e71b1e7186a..d0466cb083d 100644 --- a/tests/ns/query_test.c +++ b/tests/ns/query_test.c @@ -32,7 +32,6 @@ #include #include -#include #include #include #include