]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
afs: Allow database switching on sighup.
authorAndre Noll <maan@tuebingen.mpg.de>
Wed, 3 Jan 2018 01:49:22 +0000 (02:49 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Tue, 13 Mar 2018 02:28:57 +0000 (03:28 +0100)
Currently the database dir is set at startup and stays unmodified even
after the sighup handler has reloaded a configuration which specifies
a different database path.

This patch makes it possible to switch to a different database after
SIGHUP was received. To make this work, we only have invalidate the
database_dir pointer after the database has been closed.

afs.c

diff --git a/afs.c b/afs.c
index bad8b8dcf94a2078e764720f415790a64a260680..00143799c1c729cfd6fb744a204b46a76e2fee3e 100644 (file)
--- a/afs.c
+++ b/afs.c
@@ -638,16 +638,18 @@ static int setup_command_socket_or_die(void)
        return socket_fd;
 }
 
        return socket_fd;
 }
 
+static char *database_dir;
+
 static void close_afs_tables(void)
 {
        int i;
        PARA_NOTICE_LOG("closing afs_tables\n");
        for (i = 0; i < NUM_AFS_TABLES; i++)
                afs_tables[i].close();
 static void close_afs_tables(void)
 {
        int i;
        PARA_NOTICE_LOG("closing afs_tables\n");
        for (i = 0; i < NUM_AFS_TABLES; i++)
                afs_tables[i].close();
+       free(database_dir);
+       database_dir = NULL;
 }
 
 }
 
-static char *database_dir;
-
 static void get_database_dir(void)
 {
        if (!database_dir) {
 static void get_database_dir(void)
 {
        if (!database_dir) {
@@ -1022,6 +1024,7 @@ static int com_init_callback(struct afs_callback_arg *aca)
        int i, ret;
 
        close_afs_tables();
        int i, ret;
 
        close_afs_tables();
+       get_database_dir();
        for (i = 0; i < NUM_AFS_TABLES; i++) {
                struct afs_table *t = &afs_tables[i];
 
        for (i = 0; i < NUM_AFS_TABLES; i++) {
                struct afs_table *t = &afs_tables[i];