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

made server cleanup be more like a mirror image of

the server setup, to ensure that the server object is not destroyed
while still being used
parent c398950a
......@@ -64,9 +64,14 @@ ns_server_destroy(ns_server_t **serverp);
* Destroy a server object, freeing its memory.
*/
isc_result_t ns_server_init(void);
isc_result_t ns_server_setup(void);
/*
* Create the singleton names server object of BIND 9.
* Perform global server setup.
*/
void ns_server_cleanup(void);
/*
* Perform global server cleanup
*/
void
......
......@@ -250,7 +250,7 @@ setup() {
ns_main_earlyfatal("create_managers() failed: %s",
isc_result_totext(result));
result = ns_server_init();
result = ns_server_setup();
if (result != ISC_R_SUCCESS)
ns_main_earlyfatal("ns_server_init() failed: %s",
isc_result_totext(result));
......@@ -259,6 +259,7 @@ setup() {
static void
cleanup() {
destroy_managers();
ns_server_cleanup();
isc_log_write(ns_g_lctx, NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_MAIN,
ISC_LOG_NOTICE, "exiting");
ns_log_shutdown();
......
......@@ -612,18 +612,16 @@ shutdown_server(isc_task_t *task, isc_event_t *event) {
dns_view_detach(&view);
}
dns_tkey_destroy();
dns_tsig_destroy();
RWUNLOCK(&server->viewlock, isc_rwlocktype_write);
isc_task_detach(&server_task);
dns_tkey_destroy();
dns_tsig_destroy();
ns_interfacemgr_shutdown(server->interfacemgr);
ns_interfacemgr_detach(&server->interfacemgr);
dns_zonemgr_destroy(&ns_g_zonemgr);
ns_rootns_destroy();
ns_server_destroy(&server);
isc_task_detach(&server_task);
isc_event_free(&event);
}
......@@ -677,13 +675,6 @@ ns_server_destroy(ns_server_t **serverp) {
ns_server_t *server = *serverp;
REQUIRE(NS_SERVER_VALID(server));
/*
* The interface manager owns tasks, so we have to destroy it before
* we destroy the task manager.
*/
ns_interfacemgr_shutdown(server->interfacemgr);
ns_interfacemgr_detach(&server->interfacemgr);
INSIST(ISC_LIST_EMPTY(server->viewlist));
isc_rwlock_destroy(&server->viewlock);
......@@ -703,7 +694,7 @@ ns_server_destroy(ns_server_t **serverp) {
}
isc_result_t
ns_server_init() {
ns_server_setup(void) {
isc_result_t result;
/*
......@@ -751,6 +742,13 @@ ns_server_init() {
return (result);
}
void
ns_server_cleanup(void)
{
ns_rootns_destroy();
ns_server_destroy(&ns_g_server);
}
void
ns_server_fatal(isc_logmodule_t *module, isc_boolean_t want_core,
const char *format, ...)
......
......@@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: xfrout.c,v 1.34 2000/01/11 21:18:21 gson Exp $ */
/* $Id: xfrout.c,v 1.35 2000/01/12 01:17:26 gson Exp $ */
#include <config.h>
......@@ -1045,6 +1045,7 @@ xfrout_ctx_create(isc_mem_t *mctx, ns_client_t *client, unsigned int id,
return (DNS_R_NOMEMORY);
xfr->mctx = mctx;
xfr->client = client;
ns_client_wait(client);
xfr->id = id;
xfr->qname = qname;
xfr->qtype = qtype;
......@@ -1372,6 +1373,8 @@ xfrout_ctx_destroy(xfrout_ctx_t **xfrp) {
if (xfr->db != NULL)
dns_db_detach(&xfr->db);
ns_client_unwait(xfr->client);
isc_mem_put(xfr->mctx, xfr, sizeof(*xfr));
*xfrp = NULL;
......
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