]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
server: Free parse result also in afs.
authorAndre Noll <maan@tuebingen.mpg.de>
Mon, 1 Jan 2018 03:28:29 +0000 (04:28 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Tue, 13 Mar 2018 02:28:57 +0000 (03:28 +0100)
Both the server and the afs process need to access the lopsub parse
result which is allocated and initialized prior to the fork(2) that
creates the afs process. Hence both processes should free this memory
on exit.

The new public free_lpr() frees the memory allocated by both parse result
structures.

afs.c
server.c
server.h

diff --git a/afs.c b/afs.c
index d9aa3ce05ddd4e3135b2097c149f0eaf493a4d57..ced2e451bafe4534671bbdb492066f4beeb8e1bb 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -1007,6 +1007,7 @@ __noreturn void afs_init(int socket_fd)
 out_close:
        close_afs_tables();
 out:
 out_close:
        close_afs_tables();
 out:
+       free_lpr();
        if (ret < 0)
                PARA_EMERG_LOG("%s\n", para_strerror(-ret));
        exit(EXIT_FAILURE);
        if (ret < 0)
                PARA_EMERG_LOG("%s\n", para_strerror(-ret));
        exit(EXIT_FAILURE);
index e5335346010313277e258b3d2bb0a0c9f108fbfc..076bf4fabbf2b0900e759d5cf4fb1427fa18bc99 100644 (file)
--- a/server.c
+++ b/server.c
@@ -643,6 +643,21 @@ static int server_select(int max_fileno, fd_set *readfds, fd_set *writefds,
        return ret;
 }
 
        return ret;
 }
 
+/**
+ * Deallocate all lopsub parse results.
+ *
+ * The server allocates a parse result for command line options and optionally
+ * a second parse result for the effective configuration, defined by merging
+ * the command line options with the options stored in the configuration file.
+ * This function frees both structures.
+ */
+void free_lpr(void)
+{
+       lls_free_parse_result(server_lpr, CMD_PTR);
+       if (server_lpr != cmdline_lpr)
+               lls_free_parse_result(cmdline_lpr, CMD_PTR);
+}
+
 /**
  * The main function of para_server.
  *
 /**
  * The main function of para_server.
  *
@@ -686,8 +701,6 @@ int main(int argc, char *argv[])
        vss_shutdown();
        shm_detach(mmd);
        user_list_deplete();
        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);
+       free_lpr();
        exit(ret < 0? EXIT_FAILURE : EXIT_SUCCESS);
 }
        exit(ret < 0? EXIT_FAILURE : EXIT_SUCCESS);
 }
index 69d27054a82fa0347fb8774053711fca77605325..d56da7eb0db8d74c78e139484653e84e51ba684e 100644 (file)
--- a/server.h
+++ b/server.h
@@ -117,3 +117,4 @@ int handle_connect(int fd);
 void parse_config_or_die(bool reload);
 char *server_get_tasks(void);
 bool process_is_command_handler(void);
 void parse_config_or_die(bool reload);
 char *server_get_tasks(void);
 bool process_is_command_handler(void);
+void free_lpr(void);