Commit b03758b0 authored by Andreas Gustafsson's avatar Andreas Gustafsson
Browse files

eliminated global variables ns_g_zonemgr and ns_g_clientmgr

parent d468db05
......@@ -47,10 +47,8 @@ EXTERN isc_taskmgr_t * ns_g_taskmgr INIT(NULL);
*/
EXTERN isc_timermgr_t * ns_g_timermgr INIT(NULL);
EXTERN isc_socketmgr_t * ns_g_socketmgr INIT(NULL);
EXTERN ns_clientmgr_t * ns_g_clientmgr INIT(NULL);
EXTERN char * ns_g_version INIT(VERSION);
EXTERN in_port_t ns_g_port INIT(53);
EXTERN dns_zonemgr_t * ns_g_zonemgr INIT(NULL);
EXTERN ns_server_t * ns_g_server INIT(NULL);
......
......@@ -45,6 +45,8 @@ struct ns_server {
isc_quota_t recursionquota;
/* Server data structures. */
dns_zonemgr_t * zonemgr;
ns_clientmgr_t * clientmgr;
dns_viewlist_t viewlist;
isc_rwlock_t viewlock;
ns_interfacemgr_t * interfacemgr;
......
......@@ -40,7 +40,6 @@
#define NS_MAIN 1
#include <named/globals.h>
#include <named/client.h>
#include <named/interfacemgr.h>
#include <named/log.h>
#include <named/os.h>
......@@ -210,15 +209,6 @@ create_managers() {
return (ISC_R_UNEXPECTED);
}
result = ns_clientmgr_create(ns_g_mctx, ns_g_taskmgr, ns_g_timermgr,
&ns_g_clientmgr);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"ns_clientmgr_create() failed: %s\n",
isc_result_totext(result));
return (ISC_R_UNEXPECTED);
}
return (ISC_R_SUCCESS);
}
......@@ -230,7 +220,6 @@ destroy_managers(void) {
isc_taskmgr_destroy(&ns_g_taskmgr);
isc_timermgr_destroy(&ns_g_timermgr);
isc_socketmgr_destroy(&ns_g_socketmgr);
ns_clientmgr_destroy(&ns_g_clientmgr);
}
static void
......
......@@ -59,6 +59,7 @@
#include <dns/tsig.h>
#include <dns/tkey.h>
#include <named/client.h>
#include <named/globals.h>
#include <named/interfacemgr.h>
#include <named/listenlist.h>
......@@ -363,7 +364,8 @@ load_zone(dns_c_ctx_t *ctx, dns_c_zone_t *czone, dns_c_view_t *cview,
if (result != DNS_R_SUCCESS)
goto cleanup;
result = dns_zonemgr_managezone(ns_g_zonemgr, zone);
result = dns_zonemgr_managezone(ns_g_server->zonemgr,
zone);
if (result != DNS_R_SUCCESS)
goto cleanup;
}
......@@ -562,7 +564,7 @@ load_configuration(const char *filename, ns_server_t *server) {
* so that we know when we need to force AXFR of
* slave zones whose master files are missing.
*/
dns_zonemgr_forcemaint(ns_g_zonemgr);
dns_zonemgr_forcemaint(server->zonemgr);
/*
* Put the configuration into production.
......@@ -625,11 +627,33 @@ load_configuration(const char *filename, ns_server_t *server) {
static void
run_server(isc_task_t *task, isc_event_t *event) {
isc_result_t result;
ns_server_t *server = (ns_server_t *) event->arg;
(void)task;
isc_event_free(&event);
result = ns_clientmgr_create(ns_g_mctx, ns_g_taskmgr, ns_g_timermgr,
&server->clientmgr);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"ns_clientmgr_create() failed: %s\n",
isc_result_totext(result));
/* XXX cleanup */
return;
}
result = ns_interfacemgr_create(ns_g_mctx, ns_g_taskmgr,
ns_g_socketmgr, server->clientmgr,
&server->interfacemgr);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"ns_interfacemgr_create() failed: %s",
isc_result_totext(result));
/* XXX cleanup */
return;
}
load_configuration(ns_g_conffile, server);
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,
......@@ -661,9 +685,10 @@ shutdown_server(isc_task_t *task, isc_event_t *event) {
dns_tkey_destroy();
dns_tsig_destroy();
ns_clientmgr_destroy(&server->clientmgr);
ns_interfacemgr_shutdown(server->interfacemgr);
ns_interfacemgr_detach(&server->interfacemgr);
dns_zonemgr_destroy(&ns_g_zonemgr);
dns_zonemgr_destroy(&server->zonemgr);
isc_task_detach(&server->task);
......@@ -697,22 +722,13 @@ ns_server_create(isc_mem_t *mctx, ns_server_t **serverp) {
RUNTIME_CHECK(result == ISC_R_SUCCESS);
/* Initialize server data structures. */
server->zonemgr = NULL;
server->clientmgr = NULL;
server->interfacemgr = NULL;
ISC_LIST_INIT(server->viewlist);
result = isc_rwlock_init(&server->viewlock, 0, 0);
RUNTIME_CHECK(result == ISC_R_SUCCESS);
server->interfacemgr = NULL;
result = ns_interfacemgr_create(ns_g_mctx, ns_g_taskmgr,
ns_g_socketmgr, ns_g_clientmgr,
&server->interfacemgr);
if (result != ISC_R_SUCCESS) {
UNEXPECTED_ERROR(__FILE__, __LINE__,
"ns_interfacemgr_create() failed: %s",
isc_result_totext(result));
/* XXX cleanup */
return (ISC_R_UNEXPECTED);
}
/*
* Setup the server task, which is responsible for coordinating
* startup and shutdown of the server.
......@@ -779,7 +795,7 @@ ns_server_setup(void) {
return (result);
result = dns_zonemgr_create(ns_g_mctx, ns_g_taskmgr, ns_g_timermgr,
ns_g_socketmgr, &ns_g_zonemgr);
ns_g_socketmgr, &ns_g_server->zonemgr);
if (result != ISC_R_SUCCESS)
return (result);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment