From: Florent Bruneau Date: Sat, 4 Oct 2008 07:36:42 +0000 (+0200) Subject: Ensure config is properly unloaded. X-Git-Url: http://git.madism.org/?a=commitdiff_plain;h=4cc3c542c668521aef91f06f5bdff1c73643b646;p=apps%2Fpfixtools.git Ensure config is properly unloaded. Signed-off-by: Florent Bruneau --- diff --git a/postlicyd/config.c b/postlicyd/config.c index d1e4d83..d4131f1 100644 --- a/postlicyd/config.c +++ b/postlicyd/config.c @@ -77,9 +77,13 @@ config_param_register("verify_filter"); */ config_param_register("port"); + +static config_t *global_config = NULL; + static inline config_t *config_new(void) { config_t *config = p_new(config_t, 1); + global_config = config; return config; } @@ -97,9 +101,17 @@ void config_delete(config_t **config) if (*config) { config_close(*config); p_delete(config); + global_config = NULL; } } +static void config_exit() +{ + if (global_config) { + config_delete(&global_config); + } +} +module_exit(config_exit); static bool config_second_pass(config_t *config) { diff --git a/postlicyd/main-postlicyd.c b/postlicyd/main-postlicyd.c index 07fe1de..1f286eb 100644 --- a/postlicyd/main-postlicyd.c +++ b/postlicyd/main-postlicyd.c @@ -219,12 +219,9 @@ int main(int argc, char *argv[]) if (common_setup(pidfile, true, NULL, NULL, daemonize) != EXIT_SUCCESS || start_listener(config->port) < 0) { - config_delete(&config); return EXIT_FAILURE; } else { - int res = server_loop(query_starter, (delete_client_t)query_delete, - policy_run, config_refresh, config); - config_delete(&config); - return res; + return server_loop(query_starter, (delete_client_t)query_delete, + policy_run, config_refresh, config); } }