gui: Improve config reload.
authorAndre Noll <maan@systemlinux.org>
Thu, 13 Mar 2014 08:41:44 +0000 (09:41 +0100)
committerAndre Noll <maan@systemlinux.org>
Sun, 4 May 2014 13:48:54 +0000 (15:48 +0200)
There are two ways to make para_gui reload its config file: Sending
SIGUSR1 and running the internal reread_conf command. When SIGUSR1
is received, signal_post_select() calls com_reread_conf(). This is
a layer violation since command handlers should only be called from
the input task.

This patch provides the generic function reread_conf() which is called
from both the command handler and from signal_post_select().

gui.c

diff --git a/gui.c b/gui.c
index e53d5c73e41e7f665e4d14bb65d4113216a295ba..a20750f7f300800b7255b32a50120a0526b1ff58 100644 (file)
--- a/gui.c
+++ b/gui.c
@@ -893,6 +893,19 @@ out:
                exit(EXIT_FAILURE);
 }
 
+/* reread configuration, terminate on errors */
+static void reread_conf(void)
+{
+       /*
+        * gengetopt might print to stderr and exit on errors. So we have to
+        * shutdown curses first.
+        */
+       shutdown_curses();
+       parse_config_file_or_die(true /* override */);
+       init_curses();
+       print_in_bar(COLOR_MSG, "config file reloaded\n");
+}
+
 /*
  * React to various signal-related events
  */
@@ -917,7 +930,7 @@ static void handle_signal(int sig)
                return;
        case SIGUSR1:
                PARA_NOTICE_LOG("got SIGUSR1, rereading configuration\n");
-               com_reread_conf();
+               reread_conf();
                return;
        case SIGCHLD:
                check_sigchld();
@@ -1296,19 +1309,9 @@ static void com_ll_incr(void)
        print_in_bar(COLOR_MSG, "loglevel set to %d\n", loglevel);
 }
 
-/*
- * reread configuration, terminate on errors
- */
 static void com_reread_conf(void)
 {
-       /*
-        * gengetopt might print to stderr and exit on errors. So we have to
-        * shutdown curses first.
-        */
-       shutdown_curses();
-       parse_config_file_or_die(true /* override */);
-       init_curses();
-       print_in_bar(COLOR_MSG, "config file reloaded\n");
+       reread_conf();
 }
 
 static void com_help(void)