2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

Move entropy and dispatchmgr create/destroy to more correct places.

This commit is contained in:
Brian Wellington
2000-06-21 22:12:02 +00:00
parent 17e0f3e747
commit 165250c403
5 changed files with 32 additions and 25 deletions

View File

@@ -40,6 +40,7 @@ EXTERN isc_mem_t * ns_g_mctx INIT(NULL);
EXTERN unsigned int ns_g_cpus INIT(1);
EXTERN isc_taskmgr_t * ns_g_taskmgr INIT(NULL);
EXTERN dns_dispatchmgr_t * ns_g_dispatchmgr INIT(NULL);
EXTERN isc_entropy_t * ns_g_entropy INIT(NULL);
/*
* XXXRTH We're going to want multiple timer managers eventually. One
* for really short timers, another for client timers, and one

View File

@@ -57,7 +57,6 @@ struct ns_server {
dns_db_t * in_roothints;
dns_tkeyctx_t * tkeyctx;
isc_timer_t * interface_timer;
isc_entropy_t * entropy;
isc_mutex_t reload_event_lock;
isc_event_t * reload_event;

View File

@@ -191,6 +191,12 @@ ns_lwresd_createview(isc_mem_t *mctx, dns_view_t **viewp) {
REQUIRE(viewp != NULL && *viewp == NULL);
cache = NULL;
result = dns_dispatchmgr_create(ns_g_mctx, ns_g_entropy,
&ns_g_dispatchmgr);
if (result != ISC_R_SUCCESS)
fatal("creating dispatch manager", result);
/*
* View.
*/
@@ -323,7 +329,13 @@ ns_lwresd_create(isc_mem_t *mctx, dns_view_t *view, ns_lwresd_t **lwresdp) {
lwresd->sock = sock;
lwresd->view = NULL;
dns_view_attach(view, &lwresd->view);
if (view != NULL)
dns_view_attach(view, &lwresd->view);
else {
result = ns_lwresd_createview(ns_g_mctx, &lwresd->view);
if (result != ISC_R_SUCCESS)
fatal("failed to create default view", result);
}
lwresd->task = NULL;
result = isc_task_create(ns_g_taskmgr, 0, &lwresd->task);

View File

@@ -22,6 +22,7 @@
#include <isc/app.h>
#include <isc/commandline.h>
#include <isc/entropy.h>
#include <isc/task.h>
#include <isc/timer.h>
#include <isc/util.h>
@@ -364,14 +365,16 @@ create_managers(void) {
return (ISC_R_UNEXPECTED);
}
result = dns_dispatchmgr_create(ns_g_mctx, NULL, &ns_g_dispatchmgr);
result = isc_entropy_create(ns_g_mctx, &ns_g_entropy);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"dns_dispatchmgr_create() failed: %s",
"isc_entropy_create() failed: %s",
isc_result_totext(result));
return (ISC_R_UNEXPECTED);
}
(void)isc_entropy_createfilesource(ns_g_entropy, "/dev/random");
return (ISC_R_SUCCESS);
}
@@ -384,7 +387,7 @@ destroy_managers(void) {
omapi_lib_destroy();
}
dns_dispatchmgr_destroy(&ns_g_dispatchmgr);
isc_entropy_detach(&ns_g_entropy);
/*
* isc_taskmgr_destroy() will block until all tasks have exited,
*/
@@ -432,15 +435,9 @@ setup(void) {
ns_main_earlyfatal("create_managers() failed: %s",
isc_result_totext(result));
if (lwresd_only) {
dns_view_t *view = NULL;
result = ns_lwresd_createview(ns_g_mctx, &view);
if (result != ISC_R_SUCCESS)
ns_main_earlyfatal("ns_lwresd_createview() failed: %s",
isc_result_totext(result));
ns_lwresd_create(ns_g_mctx, view, &ns_g_lwresd);
dns_view_detach(&view);
} else
if (lwresd_only)
ns_lwresd_create(ns_g_mctx, NULL, &ns_g_lwresd);
else
ns_server_create(ns_g_mctx, &ns_g_server);
if (!lwresd_only) {

View File

@@ -1316,7 +1316,7 @@ load_configuration(const char *filename, ns_server_t *server,
*/
{
dns_tkeyctx_t *t = NULL;
CHECKM(dns_tkeyctx_fromconfig(cctx, ns_g_mctx, server->entropy,
CHECKM(dns_tkeyctx_fromconfig(cctx, ns_g_mctx, ns_g_entropy,
&t),
"configuring TKEY");
if (server->tkeyctx != NULL)
@@ -1443,6 +1443,10 @@ run_server(isc_task_t *task, isc_event_t *event) {
isc_event_free(&event);
CHECKFATAL(dns_dispatchmgr_create(ns_g_mctx, ns_g_entropy,
&ns_g_dispatchmgr),
"creating dispatch manager");
CHECKFATAL(ns_clientmgr_create(ns_g_mctx, ns_g_taskmgr, ns_g_timermgr,
&server->clientmgr),
"creating client manager");
@@ -1495,6 +1499,8 @@ shutdown_server(isc_task_t *task, isc_event_t *event) {
ns_interfacemgr_shutdown(server->interfacemgr);
ns_interfacemgr_detach(&server->interfacemgr);
dns_dispatchmgr_destroy(&ns_g_dispatchmgr);
dns_zonemgr_shutdown(server->zonemgr);
isc_task_detach(&server->task);
@@ -1553,16 +1559,11 @@ ns_server_create(isc_mem_t *mctx, ns_server_t **serverp) {
ISC_R_NOMEMORY : ISC_R_SUCCESS,
"allocating reload event");
server->entropy = NULL;
CHECKFATAL(isc_entropy_create(ns_g_mctx, &server->entropy),
"initializing entropy pool");
(void)isc_entropy_createfilesource(server->entropy, "/dev/random");
CHECKFATAL(dst_lib_init(ns_g_mctx, server->entropy, 0),
CHECKFATAL(dst_lib_init(ns_g_mctx, ns_g_entropy, 0),
"initializing DST");
server->tkeyctx = NULL;
CHECKFATAL(dns_tkeyctx_create(ns_g_mctx, server->entropy,
CHECKFATAL(dns_tkeyctx_create(ns_g_mctx, ns_g_entropy,
&server->tkeyctx),
"creating TKEY context");
@@ -1602,9 +1603,6 @@ ns_server_destroy(ns_server_t **serverp) {
dst_lib_destroy();
if (server->entropy != NULL)
isc_entropy_detach(&server->entropy);
isc_event_free(&server->reload_event);
INSIST(ISC_LIST_EMPTY(server->viewlist));