mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-01 06:55:30 +00:00
Move entropy and dispatchmgr create/destroy to more correct places.
This commit is contained in:
@@ -40,6 +40,7 @@ EXTERN isc_mem_t * ns_g_mctx INIT(NULL);
|
|||||||
EXTERN unsigned int ns_g_cpus INIT(1);
|
EXTERN unsigned int ns_g_cpus INIT(1);
|
||||||
EXTERN isc_taskmgr_t * ns_g_taskmgr INIT(NULL);
|
EXTERN isc_taskmgr_t * ns_g_taskmgr INIT(NULL);
|
||||||
EXTERN dns_dispatchmgr_t * ns_g_dispatchmgr 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
|
* XXXRTH We're going to want multiple timer managers eventually. One
|
||||||
* for really short timers, another for client timers, and one
|
* for really short timers, another for client timers, and one
|
||||||
|
@@ -57,7 +57,6 @@ struct ns_server {
|
|||||||
dns_db_t * in_roothints;
|
dns_db_t * in_roothints;
|
||||||
dns_tkeyctx_t * tkeyctx;
|
dns_tkeyctx_t * tkeyctx;
|
||||||
isc_timer_t * interface_timer;
|
isc_timer_t * interface_timer;
|
||||||
isc_entropy_t * entropy;
|
|
||||||
|
|
||||||
isc_mutex_t reload_event_lock;
|
isc_mutex_t reload_event_lock;
|
||||||
isc_event_t * reload_event;
|
isc_event_t * reload_event;
|
||||||
|
@@ -191,6 +191,12 @@ ns_lwresd_createview(isc_mem_t *mctx, dns_view_t **viewp) {
|
|||||||
REQUIRE(viewp != NULL && *viewp == NULL);
|
REQUIRE(viewp != NULL && *viewp == NULL);
|
||||||
cache = 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.
|
* View.
|
||||||
*/
|
*/
|
||||||
@@ -323,7 +329,13 @@ ns_lwresd_create(isc_mem_t *mctx, dns_view_t *view, ns_lwresd_t **lwresdp) {
|
|||||||
lwresd->sock = sock;
|
lwresd->sock = sock;
|
||||||
|
|
||||||
lwresd->view = NULL;
|
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;
|
lwresd->task = NULL;
|
||||||
result = isc_task_create(ns_g_taskmgr, 0, &lwresd->task);
|
result = isc_task_create(ns_g_taskmgr, 0, &lwresd->task);
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include <isc/app.h>
|
#include <isc/app.h>
|
||||||
#include <isc/commandline.h>
|
#include <isc/commandline.h>
|
||||||
|
#include <isc/entropy.h>
|
||||||
#include <isc/task.h>
|
#include <isc/task.h>
|
||||||
#include <isc/timer.h>
|
#include <isc/timer.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
@@ -364,14 +365,16 @@ create_managers(void) {
|
|||||||
return (ISC_R_UNEXPECTED);
|
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) {
|
if (result != ISC_R_SUCCESS) {
|
||||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||||
"dns_dispatchmgr_create() failed: %s",
|
"isc_entropy_create() failed: %s",
|
||||||
isc_result_totext(result));
|
isc_result_totext(result));
|
||||||
return (ISC_R_UNEXPECTED);
|
return (ISC_R_UNEXPECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(void)isc_entropy_createfilesource(ns_g_entropy, "/dev/random");
|
||||||
|
|
||||||
return (ISC_R_SUCCESS);
|
return (ISC_R_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,7 +387,7 @@ destroy_managers(void) {
|
|||||||
omapi_lib_destroy();
|
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,
|
* isc_taskmgr_destroy() will block until all tasks have exited,
|
||||||
*/
|
*/
|
||||||
@@ -432,15 +435,9 @@ setup(void) {
|
|||||||
ns_main_earlyfatal("create_managers() failed: %s",
|
ns_main_earlyfatal("create_managers() failed: %s",
|
||||||
isc_result_totext(result));
|
isc_result_totext(result));
|
||||||
|
|
||||||
if (lwresd_only) {
|
if (lwresd_only)
|
||||||
dns_view_t *view = NULL;
|
ns_lwresd_create(ns_g_mctx, NULL, &ns_g_lwresd);
|
||||||
result = ns_lwresd_createview(ns_g_mctx, &view);
|
else
|
||||||
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
|
|
||||||
ns_server_create(ns_g_mctx, &ns_g_server);
|
ns_server_create(ns_g_mctx, &ns_g_server);
|
||||||
|
|
||||||
if (!lwresd_only) {
|
if (!lwresd_only) {
|
||||||
|
@@ -1316,7 +1316,7 @@ load_configuration(const char *filename, ns_server_t *server,
|
|||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
dns_tkeyctx_t *t = NULL;
|
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),
|
&t),
|
||||||
"configuring TKEY");
|
"configuring TKEY");
|
||||||
if (server->tkeyctx != NULL)
|
if (server->tkeyctx != NULL)
|
||||||
@@ -1443,6 +1443,10 @@ run_server(isc_task_t *task, isc_event_t *event) {
|
|||||||
|
|
||||||
isc_event_free(&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,
|
CHECKFATAL(ns_clientmgr_create(ns_g_mctx, ns_g_taskmgr, ns_g_timermgr,
|
||||||
&server->clientmgr),
|
&server->clientmgr),
|
||||||
"creating client manager");
|
"creating client manager");
|
||||||
@@ -1495,6 +1499,8 @@ shutdown_server(isc_task_t *task, isc_event_t *event) {
|
|||||||
ns_interfacemgr_shutdown(server->interfacemgr);
|
ns_interfacemgr_shutdown(server->interfacemgr);
|
||||||
ns_interfacemgr_detach(&server->interfacemgr);
|
ns_interfacemgr_detach(&server->interfacemgr);
|
||||||
|
|
||||||
|
dns_dispatchmgr_destroy(&ns_g_dispatchmgr);
|
||||||
|
|
||||||
dns_zonemgr_shutdown(server->zonemgr);
|
dns_zonemgr_shutdown(server->zonemgr);
|
||||||
|
|
||||||
isc_task_detach(&server->task);
|
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,
|
ISC_R_NOMEMORY : ISC_R_SUCCESS,
|
||||||
"allocating reload event");
|
"allocating reload event");
|
||||||
|
|
||||||
server->entropy = NULL;
|
CHECKFATAL(dst_lib_init(ns_g_mctx, ns_g_entropy, 0),
|
||||||
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),
|
|
||||||
"initializing DST");
|
"initializing DST");
|
||||||
|
|
||||||
server->tkeyctx = NULL;
|
server->tkeyctx = NULL;
|
||||||
CHECKFATAL(dns_tkeyctx_create(ns_g_mctx, server->entropy,
|
CHECKFATAL(dns_tkeyctx_create(ns_g_mctx, ns_g_entropy,
|
||||||
&server->tkeyctx),
|
&server->tkeyctx),
|
||||||
"creating TKEY context");
|
"creating TKEY context");
|
||||||
|
|
||||||
@@ -1602,9 +1603,6 @@ ns_server_destroy(ns_server_t **serverp) {
|
|||||||
|
|
||||||
dst_lib_destroy();
|
dst_lib_destroy();
|
||||||
|
|
||||||
if (server->entropy != NULL)
|
|
||||||
isc_entropy_detach(&server->entropy);
|
|
||||||
|
|
||||||
isc_event_free(&server->reload_event);
|
isc_event_free(&server->reload_event);
|
||||||
|
|
||||||
INSIST(ISC_LIST_EMPTY(server->viewlist));
|
INSIST(ISC_LIST_EMPTY(server->viewlist));
|
||||||
|
Reference in New Issue
Block a user