]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
server: Deplete user list on exit.
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 22 Oct 2017 12:46:16 +0000 (14:46 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Tue, 13 Mar 2018 02:28:56 +0000 (03:28 +0100)
This eliminates a bunch of valgrind memory leak warnings when
run with --leak-check=full --show-leak-kinds=all.

server.c
user_list.c
user_list.h

index 20019ef60b950f635d3a9e789d132ab1dbed7691..8b13d35b423cfac49e18e433aa31af09db4b4ad4 100644 (file)
--- a/server.c
+++ b/server.c
@@ -684,6 +684,7 @@ int main(int argc, char *argv[])
        }
        vss_shutdown();
        shm_detach(mmd);
        }
        vss_shutdown();
        shm_detach(mmd);
+       user_list_deplete();
        lls_free_parse_result(server_lpr, CMD_PTR);
        if (server_lpr != cmdline_lpr)
                lls_free_parse_result(cmdline_lpr, CMD_PTR);
        lls_free_parse_result(server_lpr, CMD_PTR);
        if (server_lpr != cmdline_lpr)
                lls_free_parse_result(cmdline_lpr, CMD_PTR);
index a2b494936f3e8f4138b98c26e181d24638a29b04..18b489b9e4c615824822feb801e3820df63ef554 100644 (file)
@@ -39,6 +39,24 @@ again:
        goto again;
 }
 
        goto again;
 }
 
+/**
+ * Remove all entries from the user list.
+ *
+ * This is called on shutdown and when the user list is reloaded because the
+ * server received SIGHUP.
+ */
+void user_list_deplete(void)
+{
+       struct user *u, *tmpu;
+
+       list_for_each_entry_safe(u, tmpu, &user_list, node) {
+               list_del(&u->node);
+               free(u->name);
+               free_public_key(u->pubkey);
+               free(u);
+       }
+}
+
 /**
  * Initialize the list of users allowed to connect to para_server.
  *
 /**
  * Initialize the list of users allowed to connect to para_server.
  *
@@ -53,17 +71,12 @@ void user_list_init(char *user_list_file)
 {
        int ret = -E_USERLIST;
        FILE *file_ptr = fopen(user_list_file, "r");
 {
        int ret = -E_USERLIST;
        FILE *file_ptr = fopen(user_list_file, "r");
-       struct user *u, *tmpu;
+       struct user *u;
 
        if (!file_ptr)
                goto err;
 
 
        if (!file_ptr)
                goto err;
 
-       list_for_each_entry_safe(u, tmpu, &user_list, node) {
-               list_del(&u->node);
-               free(u->name);
-               free_public_key(u->pubkey);
-               free(u);
-       }
+       user_list_deplete();
        for (;;) {
                int num;
                char line[255];
        for (;;) {
                int num;
                char line[255];
index 3ef62170aa722fc38f9accb4d0dba6ff268dc485..3bc98f687b12364a671da05c1629b39fdea7a8c3 100644 (file)
@@ -33,4 +33,5 @@ struct user {
 };
 
 void user_list_init(char *user_list_file);
 };
 
 void user_list_init(char *user_list_file);
+void user_list_deplete(void);
 const struct user *user_list_lookup(const char *name);
 const struct user *user_list_lookup(const char *name);