#include <isc/hex.h>
#include <isc/lib.h>
#include <isc/log.h>
+#include <isc/managers.h>
#include <isc/md.h>
#include <isc/mem.h>
#include <isc/netmgr.h>
isc_mem_create(&mctx);
CHECK(isc_appctx_create(mctx, &actx));
- netmgr = isc_nm_start(mctx, 1);
- CHECK(isc_taskmgr_create(mctx, 0, netmgr, &taskmgr));
- CHECK(isc_socketmgr_create(mctx, &socketmgr));
- CHECK(isc_timermgr_create(mctx, &timermgr));
+ isc_managers_create(mctx, 1, 0, 0, &netmgr, &taskmgr, &timermgr,
+ &socketmgr);
parse_args(argc, argv);
if (client != NULL) {
dns_client_destroy(&client);
}
- if (taskmgr != NULL) {
- isc_taskmgr_destroy(&taskmgr);
- }
- if (netmgr != NULL) {
- isc_nm_destroy(&netmgr);
- }
- if (timermgr != NULL) {
- isc_timermgr_destroy(&timermgr);
- }
- if (socketmgr != NULL) {
- isc_socketmgr_destroy(&socketmgr);
- }
+ isc_managers_destroy(&netmgr, &taskmgr, &timermgr, &socketmgr);
if (actx != NULL) {
isc_appctx_destroy(&actx);
}
#include <isc/hex.h>
#include <isc/lang.h>
#include <isc/log.h>
+#include <isc/managers.h>
#include <isc/netaddr.h>
#include <isc/netdb.h>
#include <isc/nonce.h>
unsigned int extrabytes;
isc_mem_t *mctx = NULL;
isc_log_t *lctx = NULL;
+isc_nm_t *netmgr = NULL;
isc_taskmgr_t *taskmgr = NULL;
isc_task_t *global_task = NULL;
-isc_nm_t *netmgr = NULL;
isc_sockaddr_t localaddr;
isc_refcount_t sendcount = ATOMIC_VAR_INIT(0);
isc_refcount_t recvcount = ATOMIC_VAR_INIT(0);
isc_log_setdebuglevel(lctx, 0);
- netmgr = isc_nm_start(mctx, 1);
-
- result = isc_taskmgr_create(mctx, 0, netmgr, &taskmgr);
- check_result(result, "isc_taskmgr_create");
+ isc_managers_create(mctx, 1, 0, 0, &netmgr, &taskmgr, NULL, NULL);
result = isc_task_create(taskmgr, 0, &global_task);
check_result(result, "isc_task_create");
debug("freeing task");
isc_task_detach(&global_task);
}
- /*
- * The taskmgr_destroy() and isc_nm_destroy() calls block until
- * all events are cleared.
- */
- if (taskmgr != NULL) {
- debug("freeing taskmgr");
- isc_taskmgr_destroy(&taskmgr);
- }
-
- debug("closing down netmgr");
- isc_nm_closedown(netmgr);
- debug("destroy netmgr");
- isc_nm_destroy(&netmgr);
+ isc_managers_destroy(&netmgr, &taskmgr, NULL, NULL);
LOCK_LOOKUP;
isc_refcount_destroy(&recvcount);
#include <isc/file.h>
#include <isc/hash.h>
#include <isc/hex.h>
+#include <isc/managers.h>
#include <isc/md.h>
#include <isc/mem.h>
#include <isc/mutex.h>
print_time(outfp);
print_version(outfp);
- netmgr = isc_nm_start(mctx, ntasks);
-
- result = isc_taskmgr_create(mctx, 0, netmgr, &taskmgr);
- if (result != ISC_R_SUCCESS) {
- fatal("failed to create task manager: %s",
- isc_result_totext(result));
- }
+ isc_managers_create(mctx, ntasks, 0, 0, &netmgr, &taskmgr, NULL, NULL);
master = NULL;
result = isc_task_create(taskmgr, 0, &master);
for (i = 0; i < (int)ntasks; i++) {
isc_task_detach(&tasks[i]);
}
- isc_taskmgr_destroy(&taskmgr);
- isc_nm_destroy(&netmgr);
+ isc_managers_destroy(&netmgr, &taskmgr, NULL, NULL);
isc_mem_put(mctx, tasks, ntasks * sizeof(isc_task_t *));
postsign();
TIME_NOW(&sign_finish);
}
#endif
- CHECK(isc_nm_listentcp(named_g_nm, (isc_nmiface_t *)&listener->address,
- control_newconn, listener,
- sizeof(controlconnection_t), 5, NULL,
- &listener->sock));
+ CHECK(isc_nm_listentcp(
+ named_g_netmgr, (isc_nmiface_t *)&listener->address,
+ control_newconn, listener, sizeof(controlconnection_t), 5, NULL,
+ &listener->sock));
#if 0
/* XXX: no unix socket support yet */
if (type == isc_socktype_unix) {
*/
EXTERN isc_timermgr_t *named_g_timermgr INIT(NULL);
EXTERN isc_socketmgr_t *named_g_socketmgr INIT(NULL);
-EXTERN isc_nm_t *named_g_nm INIT(NULL);
+EXTERN isc_nm_t *named_g_netmgr INIT(NULL);
EXTERN cfg_parser_t *named_g_parser INIT(NULL);
EXTERN cfg_parser_t *named_g_addparser INIT(NULL);
EXTERN const char *named_g_version INIT(PACKAGE_VERSION);
#include <isc/hash.h>
#include <isc/hp.h>
#include <isc/httpd.h>
+#include <isc/managers.h>
#include <isc/netmgr.h>
#include <isc/os.h>
#include <isc/platform.h>
"using %u UDP listener%s per interface", named_g_udpdisp,
named_g_udpdisp == 1 ? "" : "s");
- /*
- * We have ncpus network threads, ncpus worker threads, ncpus
- * old network threads - make it 4x just to be safe. The memory
- * impact is negligible.
- */
- isc_hp_init(4 * named_g_cpus);
- named_g_nm = isc_nm_start(named_g_mctx, named_g_cpus);
- if (named_g_nm == NULL) {
- UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_nm_start() failed");
- return (ISC_R_UNEXPECTED);
- }
-
- result = isc_taskmgr_create(named_g_mctx, 0, named_g_nm,
- &named_g_taskmgr);
+ result = isc_managers_create(named_g_mctx, named_g_cpus,
+ 0 /* quantum */, maxsocks, &named_g_netmgr,
+ &named_g_taskmgr, &named_g_timermgr,
+ &named_g_socketmgr);
if (result != ISC_R_SUCCESS) {
- UNEXPECTED_ERROR(__FILE__, __LINE__,
- "isc_taskmgr_create() failed: %s",
- isc_result_totext(result));
- return (ISC_R_UNEXPECTED);
- }
-
- result = isc_timermgr_create(named_g_mctx, &named_g_timermgr);
- if (result != ISC_R_SUCCESS) {
- UNEXPECTED_ERROR(__FILE__, __LINE__,
- "isc_timermgr_create() failed: %s",
- isc_result_totext(result));
- return (ISC_R_UNEXPECTED);
+ return (result);
}
- result = isc_socketmgr_create2(named_g_mctx, &named_g_socketmgr,
- maxsocks, named_g_cpus);
- if (result != ISC_R_SUCCESS) {
- UNEXPECTED_ERROR(__FILE__, __LINE__,
- "isc_socketmgr_create() failed: %s",
- isc_result_totext(result));
- return (ISC_R_UNEXPECTED);
- }
isc_socketmgr_maxudp(named_g_socketmgr, maxudp);
- isc_nm_maxudp(named_g_nm, maxudp);
+ isc_nm_maxudp(named_g_netmgr, maxudp);
+
result = isc_socketmgr_getmaxsockets(named_g_socketmgr, &socks);
if (result == ISC_R_SUCCESS) {
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
static void
destroy_managers(void) {
- /*
- * isc_nm_closedown() closes all active connections, freeing
- * attached clients and other resources and preventing new
- * connections from being established, but it not does not
- * stop all processing or destroy the netmgr yet.
- */
- isc_nm_closedown(named_g_nm);
-
- /*
- * isc_taskmgr_destroy() will block until all tasks have exited.
- */
- isc_taskmgr_destroy(&named_g_taskmgr);
- isc_nm_destroy(&named_g_nm);
- isc_timermgr_destroy(&named_g_timermgr);
- isc_socketmgr_destroy(&named_g_socketmgr);
+ isc_managers_destroy(&named_g_netmgr, &named_g_taskmgr,
+ &named_g_timermgr, &named_g_socketmgr);
}
static void
advertised = MAX_ADVERTISED_TIMEOUT;
}
- isc_nm_settimeouts(named_g_nm, initial, idle, keepalive, advertised);
+ isc_nm_settimeouts(named_g_netmgr, initial, idle, keepalive,
+ advertised);
/*
* Configure sets of UDP query source ports.
CHECKFATAL(ns_interfacemgr_create(
named_g_mctx, server->sctx, named_g_taskmgr,
- named_g_timermgr, named_g_socketmgr, named_g_nm,
+ named_g_timermgr, named_g_socketmgr, named_g_netmgr,
named_g_dispatchmgr, server->task, named_g_udpdisp,
geoip, named_g_cpus, &server->interfacemgr),
"creating interface manager");
CHECKFATAL(dns_zonemgr_create(named_g_mctx, named_g_taskmgr,
named_g_timermgr, named_g_socketmgr,
- named_g_nm, &server->zonemgr),
+ named_g_netmgr, &server->zonemgr),
"dns_zonemgr_create");
CHECKFATAL(dns_zonemgr_setsize(server->zonemgr, 1000), "dns_zonemgr_"
"setsize");
isc_sockstatscounter_max),
"isc_stats_create");
isc_socketmgr_setstats(named_g_socketmgr, server->sockstats);
- isc_nm_setstats(named_g_nm, server->sockstats);
+ isc_nm_setstats(named_g_netmgr, server->sockstats);
CHECKFATAL(isc_stats_create(named_g_mctx, &server->zonestats,
dns_zonestatscounter_max),
return (ISC_R_UNEXPECTEDEND);
}
- isc_nm_gettimeouts(named_g_nm, &initial, &idle, &keepalive,
+ isc_nm_gettimeouts(named_g_netmgr, &initial, &idle, &keepalive,
&advertised);
/* Look for optional arguments. */
result = isc_task_beginexclusive(named_g_server->task);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
- isc_nm_settimeouts(named_g_nm, initial, idle, keepalive,
+ isc_nm_settimeouts(named_g_netmgr, initial, idle, keepalive,
advertised);
isc_task_endexclusive(named_g_server->task);
CHECK(ISC_R_FAMILYNOSUPPORT);
}
- CHECK(isc_httpdmgr_create(named_g_nm, server->mctx, addr, client_ok,
+ CHECK(isc_httpdmgr_create(named_g_netmgr, server->mctx, addr, client_ok,
destroy_listener, listener,
&listener->httpdmgr));
#include <isc/hash.h>
#include <isc/lex.h>
#include <isc/log.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/nonce.h>
#include <isc/parseint.h>
result = dns_dispatchmgr_create(gmctx, &dispatchmgr);
check_result(result, "dns_dispatchmgr_create");
- result = isc_socketmgr_create(gmctx, &socketmgr);
- check_result(result, "dns_socketmgr_create");
-
- result = isc_timermgr_create(gmctx, &timermgr);
- check_result(result, "dns_timermgr_create");
-
- netmgr = isc_nm_start(gmctx, 1);
-
- result = isc_taskmgr_create(gmctx, 0, netmgr, &taskmgr);
- check_result(result, "isc_taskmgr_create");
+ isc_managers_create(gmctx, 1, 0, 0, &netmgr, &taskmgr, &timermgr,
+ &socketmgr);
result = isc_task_create(taskmgr, 0, &global_task);
check_result(result, "isc_task_create");
dst_key_free(&sig0key);
}
- ddebug("Shutting down task manager");
- isc_taskmgr_destroy(&taskmgr);
-
- ddebug("Shutting down network manager");
- isc_nm_destroy(&netmgr);
+ ddebug("Shutting down managers");
+ isc_managers_destroy(&netmgr, &taskmgr, &timermgr, &socketmgr);
ddebug("Destroying event");
isc_event_free(&global_event);
- ddebug("Shutting down socket manager");
- isc_socketmgr_destroy(&socketmgr);
-
- ddebug("Shutting down timer manager");
- isc_timermgr_destroy(&timermgr);
-
#ifdef HAVE_GSSAPI
/*
* Cleanup GSSAPI resources after taskmgr has been destroyed.
#include <isc/commandline.h>
#include <isc/file.h>
#include <isc/log.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/net.h>
#include <isc/netmgr.h>
const char *progname = NULL;
bool verbose;
+static isc_nm_t *netmgr = NULL;
static isc_taskmgr_t *taskmgr = NULL;
static isc_task_t *rndc_task = NULL;
static int nserveraddrs;
static int currentaddr = 0;
static unsigned int remoteport = 0;
-static isc_nm_t *netmgr = NULL;
static isc_buffer_t *databuf = NULL;
static isccc_ccmsg_t rndc_ccmsg;
static uint32_t algorithm;
serial = isc_random32();
isc_mem_create(&rndc_mctx);
- netmgr = isc_nm_start(rndc_mctx, 1);
- DO("create task manager",
- isc_taskmgr_create(rndc_mctx, 0, netmgr, &taskmgr));
+ isc_managers_create(rndc_mctx, 1, 0, 0, &netmgr, &taskmgr, NULL, NULL);
DO("create task", isc_task_create(taskmgr, 0, &rndc_task));
isc_log_create(rndc_mctx, &log, &logconfig);
isc_log_setcontext(log);
}
isc_task_detach(&rndc_task);
- isc_taskmgr_destroy(&taskmgr);
-
- isc_nm_closedown(netmgr);
+ isc_managers_destroy(&netmgr, &taskmgr, NULL, NULL);
/*
* Note: when TCP connections are shut down, there will be a final
*/
isccc_ccmsg_invalidate(&rndc_ccmsg);
- isc_nm_destroy(&netmgr);
-
isc_log_destroy(&log);
isc_log_setcontext(NULL);
#include <isc/commandline.h>
#include <isc/hash.h>
#include <isc/log.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/net.h>
#include <isc/parseint.h>
isc_logconfig_t *lcfg;
isc_nm_t *netmgr = NULL;
isc_taskmgr_t *taskmgr = NULL;
- isc_task_t *task;
- isc_timermgr_t *timermgr;
- isc_socketmgr_t *socketmgr;
- dns_dispatchmgr_t *dispatchmgr;
+ isc_task_t *task = NULL;
+ isc_timermgr_t *timermgr = NULL;
+ isc_socketmgr_t *socketmgr = NULL;
+ dns_dispatchmgr_t *dispatchmgr = NULL;
unsigned int attrs, attrmask;
dns_dispatch_t *dispatchv4;
dns_view_t *view;
RUNCHECK(dst_lib_init(mctx, NULL));
- netmgr = isc_nm_start(mctx, 1);
+ isc_managers_create(mctx, 1, 0, 0, &netmgr, &taskmgr, &timermgr,
+ &socketmgr);
- RUNCHECK(isc_taskmgr_create(mctx, 0, netmgr, &taskmgr));
- task = NULL;
RUNCHECK(isc_task_create(taskmgr, 0, &task));
- timermgr = NULL;
-
- RUNCHECK(isc_timermgr_create(mctx, &timermgr));
- socketmgr = NULL;
- RUNCHECK(isc_socketmgr_create(mctx, &socketmgr));
- dispatchmgr = NULL;
RUNCHECK(dns_dispatchmgr_create(mctx, &dispatchmgr));
attrs = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_MAKEQUERY |
dns_dispatch_detach(&dispatchv4);
dns_dispatchmgr_destroy(&dispatchmgr);
- isc_socketmgr_destroy(&socketmgr);
- isc_timermgr_destroy(&timermgr);
-
isc_task_shutdown(task);
isc_task_detach(&task);
- isc_taskmgr_destroy(&taskmgr);
- isc_nm_destroy(&netmgr);
+
+ isc_managers_destroy(&netmgr, &taskmgr, &timermgr, &socketmgr);
dst_lib_destroy();
#include <isc/buffer.h>
#include <isc/commandline.h>
#include <isc/lib.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/print.h>
#include <isc/sockaddr.h>
static void
ctxs_destroy(void) {
- if (ctxs_netmgr != NULL) {
- isc_nm_closedown(ctxs_netmgr);
- }
-
- if (ctxs_taskmgr != NULL) {
- isc_taskmgr_destroy(&ctxs_taskmgr);
- }
-
- if (ctxs_netmgr != NULL) {
- isc_nm_destroy(&ctxs_netmgr);
- }
-
- if (ctxs_timermgr != NULL) {
- isc_timermgr_destroy(&ctxs_timermgr);
- }
-
- if (ctxs_socketmgr != NULL) {
- isc_socketmgr_destroy(&ctxs_socketmgr);
- }
+ isc_managers_destroy(&ctxs_netmgr, &ctxs_taskmgr, &ctxs_timermgr,
+ &ctxs_socketmgr);
if (ctxs_actx != NULL) {
isc_appctx_destroy(&ctxs_actx);
goto fail;
}
- ctxs_netmgr = isc_nm_start(ctxs_mctx, 1);
-
- result = isc_taskmgr_create(ctxs_mctx, 0, ctxs_netmgr, &ctxs_taskmgr);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
-
- result = isc_socketmgr_create(ctxs_mctx, &ctxs_socketmgr);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
-
- result = isc_timermgr_create(ctxs_mctx, &ctxs_timermgr);
- if (result != ISC_R_SUCCESS) {
- goto fail;
- }
+ isc_managers_create(ctxs_mctx, 1, 0, 0, &ctxs_netmgr, &ctxs_taskmgr,
+ &ctxs_timermgr, &ctxs_socketmgr);
return (ISC_R_SUCCESS);
#include <isc/base64.h>
#include <isc/hash.h>
#include <isc/log.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/nonce.h>
#include <isc/print.h>
int
main(int argc, char *argv[]) {
- char *ourkeyname;
+ char *ourkeyname = NULL;
isc_nm_t *netmgr = NULL;
isc_taskmgr_t *taskmgr = NULL;
- isc_timermgr_t *timermgr;
- isc_socketmgr_t *socketmgr;
- isc_socket_t *sock;
+ isc_timermgr_t *timermgr = NULL;
+ isc_socketmgr_t *socketmgr = NULL;
+ isc_socket_t *sock = NULL;
unsigned int attrs, attrmask;
isc_sockaddr_t bind_any;
- dns_dispatchmgr_t *dispatchmgr;
- dns_dispatch_t *dispatchv4;
- dns_view_t *view;
- dns_tkeyctx_t *tctx;
- isc_log_t *log;
- isc_logconfig_t *logconfig;
- isc_task_t *task;
+ dns_dispatchmgr_t *dispatchmgr = NULL;
+ dns_dispatch_t *dispatchv4 = NULL;
+ dns_view_t *view = NULL;
+ dns_tkeyctx_t *tctx = NULL;
+ isc_log_t *log = NULL;
+ isc_logconfig_t *logconfig = NULL;
+ isc_task_t *task = NULL;
isc_result_t result;
int type;
RUNCHECK(dst_lib_init(mctx, NULL));
- netmgr = isc_nm_start(mctx, 1);
+ isc_managers_create(mctx, 1, 0, 0, &netmgr, &taskmgr, &timermgr,
+ &socketmgr);
- RUNCHECK(isc_taskmgr_create(mctx, 0, netmgr, &taskmgr));
- task = NULL;
RUNCHECK(isc_task_create(taskmgr, 0, &task));
- timermgr = NULL;
- RUNCHECK(isc_timermgr_create(mctx, &timermgr));
- socketmgr = NULL;
- RUNCHECK(isc_socketmgr_create(mctx, &socketmgr));
- dispatchmgr = NULL;
RUNCHECK(dns_dispatchmgr_create(mctx, &dispatchmgr));
+
isc_sockaddr_any(&bind_any);
attrs = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_MAKEQUERY |
DNS_DISPATCHATTR_IPV4;
dns_dispatchmgr_destroy(&dispatchmgr);
isc_task_shutdown(task);
isc_task_detach(&task);
- isc_taskmgr_destroy(&taskmgr);
- isc_nm_destroy(&netmgr);
isc_socket_detach(&sock);
- isc_socketmgr_destroy(&socketmgr);
- isc_timermgr_destroy(&timermgr);
+ isc_managers_destroy(&netmgr, &taskmgr, &timermgr, &socketmgr);
dst_key_free(&ourkey);
dns_tsigkey_detach(&initialkey);
#include <isc/base64.h>
#include <isc/hash.h>
#include <isc/log.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/netmgr.h>
#include <isc/print.h>
int
main(int argc, char **argv) {
- char *keyname;
- isc_nm_t *netmgr;
+ char *keyname = NULL;
+ isc_nm_t *netmgr = NULL;
isc_taskmgr_t *taskmgr = NULL;
- isc_timermgr_t *timermgr;
- isc_socketmgr_t *socketmgr;
- isc_socket_t *sock;
+ isc_timermgr_t *timermgr = NULL;
+ isc_socketmgr_t *socketmgr = NULL;
+ isc_socket_t *sock = NULL;
unsigned int attrs, attrmask;
isc_sockaddr_t bind_any;
- dns_dispatchmgr_t *dispatchmgr;
- dns_dispatch_t *dispatchv4;
- dns_view_t *view;
- dns_tkeyctx_t *tctx;
- dst_key_t *dstkey;
- isc_log_t *log;
- isc_logconfig_t *logconfig;
- isc_task_t *task;
+ dns_dispatchmgr_t *dispatchmgr = NULL;
+ dns_dispatch_t *dispatchv4 = NULL;
+ dns_view_t *view = NULL;
+ dns_tkeyctx_t *tctx = NULL;
+ dst_key_t *dstkey = NULL;
+ isc_log_t *log = NULL;
+ isc_logconfig_t *logconfig = NULL;
+ isc_task_t *task = NULL;
isc_result_t result;
int type;
RUNCHECK(dst_lib_init(mctx, NULL));
- netmgr = isc_nm_start(mctx, 1);
+ isc_managers_create(mctx, 1, 0, 0, &netmgr, &taskmgr, &timermgr,
+ &socketmgr);
- RUNCHECK(isc_taskmgr_create(mctx, 0, netmgr, &taskmgr));
- task = NULL;
RUNCHECK(isc_task_create(taskmgr, 0, &task));
- timermgr = NULL;
- RUNCHECK(isc_timermgr_create(mctx, &timermgr));
- socketmgr = NULL;
- RUNCHECK(isc_socketmgr_create(mctx, &socketmgr));
- dispatchmgr = NULL;
RUNCHECK(dns_dispatchmgr_create(mctx, &dispatchmgr));
isc_sockaddr_any(&bind_any);
attrs = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_MAKEQUERY |
dns_dispatchmgr_destroy(&dispatchmgr);
isc_task_shutdown(task);
isc_task_detach(&task);
- isc_taskmgr_destroy(&taskmgr);
- isc_nm_destroy(&netmgr);
isc_socket_detach(&sock);
- isc_socketmgr_destroy(&socketmgr);
- isc_timermgr_destroy(&timermgr);
+ isc_managers_destroy(&netmgr, &taskmgr, &timermgr, &socketmgr);
dns_tsigkeyring_detach(&ring);
#include <sys/types.h>
#include <unistd.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/netaddr.h>
#include <isc/netmgr.h>
isc_mem_create(&mctx);
- netmgr = isc_nm_start(mctx, workers);
+ isc_managers_create(mctx, workers, 0, 0, &netmgr, NULL, NULL, NULL);
}
static void
close(out);
}
- isc_nm_destroy(&netmgr);
+ isc_managers_destroy(&netmgr, NULL, NULL, NULL);
isc_mem_destroy(&mctx);
if (tls_ctx) {
isc_tlsctx_free(&tls_ctx);
#include <stdlib.h>
#include <strings.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/netaddr.h>
#include <isc/netmgr.h>
isc_mem_create(&mctx);
- netmgr = isc_nm_start(mctx, workers);
+ isc_managers_create(mctx, workers, 0, 0, &netmgr, NULL, NULL, NULL);
}
static void
teardown(void) {
- isc_nm_destroy(&netmgr);
+ isc_managers_destroy(&netmgr, NULL, NULL, NULL);
isc_mem_destroy(&mctx);
if (tls_ctx) {
isc_tlsctx_free(&tls_ctx);
#include <isc/hash.h>
#include <isc/hex.h>
#include <isc/log.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/net.h>
#include <isc/nonce.h>
isc_logconfig_t *lcfg;
isc_nm_t *netmgr = NULL;
isc_taskmgr_t *taskmgr = NULL;
- isc_task_t *task;
- isc_timermgr_t *timermgr;
- isc_socketmgr_t *socketmgr;
- dns_dispatchmgr_t *dispatchmgr;
+ isc_task_t *task = NULL;
+ isc_timermgr_t *timermgr = NULL;
+ isc_socketmgr_t *socketmgr = NULL;
+ dns_dispatchmgr_t *dispatchmgr = NULL;
unsigned int attrs, attrmask;
dns_dispatch_t *dispatchvx;
dns_view_t *view;
fatal("can't choose between IPv4 and IPv6");
}
- netmgr = isc_nm_start(mctx, 1);
+ isc_managers_create(mctx, 1, 0, 0, &netmgr, &taskmgr, &timermgr,
+ &socketmgr);
- RUNCHECK(isc_taskmgr_create(mctx, 0, netmgr, &taskmgr));
- task = NULL;
RUNCHECK(isc_task_create(taskmgr, 0, &task));
- timermgr = NULL;
- RUNCHECK(isc_timermgr_create(mctx, &timermgr));
- socketmgr = NULL;
- RUNCHECK(isc_socketmgr_create(mctx, &socketmgr));
- dispatchmgr = NULL;
RUNCHECK(dns_dispatchmgr_create(mctx, &dispatchmgr));
attrs = DNS_DISPATCHATTR_UDP | DNS_DISPATCHATTR_MAKEQUERY;
dns_dispatch_detach(&dispatchvx);
dns_dispatchmgr_destroy(&dispatchmgr);
- isc_socketmgr_destroy(&socketmgr);
- isc_timermgr_destroy(&timermgr);
-
isc_task_shutdown(task);
isc_task_detach(&task);
- isc_taskmgr_destroy(&taskmgr);
- isc_nm_destroy(&netmgr);
+
+ isc_managers_destroy(&netmgr, &taskmgr, &timermgr, &socketmgr);
dst_lib_destroy();
#include <isc/hash.h>
#include <isc/hex.h>
#include <isc/lex.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/os.h>
#include <isc/print.h>
isc_task_shutdown(maintask);
isc_task_destroy(&maintask);
}
- if (socketmgr != NULL) {
- isc_socketmgr_destroy(&socketmgr);
- }
- if (taskmgr != NULL) {
- isc_taskmgr_destroy(&taskmgr);
- }
- if (netmgr != NULL) {
- isc_nm_destroy(&netmgr);
- }
- if (timermgr != NULL) {
- isc_timermgr_destroy(&timermgr);
- }
+ isc_managers_destroy(&netmgr, &taskmgr, &timermgr, &socketmgr);
if (app_running) {
isc_app_finish();
}
isc_result_t result;
ncpus = isc_os_ncpus();
- netmgr = isc_nm_start(dt_mctx, ncpus);
- CHECK(isc_taskmgr_create(dt_mctx, 0, netmgr, &taskmgr));
- CHECK(isc_timermgr_create(dt_mctx, &timermgr));
- CHECK(isc_socketmgr_create(dt_mctx, &socketmgr));
+ isc_managers_create(dt_mctx, ncpus, 0, 0, &netmgr, &taskmgr, &timermgr,
+ &socketmgr);
CHECK(isc_task_create(taskmgr, 0, &maintask));
return (ISC_R_SUCCESS);
include/isc/list.h \
include/isc/log.h \
include/isc/magic.h \
+ include/isc/managers.h \
include/isc/md.h \
include/isc/mem.h \
include/isc/meminfo.h \
lex.c \
lib.c \
log.c \
+ managers.c \
md.c \
mem.c \
mutexblock.c \
pthreads/thread.c \
entropy_private.h \
fsaccess_common_p.h \
+ task_p.h \
+ timer_p.h \
+ socket_p.h \
+ netmgr_p.h \
lib_p.h \
mem_p.h \
tls_p.h
void
isc_hp_init(int max_threads) {
+ if (isc__hp_max_threads > max_threads) {
+ return;
+ }
isc__hp_max_threads = max_threads;
isc__hp_max_retired = max_threads * HP_MAX_HPS;
}
void
isc_hp_init(int max_threads);
/*%<
- * Initialize hazard pointer constants - isc__hp_max_threads. If more threads
- * will try to access hp it will assert.
+ * Initialize hazard pointer constants, isc__hp_max_threads and
+ * isc__hp_max_retired. If more threads try to access hp, it
+ * will assert. Calling this function repeatedly can be used
+ * to increase the limits, but cannot reduce them.
*/
isc_hp_t *
--- /dev/null
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("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.
+ */
+
+#pragma once
+
+#include <isc/netmgr.h>
+#include <isc/result.h>
+#include <isc/socket.h>
+#include <isc/task.h>
+#include <isc/timer.h>
+
+typedef struct isc_managers isc_managers_t;
+
+isc_result_t
+isc_managers_create(isc_mem_t *mctx, size_t workers, size_t quantum,
+ size_t sockets, isc_nm_t **netmgrp,
+ isc_taskmgr_t **taskmgrp, isc_timermgr_t **timermgrp,
+ isc_socketmgr_t **socketmgrp);
+
+void
+isc_managers_destroy(isc_nm_t **netmgrp, isc_taskmgr_t **taskmgrp,
+ isc_timermgr_t **timermgrp, isc_socketmgr_t **socketmgrp);
* callbacks.
*/
-isc_nm_t *
-isc_nm_start(isc_mem_t *mctx, uint32_t workers);
-/*%<
- * Creates a new network manager with 'workers' worker threads,
- * and starts it running.
- */
-
void
isc_nm_attach(isc_nm_t *mgr, isc_nm_t **dst);
void
isc_nm_detach(isc_nm_t **mgr0);
-void
-isc_nm_destroy(isc_nm_t **mgr0);
/*%<
* Attach/detach a network manager. When all references have been
* released, the network manager is shut down, freeing all resources.
* information regarding copyright ownership.
*/
-#ifndef ISC_SOCKET_H
-#define ISC_SOCKET_H 1
+#pragma once
/*****
***** Module Info
*/
/*@}*/
-isc_result_t
-isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp);
-
-isc_result_t
-isc_socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
- unsigned int maxsocks, int nthreads);
-/*%<
- * Create a socket manager. If "maxsocks" is non-zero, it specifies the
- * maximum number of sockets that the created manager should handle.
- * isc_socketmgr_create() is equivalent of isc_socketmgr_create2() with
- * "maxsocks" being zero.
- *
- * Notes:
- *
- *\li All memory will be allocated in memory context 'mctx'.
- *
- * Requires:
- *
- *\li 'mctx' is a valid memory context.
- *
- *\li 'managerp' points to a NULL isc_socketmgr_t.
- *
- *\li 'actx' is a valid application context (for createinctx()).
- *
- * Ensures:
- *
- *\li '*managerp' is a valid isc_socketmgr_t.
- *
- * Returns:
- *
- *\li #ISC_R_SUCCESS
- *\li #ISC_R_NOMEMORY
- *\li #ISC_R_UNEXPECTED
- *\li #ISC_R_NOTIMPLEMENTED
- */
-
isc_result_t
isc_socketmgr_getmaxsockets(isc_socketmgr_t *manager, unsigned int *nsockp);
/*%<
* (see above).
*/
-void
-isc_socketmgr_destroy(isc_socketmgr_t **managerp);
-/*%<
- * Destroy a socket manager.
- *
- * Notes:
- *
- *\li This routine blocks until there are no sockets left in the manager,
- * so if the caller holds any socket references using the manager, it
- * must detach them before calling isc_socketmgr_destroy() or it will
- * block forever.
- *
- * Requires:
- *
- *\li '*managerp' is a valid isc_socketmgr_t.
- *
- *\li All sockets managed by this manager are fully detached.
- *
- * Ensures:
- *
- *\li *managerp == NULL
- *
- *\li All resources used by the manager have been freed.
- */
-
isc_sockettype_t
isc_socket_gettype(isc_socket_t *sock);
/*%<
isc_socketmgr_t **managerp);
ISC_LANG_ENDDECLS
-
-#endif /* ISC_SOCKET_H */
* information regarding copyright ownership.
*/
-#ifndef ISC_TASK_H
-#define ISC_TASK_H 1
+#pragma once
/*****
***** Module Info
***** Task Manager.
*****/
-isc_result_t
-isc_taskmgr_create(isc_mem_t *mctx, unsigned int default_quantum, isc_nm_t *nm,
- isc_taskmgr_t **managerp);
-/*%<
- * Create a new task manager.
- *
- * Notes:
- *
- *\li If 'default_quantum' is non-zero, then it will be used as the default
- * quantum value when tasks are created. If zero, then an implementation
- * defined default quantum will be used.
- *
- *\li If 'nm' is set then netmgr is paused when an exclusive task mode
- * is requested.
- *
- * Requires:
- *
- *\li 'mctx' is a valid memory context.
- *
- *\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_attach(isc_taskmgr_t *, isc_taskmgr_t **);
void
isc_taskmgr_detach(isc_taskmgr_t *);
-void
-isc_taskmgr_destroy(isc_taskmgr_t **managerp);
-/*%<
- * Destroy '*managerp'.
- *
- * Notes:
- *
- *\li Calling isc_taskmgr_destroy() will shutdown 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_app_shutdown().
- *
- *\li Task manager references are not reference counted, so the caller
- * must ensure that no attempt will be made to use the manager after
- * isc_taskmgr_destroy() returns.
- *
- * Requires:
- *
- *\li '*managerp' is a valid task manager.
- *
- *\li isc_taskmgr_destroy() has not be called previously on '*managerp'.
- *
- * Ensures:
- *
- *\li All resources used by the task manager, and any tasks it managed,
- * have been freed.
- */
-
void
isc_taskmgr_setexcltask(isc_taskmgr_t *mgr, isc_task_t *task);
/*%<
#endif /* HAVE_JSON_C */
ISC_LANG_ENDDECLS
-
-#endif /* ISC_TASK_H */
* information regarding copyright ownership.
*/
-#ifndef ISC_TIMER_H
-#define ISC_TIMER_H 1
+#pragma once
/*****
***** Module Info
*\li 'timer' to be a valid timer.
*/
-isc_result_t
-isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp);
-/*%<
- * Create a timer manager.
- *
- * Notes:
- *
- *\li All memory will be allocated in memory context 'mctx'.
- *
- * Requires:
- *
- *\li 'mctx' is a valid memory context.
- *
- *\li 'managerp' points to a NULL isc_timermgr_t.
- *
- * Ensures:
- *
- *\li '*managerp' is a valid isc_timermgr_t.
- *
- * Returns:
- *
- *\li Success
- *\li No memory
- *\li Unexpected error
- */
-
-void
-isc_timermgr_destroy(isc_timermgr_t **managerp);
-/*%<
- * Destroy a timer manager.
- *
- * Notes:
- *
- *\li This routine blocks until there are no timers left in the manager,
- * so if the caller holds any timer references using the manager, it
- * must detach them before calling isc_timermgr_destroy() or it will
- * block forever.
- *
- * Requires:
- *
- *\li '*managerp' is a valid isc_timermgr_t.
- *
- * Ensures:
- *
- *\li *managerp == NULL
- *
- *\li All resources used by the manager have been freed.
- */
-
void
isc_timermgr_poke(isc_timermgr_t *m);
ISC_LANG_ENDDECLS
-
-#endif /* ISC_TIMER_H */
--- /dev/null
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("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.
+ */
+
+#include <isc/hp.h>
+#include <isc/managers.h>
+#include <isc/util.h>
+
+#include "netmgr_p.h"
+#include "socket_p.h"
+#include "task_p.h"
+#include "timer_p.h"
+
+isc_result_t
+isc_managers_create(isc_mem_t *mctx, size_t workers, size_t quantum,
+ size_t sockets, isc_nm_t **netmgrp,
+ isc_taskmgr_t **taskmgrp, isc_timermgr_t **timermgrp,
+ isc_socketmgr_t **socketmgrp) {
+ isc_result_t result;
+ isc_nm_t *netmgr = NULL;
+ isc_socketmgr_t *socketmgr = NULL;
+ isc_taskmgr_t *taskmgr = NULL;
+ isc_timermgr_t *timermgr = NULL;
+
+ /*
+ * We have ncpus network threads, ncpus old network threads - make
+ * it 4x just to be on the safe side.
+ */
+ isc_hp_init(4 * workers);
+
+ REQUIRE(netmgrp != NULL && *netmgrp == NULL);
+ isc__netmgr_create(mctx, workers, &netmgr);
+ *netmgrp = netmgr;
+ INSIST(netmgr != NULL);
+
+ REQUIRE(taskmgrp == NULL || *taskmgrp == NULL);
+ if (taskmgrp != NULL) {
+ result = isc__taskmgr_create(mctx, quantum, netmgr, &taskmgr);
+ if (result != ISC_R_SUCCESS) {
+ UNEXPECTED_ERROR(__FILE__, __LINE__,
+ "isc_taskmgr_create() failed: %s",
+ isc_result_totext(result));
+ goto fail;
+ }
+ *taskmgrp = taskmgr;
+ }
+
+ REQUIRE(timermgrp == NULL || *timermgrp == NULL);
+ if (timermgrp != NULL) {
+ result = isc__timermgr_create(mctx, &timermgr);
+ if (result != ISC_R_SUCCESS) {
+ UNEXPECTED_ERROR(__FILE__, __LINE__,
+ "isc_timermgr_create() failed: %s",
+ isc_result_totext(result));
+ goto fail;
+ }
+ *timermgrp = timermgr;
+ }
+
+ REQUIRE(socketmgrp == NULL || *socketmgrp == NULL);
+ if (socketmgrp != NULL) {
+ result = isc__socketmgr_create(mctx, &socketmgr, sockets,
+ workers);
+ if (result != ISC_R_SUCCESS) {
+ UNEXPECTED_ERROR(__FILE__, __LINE__,
+ "isc_socketmgr_create() failed: %s",
+ isc_result_totext(result));
+ goto fail;
+ }
+ *socketmgrp = socketmgr;
+ }
+
+ return (ISC_R_SUCCESS);
+fail:
+ isc_managers_destroy(netmgrp, taskmgrp, timermgrp, socketmgrp);
+
+ return (result);
+}
+
+void
+isc_managers_destroy(isc_nm_t **netmgrp, isc_taskmgr_t **taskmgrp,
+ isc_timermgr_t **timermgrp, isc_socketmgr_t **socketmgrp) {
+ if (netmgrp != NULL && *netmgrp != NULL) {
+ isc_nm_closedown(*netmgrp);
+ }
+
+ if (taskmgrp != NULL && *taskmgrp != NULL) {
+ isc__taskmgr_destroy(taskmgrp);
+ }
+
+ if (netmgrp != NULL && *netmgrp != NULL) {
+ isc__netmgr_destroy(netmgrp);
+ }
+
+ if (timermgrp != NULL && *timermgrp != NULL) {
+ isc__timermgr_destroy(timermgrp);
+ }
+
+ if (socketmgrp != NULL && *socketmgrp != NULL) {
+ isc__socketmgr_destroy(socketmgrp);
+ }
+}
#include <isc/util.h>
#include "netmgr-int.h"
+#include "netmgr_p.h"
#include "openssl_shim.h"
#include "uv-compat.h"
}
#endif /* WIN32 */
-isc_nm_t *
-isc_nm_start(isc_mem_t *mctx, uint32_t workers) {
+void
+isc__netmgr_create(isc_mem_t *mctx, uint32_t workers, isc_nm_t **netmgrp) {
isc_nm_t *mgr = NULL;
char name[32];
}
mgr->magic = NM_MAGIC;
- return (mgr);
+ *netmgrp = mgr;
}
/*
}
void
-isc_nm_destroy(isc_nm_t **mgr0) {
+isc__netmgr_destroy(isc_nm_t **netmgrp) {
isc_nm_t *mgr = NULL;
int counter = 0;
- REQUIRE(mgr0 != NULL);
- REQUIRE(VALID_NM(*mgr0));
+ REQUIRE(VALID_NM(*netmgrp));
- mgr = *mgr0;
+ mgr = *netmgrp;
/*
* Close active connections.
/*
* Detach final reference.
*/
- isc_nm_detach(mgr0);
+ isc_nm_detach(netmgrp);
}
void
--- /dev/null
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("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.
+ */
+
+#pragma once
+
+#include <isc/mem.h>
+#include <isc/result.h>
+
+void
+isc__netmgr_create(isc_mem_t *mctx, uint32_t workers, isc_nm_t **netgmrp);
+/*%<
+ * Creates a new network manager with 'workers' worker threads,
+ * and starts it running.
+ */
+
+void
+isc__netmgr_destroy(isc_nm_t **netmgrp);
+/*%<
+ * Destroy is working the same way as isc_nm_detach, but it actively waits
+ * for all other references to be gone.
+ */
--- /dev/null
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("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.
+ */
+
+#include <isc/mem.h>
+#include <isc/result.h>
+#include <isc/socket.h>
+
+isc_result_t
+isc__socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp,
+ unsigned int maxsocks, int nthreads);
+/*%<
+ * Create a socket manager. If "maxsocks" is non-zero, it specifies the
+ * maximum number of sockets that the created manager should handle.
+ *
+ * Notes:
+ *
+ *\li All memory will be allocated in memory context 'mctx'.
+ *
+ * Requires:
+ *
+ *\li 'mctx' is a valid memory context.
+ *
+ *\li 'managerp' points to a NULL isc_socketmgr_t.
+ *
+ * Ensures:
+ *
+ *\li '*managerp' is a valid isc_socketmgr_t.
+ *
+ * Returns:
+ *
+ *\li #ISC_R_SUCCESS
+ *\li #ISC_R_NOMEMORY
+ *\li #ISC_R_UNEXPECTED
+ *\li #ISC_R_NOTIMPLEMENTED
+ */
+
+void
+isc__socketmgr_destroy(isc_socketmgr_t **managerp);
+/*%<
+ * Destroy a socket manager.
+ *
+ * Notes:
+ *
+ *\li This routine blocks until there are no sockets left in the manager,
+ * so if the caller holds any socket references using the manager, it
+ * must detach them before calling isc_socketmgr_destroy() or it will
+ * block forever.
+ *
+ * Requires:
+ *
+ *\li '*managerp' is a valid isc_socketmgr_t.
+ *
+ *\li All sockets managed by this manager are fully detached.
+ *
+ * Ensures:
+ *
+ *\li *managerp == NULL
+ *
+ *\li All resources used by the manager have been freed.
+ */
+
+#if !WIN32
+
+#include <sys/time.h>
+
+typedef struct isc_socketwait isc_socketwait_t;
+int
+isc__socketmgr_waitevents(isc_socketmgr_t *, struct timeval *,
+ isc_socketwait_t **);
+isc_result_t
+isc__socketmgr_dispatch(isc_socketmgr_t *, isc_socketwait_t *);
+
+#endif
#include <json_object.h>
#endif /* HAVE_JSON_C */
-#ifdef OPENSSL_LEAKS
-#include <openssl/err.h>
-#endif /* ifdef OPENSSL_LEAKS */
+#include "task_p.h"
/*
* Task manager is built around 'as little locking as possible' concept.
}
isc_result_t
-isc_taskmgr_create(isc_mem_t *mctx, unsigned int default_quantum, isc_nm_t *nm,
- isc_taskmgr_t **managerp) {
+isc__taskmgr_create(isc_mem_t *mctx, unsigned int default_quantum, isc_nm_t *nm,
+ isc_taskmgr_t **managerp) {
isc_taskmgr_t *manager;
/*
}
void
-isc_taskmgr_destroy(isc_taskmgr_t **managerp) {
+isc__taskmgr_destroy(isc_taskmgr_t **managerp) {
isc_taskmgr_t *manager;
isc_task_t *task;
--- /dev/null
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("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.
+ */
+
+#pragma once
+
+#include <isc/mem.h>
+#include <isc/result.h>
+#include <isc/task.h>
+
+isc_result_t
+isc__taskmgr_create(isc_mem_t *mctx, unsigned int default_quantum, isc_nm_t *nm,
+ isc_taskmgr_t **managerp);
+/*%<
+ * Create a new task manager.
+ *
+ * Notes:
+ *
+ *\li If 'default_quantum' is non-zero, then it will be used as the default
+ * quantum value when tasks are created. If zero, then an implementation
+ * defined default quantum will be used.
+ *
+ *\li If 'nm' is set then netmgr is paused when an exclusive task mode
+ * is requested.
+ *
+ * Requires:
+ *
+ *\li 'mctx' is a valid memory context.
+ *
+ *\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 shutdown 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_app_shutdown().
+ *
+ *\li Task manager references are not reference counted, so the caller
+ * must ensure that no attempt will be made to use the manager after
+ * isc_taskmgr_destroy() returns.
+ *
+ * Requires:
+ *
+ *\li '*managerp' is a valid task manager.
+ *
+ *\li isc_taskmgr_destroy() has not be called previously on '*managerp'.
+ *
+ * Ensures:
+ *
+ *\li All resources used by the task manager, and any tasks it managed,
+ * have been freed.
+ */
check_LTLIBRARIES = libisctest.la
libisctest_la_SOURCES = \
- ../unix/socket_p.h \
+ ../socket_p.h \
isctest.c \
isctest.h \
uv_wrap.h
#include "../netmgr/netmgr-int.h"
#include "../netmgr/uv-compat.c"
#include "../netmgr/uv-compat.h"
+#include "../netmgr_p.h"
#include "isctest.h"
#define MAX_NM 2
nm = isc_mem_get(test_mctx, MAX_NM * sizeof(nm[0]));
for (size_t i = 0; i < MAX_NM; i++) {
- nm[i] = isc_nm_start(test_mctx, nworkers);
+ isc__netmgr_create(test_mctx, nworkers, &nm[i]);
assert_non_null(nm[i]);
}
isc_nm_t **nm = (isc_nm_t **)*state;
for (size_t i = 0; i < MAX_NM; i++) {
- isc_nm_destroy(&nm[i]);
+ isc__netmgr_destroy(&nm[i]);
assert_null(nm[i]);
}
isc_mem_put(test_mctx, nm, MAX_NM * sizeof(nm[0]));
#include <isc/buffer.h>
#include <isc/hash.h>
#include <isc/hp.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/os.h>
#include <isc/socket.h>
isc_task_shutdown(maintask);
isc_task_destroy(&maintask);
}
- if (socketmgr != NULL) {
- isc_socketmgr_destroy(&socketmgr);
- }
- if (taskmgr != NULL) {
- isc_taskmgr_destroy(&taskmgr);
- }
- if (netmgr != NULL) {
- isc_nm_destroy(&netmgr);
- }
- if (timermgr != NULL) {
- isc_timermgr_destroy(&timermgr);
- }
+ isc_managers_destroy(&netmgr, &taskmgr, &timermgr, &socketmgr);
}
static isc_result_t
INSIST(workers != 0);
isc_hp_init(6 * workers);
+ isc_managers_create(test_mctx, workers, 0, 0, &netmgr, &taskmgr,
+ &timermgr, &socketmgr);
- netmgr = isc_nm_start(test_mctx, workers);
- CHECK(isc_taskmgr_create(test_mctx, 0, netmgr, &taskmgr));
CHECK(isc_task_create(taskmgr, 0, &maintask));
isc_taskmgr_setexcltask(taskmgr, maintask);
- CHECK(isc_timermgr_create(test_mctx, &timermgr));
- CHECK(isc_socketmgr_create(test_mctx, &socketmgr));
return (ISC_R_SUCCESS);
cleanup:
if (maintask != NULL) {
isc_task_detach(&maintask);
}
- if (taskmgr != NULL) {
- isc_taskmgr_destroy(&taskmgr);
- }
cleanup_managers();
#include "../netmgr/udp.c"
#include "../netmgr/uv-compat.c"
#include "../netmgr/uv-compat.h"
+#include "../netmgr_p.h"
#include "isctest.h"
typedef void (*stream_connect_function)(isc_nm_t *nm);
return (-1);
}
- listen_nm = isc_nm_start(test_mctx, workers);
+ isc__netmgr_create(test_mctx, workers, &listen_nm);
assert_non_null(listen_nm);
isc_nm_settimeouts(listen_nm, T_INIT, T_IDLE, T_KEEPALIVE,
T_ADVERTISED);
- connect_nm = isc_nm_start(test_mctx, workers);
+ isc__netmgr_create(test_mctx, workers, &connect_nm);
assert_non_null(connect_nm);
isc_nm_settimeouts(connect_nm, T_INIT, T_IDLE, T_KEEPALIVE,
T_ADVERTISED);
nm_teardown(void **state __attribute__((unused))) {
UNUSED(state);
- isc_nm_destroy(&connect_nm);
+ isc__netmgr_destroy(&connect_nm);
assert_null(connect_nm);
- isc_nm_destroy(&listen_nm);
+ isc__netmgr_destroy(&listen_nm);
assert_null(listen_nm);
WAIT_FOR_EQ(active_cconnects, 0);
#include <isc/socket.h>
#include <isc/task.h>
-#include "../unix/socket_p.h"
+#include "../socket_p.h"
#include "isctest.h"
static bool recv_dscp;
#include <isc/cmocka.h>
#include <isc/commandline.h>
#include <isc/condition.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/platform.h>
#include <isc/print.h>
static void
manytasks(void **state) {
isc_mem_t *mctx = NULL;
- isc_result_t result;
isc_event_t *event = NULL;
uintptr_t ntasks = 10000;
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
isc_mem_create(&mctx);
- netmgr = isc_nm_start(mctx, 4);
- result = isc_taskmgr_create(mctx, 0, netmgr, &taskmgr);
- assert_int_equal(result, ISC_R_SUCCESS);
+ isc_managers_create(mctx, 4, 0, 0, &netmgr, &taskmgr, NULL, NULL);
atomic_init(&done, false);
}
UNLOCK(&lock);
- isc_taskmgr_destroy(&taskmgr);
- isc_nm_destroy(&netmgr);
+ isc_managers_destroy(&netmgr, &taskmgr, NULL, NULL);
+
isc_mem_destroy(&mctx);
isc_condition_destroy(&cv);
isc_mutex_destroy(&lock);
}
static void
-shutdown(void **state) {
+task_shutdown(void **state) {
isc_result_t result;
isc_eventtype_t event_type;
isc_event_t *event = NULL;
cmocka_unit_test_setup_teardown(purgeevent_notpurge, _setup,
_teardown),
cmocka_unit_test_setup_teardown(purgerange, _setup, _teardown),
- cmocka_unit_test_setup_teardown(shutdown, _setup4, _teardown),
+ cmocka_unit_test_setup_teardown(task_shutdown, _setup4,
+ _teardown),
cmocka_unit_test_setup_teardown(task_exclusive, _setup4,
_teardown),
};
#include <isc/timer.h>
#include <isc/util.h>
-#ifdef OPENSSL_LEAKS
-#include <openssl/err.h>
-#endif /* ifdef OPENSSL_LEAKS */
+#include "timer_p.h"
#ifdef ISC_TIMER_TRACE
#define XTRACE(s) fprintf(stderr, "%s\n", (s))
}
UNLOCK(&manager->lock);
-#ifdef OPENSSL_LEAKS
- ERR_remove_state(0);
-#endif /* ifdef OPENSSL_LEAKS */
-
return ((isc_threadresult_t)0);
}
}
isc_result_t
-isc_timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
+isc__timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp) {
isc_timermgr_t *manager;
isc_result_t result;
}
void
-isc_timermgr_destroy(isc_timermgr_t **managerp) {
+isc__timermgr_destroy(isc_timermgr_t **managerp) {
isc_timermgr_t *manager;
/*
--- /dev/null
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("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.
+ */
+
+#pragma once
+
+#include <isc/mem.h>
+#include <isc/result.h>
+#include <isc/timer.h>
+
+isc_result_t
+isc__timermgr_create(isc_mem_t *mctx, isc_timermgr_t **managerp);
+/*%<
+ * Create a timer manager.
+ *
+ * Notes:
+ *
+ *\li All memory will be allocated in memory context 'mctx'.
+ *
+ * Requires:
+ *
+ *\li 'mctx' is a valid memory context.
+ *
+ *\li 'managerp' points to a NULL isc_timermgr_t.
+ *
+ * Ensures:
+ *
+ *\li '*managerp' is a valid isc_timermgr_t.
+ *
+ * Returns:
+ *
+ *\li Success
+ *\li No memory
+ *\li Unexpected error
+ */
+
+void
+isc__timermgr_destroy(isc_timermgr_t **managerp);
+/*%<
+ * Destroy a timer manager.
+ *
+ * Notes:
+ *
+ *\li This routine blocks until there are no timers left in the manager,
+ * so if the caller holds any timer references using the manager, it
+ * must detach them before calling isc_timermgr_destroy() or it will
+ * block forever.
+ *
+ * Requires:
+ *
+ *\li '*managerp' is a valid isc_timermgr_t.
+ *
+ * Ensures:
+ *
+ *\li *managerp == NULL
+ *
+ *\li All resources used by the manager have been freed.
+ */
#include <netinet/tcp.h>
#include "errno2result.h"
+#include "socket_p.h"
#ifdef ENABLE_TCP_FASTOPEN
#include <netinet/tcp.h>
}
isc_result_t
-isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp) {
- return (isc_socketmgr_create2(mctx, managerp, 0, 1));
-}
-
-isc_result_t
-isc_socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
+isc__socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp,
unsigned int maxsocks, int nthreads) {
int i;
isc_socketmgr_t *manager;
}
void
-isc_socketmgr_destroy(isc_socketmgr_t **managerp) {
+isc__socketmgr_destroy(isc_socketmgr_t **managerp) {
isc_socketmgr_t *manager;
/*
+++ /dev/null
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("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.
- */
-
-#ifndef ISC_SOCKET_P_H
-#define ISC_SOCKET_P_H
-
-/*! \file */
-
-#include <sys/time.h>
-
-typedef struct isc_socketwait isc_socketwait_t;
-int
-isc__socketmgr_waitevents(isc_socketmgr_t *, struct timeval *,
- isc_socketwait_t **);
-isc_result_t
-isc__socketmgr_dispatch(isc_socketmgr_t *, isc_socketwait_t *);
-#endif /* ISC_SOCKET_P_H */
isc_socket_sendto
isc_socket_sendto2
isc_socket_setname
-isc_socketmgr_create
-isc_socketmgr_create2
-isc_socketmgr_destroy
isc_socketmgr_getmaxsockets
isc_socketmgr_setreserved
isc_socketmgr_setstats
isc_logconfig_destroy
isc_logconfig_use
isc_logfile_roll
+isc_managers_create
+isc_managers_destroy
isc_md_new
isc_md_init
isc_md_reset
isc_nmhandle_settimeout
isc_nm_cancelread
isc_nm_closedown
-isc_nm_destroy
isc_nm_detach
isc_nm_http_endpoint
isc_nm_httpconnect
isc_nm_resumeread
isc_nm_send
isc_nm_setstats
-isc_nm_start
isc_nm_stoplistening
isc_nm_tcpconnect
isc_nm_tcpdnsconnect
isc_task_shutdown
isc_task_unpause
isc_task_unsend
-isc_taskmgr_create
-isc_taskmgr_destroy
isc_taskmgr_excltask
@IF NOTYET
isc_taskmgr_renderjson
isc_timer_gettype
isc_timer_reset
isc_timer_touch
-isc_timermgr_create
-isc_timermgr_destroy
isc_timermgr_poke
isc_tls_get_http2_alpn
isc_tls_create
<ClInclude Include="..\include\isc\magic.h">
<Filter>Library Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\include\isc\managers.h">
+ <Filter>Library Header Files</Filter>
+ </ClInclude>
<ClInclude Include="..\include\isc\mem.h">
<Filter>Library Header Files</Filter>
</ClInclude>
<ClCompile Include="..\log.c">
<Filter>Library Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\managers.c">
+ <Filter>Library Source Files</Filter>
+ </ClCompile>
<ClCompile Include="..\mem.c">
<Filter>Library Source Files</Filter>
</ClCompile>
<ClInclude Include="..\include\isc\list.h" />
<ClInclude Include="..\include\isc\log.h" />
<ClInclude Include="..\include\isc\magic.h" />
+ <ClInclude Include="..\include\isc\managers.h" />
<ClInclude Include="..\include\isc\md.h" />
<ClInclude Include="..\include\isc\mem.h" />
<ClInclude Include="..\include\isc\meminfo.h" />
<ClCompile Include="..\lex.c" />
<ClCompile Include="..\lib.c" />
<ClCompile Include="..\log.c" />
+ <ClCompile Include="..\managers.c" />
<ClCompile Include="..\md.c" />
<ClCompile Include="..\mem.c" />
<ClCompile Include="..\mutexblock.c" />
#endif /* HAVE_LIBXML2 */
#include "errno2result.h"
+#include "socket_p.h"
/*
* Set by the -T dscp option on the command line. If set to a value
* Create a new socket manager.
*/
isc_result_t
-isc_socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp) {
- return (isc_socketmgr_create2(mctx, managerp, 0, 1));
-}
-
-isc_result_t
-isc_socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp,
+isc__socketmgr_create(isc_mem_t *mctx, isc_socketmgr_t **managerp,
unsigned int maxsocks, int nthreads) {
isc_socketmgr_t *manager;
}
void
-isc_socketmgr_destroy(isc_socketmgr_t **managerp) {
+isc__socketmgr_destroy(isc_socketmgr_t **managerp) {
isc_socketmgr_t *manager;
/*
#include <isc/buffer.h>
#include <isc/file.h>
#include <isc/hash.h>
+#include <isc/managers.h>
#include <isc/mem.h>
#include <isc/netmgr.h>
#include <isc/os.h>
isc_task_t *maintask = NULL;
isc_timermgr_t *timermgr = NULL;
isc_socketmgr_t *socketmgr = NULL;
-isc_nm_t *nm = NULL;
dns_zonemgr_t *zonemgr = NULL;
dns_dispatchmgr_t *dispatchmgr = NULL;
ns_clientmgr_t *clientmgr = NULL;
if (interfacemgr != NULL) {
ns_interfacemgr_detach(&interfacemgr);
}
- if (socketmgr != NULL) {
- isc_socketmgr_destroy(&socketmgr);
- }
- ns_test_nap(500000);
- if (nm != NULL) {
- /*
- * Force something in the workqueue as a workaround
- * for libuv bug - not sending uv_close callback.
- */
- isc_nm_pause(nm);
- isc_nm_resume(nm);
- isc_nm_detach(&nm);
- }
- if (taskmgr != NULL) {
- isc_taskmgr_destroy(&taskmgr);
- }
- if (netmgr != NULL) {
- isc_nm_destroy(&netmgr);
- }
- if (timermgr != NULL) {
- isc_timermgr_destroy(&timermgr);
- }
+
+ isc_managers_destroy(&netmgr, &taskmgr, &timermgr, &socketmgr);
+
if (app_running) {
isc_app_finish();
}
isc_event_t *event = NULL;
ncpus = isc_os_ncpus();
- netmgr = isc_nm_start(mctx, ncpus);
- CHECK(isc_taskmgr_create(mctx, 0, netmgr, &taskmgr));
+ isc_managers_create(mctx, ncpus, 0, 0, &netmgr, &taskmgr, &timermgr,
+ &socketmgr);
CHECK(isc_task_create(taskmgr, 0, &maintask));
isc_taskmgr_setexcltask(taskmgr, maintask);
CHECK(isc_task_onshutdown(maintask, shutdown_managers, NULL));
- CHECK(isc_timermgr_create(mctx, &timermgr));
-
- CHECK(isc_socketmgr_create(mctx, &socketmgr));
-
- nm = isc_nm_start(mctx, ncpus);
-
CHECK(ns_server_create(mctx, matchview, &sctx));
CHECK(dns_dispatchmgr_create(mctx, &dispatchmgr));
CHECK(ns_interfacemgr_create(mctx, sctx, taskmgr, timermgr, socketmgr,
- nm, dispatchmgr, maintask, ncpus, NULL,
+ netmgr, dispatchmgr, maintask, ncpus, NULL,
ncpus, &interfacemgr));
CHECK(ns_listenlist_default(mctx, port, -1, true, &listenon));
./lib/isc/include/isc/list.h C 1997,1998,1999,2000,2001,2002,2004,2006,2007,2011,2012,2013,2016,2018,2019,2020,2021
./lib/isc/include/isc/log.h C 1999,2000,2001,2002,2004,2005,2006,2007,2009,2014,2016,2017,2018,2019,2020,2021
./lib/isc/include/isc/magic.h C 1999,2000,2001,2004,2005,2006,2007,2016,2017,2018,2019,2020,2021
+./lib/isc/include/isc/managers.h C 2021
./lib/isc/include/isc/md.h C 2018,2019,2020,2021
./lib/isc/include/isc/mem.h C 1997,1998,1999,2000,2001,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2015,2016,2017,2018,2019,2020,2021
./lib/isc/include/isc/meminfo.h C 2015,2016,2018,2019,2020,2021
./lib/isc/lib.c C 1999,2000,2001,2004,2005,2007,2009,2013,2014,2015,2016,2018,2019,2020,2021
./lib/isc/lib_p.h C 2021
./lib/isc/log.c C 1999,2000,2001,2002,2003,2004,2005,2006,2007,2009,2011,2012,2013,2014,2016,2017,2018,2019,2020,2021
+./lib/isc/managers.c C 2021
./lib/isc/md.c C 2018,2019,2020,2021
./lib/isc/mem.c C 1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021
./lib/isc/mem_p.h C 2018,2019,2020,2021
./lib/isc/netmgr/uv-compat.c C 2020,2021
./lib/isc/netmgr/uv-compat.h C 2019,2020,2021
./lib/isc/netmgr/uverr2result.c C 2019,2020,2021
+./lib/isc/netmgr_p.h C 2021
./lib/isc/netscope.c C 2002,2004,2005,2006,2007,2016,2018,2019,2020,2021
./lib/isc/nonce.c C 2018,2019,2020,2021
./lib/isc/openssl_shim.c C 2018,2019,2020,2021
./lib/isc/serial.c C 1999,2000,2001,2004,2005,2007,2016,2018,2019,2020,2021
./lib/isc/siphash.c C 2019,2020,2021
./lib/isc/sockaddr.c C 1999,2000,2001,2002,2003,2004,2005,2006,2007,2010,2011,2012,2014,2015,2016,2017,2018,2019,2020,2021
+./lib/isc/socket_p.h C 2021
./lib/isc/stats.c C 2009,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021
./lib/isc/string.c C 1999,2000,2001,2003,2004,2005,2006,2007,2011,2012,2014,2015,2016,2018,2019,2020,2021
./lib/isc/symtab.c C 1996,1997,1998,1999,2000,2001,2004,2005,2007,2011,2012,2013,2016,2018,2019,2020,2021
./lib/isc/task.c C 1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021
+./lib/isc/task_p.h C 2021
./lib/isc/taskpool.c C 1999,2000,2001,2004,2005,2007,2011,2012,2013,2016,2018,2019,2020,2021
./lib/isc/tests/aes_test.c C 2014,2016,2018,2019,2020,2021
./lib/isc/tests/buffer_test.c C 2014,2015,2016,2017,2018,2019,2020,2021
./lib/isc/tests/timer_test.c C 2018,2019,2020,2021
./lib/isc/tests/uv_wrap.h C 2020,2021
./lib/isc/timer.c C 1998,1999,2000,2001,2002,2004,2005,2007,2008,2009,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021
+./lib/isc/timer_p.h C 2021
./lib/isc/tls.c C 2021
./lib/isc/tls_p.h C 2021
./lib/isc/tm.c C 2014,2016,2018,2019,2020,2021
./lib/isc/unix/pk11_api.c C 2014,2016,2018,2019,2020,2021
./lib/isc/unix/resource.c C 2000,2001,2004,2007,2008,2009,2016,2018,2019,2020,2021
./lib/isc/unix/socket.c C 1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021
-./lib/isc/unix/socket_p.h C 2000,2001,2004,2005,2007,2008,2009,2016,2018,2019,2020,2021
./lib/isc/unix/stdio.c C 2000,2001,2004,2007,2011,2012,2013,2014,2016,2018,2019,2020,2021
./lib/isc/unix/stdtime.c C 1999,2000,2001,2004,2005,2007,2016,2018,2019,2020,2021
./lib/isc/unix/syslog.c C 2001,2004,2005,2007,2016,2018,2019,2020,2021