mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-10-14 02:22:03 +08:00
Try to release as much memory as possible to be able to detect real memory leaks.
This commit is contained in:
+8
-1
@@ -517,7 +517,7 @@ int cmd_parser (int argc, char **argv, struct cfg_st* config)
|
||||
}
|
||||
|
||||
#define DEL(x) free(x);x=NULL
|
||||
void reload_cfg_file(struct cfg_st* config)
|
||||
void clear_cfg_file(struct cfg_st* config)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
@@ -566,6 +566,13 @@ unsigned i;
|
||||
DEL(config->cert);
|
||||
DEL(config->network.routes);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void reload_cfg_file(struct cfg_st* config)
|
||||
{
|
||||
clear_cfg_file(config);
|
||||
|
||||
memset(config, 0, sizeof(*config));
|
||||
|
||||
parse_cfg_file(cfg_file, config);
|
||||
|
||||
@@ -216,11 +216,14 @@ static void toggle_watch(DBusWatch * watch, void *data)
|
||||
}
|
||||
}
|
||||
|
||||
#define OCSERV_DBUS_NAME "org.infradead.ocserv"
|
||||
|
||||
void ctl_handler_deinit(main_server_st * s)
|
||||
{
|
||||
if (s->ctl_ctx != NULL) {
|
||||
mslog(s, NULL, LOG_DEBUG, "closing DBUS connection");
|
||||
dbus_connection_close(s->ctl_ctx);
|
||||
dbus_bus_release_name(s->ctl_ctx, OCSERV_DBUS_NAME, NULL);
|
||||
dbus_connection_unref(s->ctl_ctx);
|
||||
}
|
||||
}
|
||||
@@ -239,7 +242,7 @@ int ctl_handler_init(main_server_st * s)
|
||||
if (conn == NULL)
|
||||
goto error;
|
||||
|
||||
ret = dbus_bus_request_name(conn, "org.infradead.ocserv",
|
||||
ret = dbus_bus_request_name(conn, OCSERV_DBUS_NAME,
|
||||
DBUS_NAME_FLAG_REPLACE_EXISTING, &err);
|
||||
if (ret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
|
||||
goto error;
|
||||
|
||||
+7
-1
@@ -717,7 +717,6 @@ unsigned total = 10;
|
||||
|
||||
if (terminate != 0) {
|
||||
mslog(s, NULL, LOG_DEBUG, "termination request received; waiting for children to die");
|
||||
ctl_handler_deinit(s);
|
||||
kill_children(s);
|
||||
while (waitpid(-1, NULL, WNOHANG) == 0) {
|
||||
if (total == 0) {
|
||||
@@ -729,6 +728,13 @@ unsigned total = 10;
|
||||
}
|
||||
remove(s->socket_file);
|
||||
remove_pid_file();
|
||||
|
||||
/* try to clean-up everything allocated to ease checks
|
||||
* for memory leaks.
|
||||
*/
|
||||
clear_lists(s);
|
||||
tls_global_deinit(s);
|
||||
clear_cfg_file(s->config);
|
||||
closelog();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
int cmd_parser (int argc, char **argv, struct cfg_st* config);
|
||||
void reload_cfg_file(struct cfg_st* config);
|
||||
void clear_cfg_file(struct cfg_st* config);
|
||||
void write_pid_file(void);
|
||||
void remove_pid_file(void);
|
||||
|
||||
|
||||
@@ -189,6 +189,7 @@ struct htable_iter iter;
|
||||
}
|
||||
htable_clear(&db->ht);
|
||||
db->entries = 0;
|
||||
free(db);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -279,6 +280,18 @@ int ret;
|
||||
return;
|
||||
}
|
||||
|
||||
void tls_global_deinit(main_server_st* s)
|
||||
{
|
||||
if (s->creds.xcred != NULL)
|
||||
gnutls_certificate_free_credentials(s->creds.xcred);
|
||||
if (s->creds.cprio != NULL)
|
||||
gnutls_priority_deinit(s->creds.cprio);
|
||||
|
||||
gnutls_global_deinit();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Checks, if there is a single certificate specified, whether it
|
||||
* is compatible with all ciphersuites */
|
||||
static void certificate_check(main_server_st *s)
|
||||
|
||||
@@ -41,6 +41,7 @@ void tls_cork(gnutls_session_t session);
|
||||
int tls_uncork(gnutls_session_t session);
|
||||
|
||||
void tls_global_init(struct main_server_st* s);
|
||||
void tls_global_deinit(struct main_server_st* s);
|
||||
void tls_global_init_certs(struct main_server_st* s);
|
||||
|
||||
ssize_t tls_send_file(gnutls_session_t session, const char *file);
|
||||
|
||||
Reference in New Issue
Block a user