Freeup main module after module states.

git-svn-id: file:///svn/unbound/trunk@407 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2007-06-20 13:17:07 +00:00
parent cc9c205d88
commit 133b65bc67
2 changed files with 21 additions and 19 deletions

View file

@ -125,6 +125,7 @@ daemon_init()
signal_handling_record();
checklock_start();
daemon->need_to_exit = 0;
daemon->num_modules = 0;
if(!(daemon->env = (struct module_env*)calloc(1,
sizeof(*daemon->env)))) {
free(daemon);
@ -147,6 +148,22 @@ daemon_open_shared_ports(struct daemon* daemon)
return 1;
}
/**
* Desetup the modules, deinit, delete.
* @param daemon: the daemon.
*/
static void
daemon_desetup_modules(struct daemon* daemon)
{
int i;
for(i=0; i<daemon->num_modules; i++) {
(*daemon->modfunc[i]->deinit)(daemon->env, i);
}
daemon->num_modules = 0;
free(daemon->modfunc);
daemon->modfunc = 0;
}
/**
* Setup modules. Assigns ids and calls module_init.
* @param daemon: the daemon
@ -154,6 +171,8 @@ daemon_open_shared_ports(struct daemon* daemon)
static void daemon_setup_modules(struct daemon* daemon)
{
int i;
if(daemon->num_modules != 0)
daemon_desetup_modules(daemon);
/* fixed setup of the modules */
daemon->num_modules = 1;
daemon->modfunc = (struct module_func_block**)calloc((size_t)
@ -290,22 +309,6 @@ daemon_stop_others(struct daemon* daemon)
}
}
/**
* Desetup the modules, deinit, delete.
* @param daemon: the daemon.
*/
static void
daemon_desetup_modules(struct daemon* daemon)
{
int i;
for(i=0; i<daemon->num_modules; i++) {
(*daemon->modfunc[i]->deinit)(daemon->env, i);
}
daemon->num_modules = 0;
free(daemon->modfunc);
daemon->modfunc = 0;
}
void
daemon_fork(struct daemon* daemon)
{
@ -339,9 +342,6 @@ daemon_fork(struct daemon* daemon)
/* we exited! a signal happened! Stop other threads */
daemon_stop_others(daemon);
/* de-setup modules */
daemon_desetup_modules(daemon);
if(daemon->workers[0]->need_to_restart)
daemon->need_to_exit = 0;
else daemon->need_to_exit = 1;
@ -369,6 +369,7 @@ daemon_delete(struct daemon* daemon)
{
if(!daemon)
return;
daemon_desetup_modules(daemon);
listening_ports_free(daemon->ports);
if(daemon->env) {
slabhash_delete(daemon->env->msg_cache);

View file

@ -6,6 +6,7 @@
- set num target queries to 0 when you move them to slumber list.
- typo in check caused subquery errors to be ignored, fixed.
- make lint happy about rlim_t.
- freeup of modules after freeup of module-states.
19 June 2007: Wouter
- nicer layout in stats.c, review 0.3 change.