Commit 70de5614 authored by Sebastien Decugis's avatar Sebastien Decugis
Browse files

Forgot to cleanup the configuration on exit, spotted by valgrind

parent 0dd1cb81
......@@ -135,3 +135,18 @@ int fd_app_check_common(struct fd_list * list1, struct fd_list * list2, int * co
*common_found = 0;
return 0;
}
/* Remove the apps from a list */
int fd_app_empty(struct fd_list * list)
{
TRACE_ENTRY("%p", list);
CHECK_PARAMS( list );
while (!FD_IS_LIST_EMPTY(list)) {
struct fd_list * li = list->next;
fd_list_unlink(li);
free(li);
}
return 0;
}
......@@ -270,3 +270,39 @@ int fd_conf_parse()
return 0;
}
/* Destroy contents of fd_g_config structure */
int fd_conf_deinit()
{
TRACE_ENTRY();
/* Free the TLS parameters */
gnutls_priority_deinit(fd_g_config->cnf_sec_data.prio_cache);
gnutls_dh_params_deinit(fd_g_config->cnf_sec_data.dh_cache);
gnutls_certificate_free_credentials(fd_g_config->cnf_sec_data.credentials);
free(fd_g_config->cnf_sec_data.cert_file); fd_g_config->cnf_sec_data.cert_file = NULL;
free(fd_g_config->cnf_sec_data.key_file); fd_g_config->cnf_sec_data.key_file = NULL;
free(fd_g_config->cnf_sec_data.ca_file); fd_g_config->cnf_sec_data.ca_file = NULL;
free(fd_g_config->cnf_sec_data.crl_file); fd_g_config->cnf_sec_data.crl_file = NULL;
free(fd_g_config->cnf_sec_data.prio_string); fd_g_config->cnf_sec_data.prio_string = NULL;
/* Destroy dictionary */
CHECK_FCT_DO( fd_dict_fini(&fd_g_config->cnf_dict), );
/* Destroy the main event queue */
CHECK_FCT_DO( fd_fifo_del(&fd_g_config->cnf_main_ev), );
/* Destroy the local endpoints and applications */
CHECK_FCT_DO(fd_ep_filter(&fd_g_config->cnf_endpoints, 0 ), );
CHECK_FCT_DO(fd_app_empty(&fd_g_config->cnf_apps ), );
/* Destroy the local identity */
free(fd_g_config->cnf_diamid); fd_g_config->cnf_diamid = NULL;
free(fd_g_config->cnf_diamrlm); fd_g_config->cnf_diamrlm = NULL;
return 0;
}
......@@ -79,6 +79,7 @@
/* Configuration */
int fd_conf_init();
int fd_conf_deinit();
void fd_conf_dump();
int fd_conf_parse();
int fddparse(struct fd_config * conf); /* yacc generated */
......
......@@ -169,6 +169,8 @@ end:
GNUTLS_TRACE( gnutls_global_deinit() );
CHECK_FCT_DO( fd_conf_deinit(), );
fd_log_debug(FD_PROJECT_BINARY " daemon is terminated.\n");
fd_lib_fini();
......
......@@ -725,5 +725,6 @@ struct fd_app {
int fd_app_merge(struct fd_list * list, application_id_t aid, vendor_id_t vid, int auth, int acct);
int fd_app_check(struct fd_list * list, application_id_t aid, struct fd_app **detail);
int fd_app_check_common(struct fd_list * list1, struct fd_list * list2, int * common_found);
int fd_app_empty(struct fd_list * list);
#endif /* _FREEDIAMETER_H */
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