From: Andre Noll Date: Thu, 13 Mar 2014 08:41:44 +0000 (+0100) Subject: gui: Improve config reload. X-Git-Tag: v0.5.3~12^2~19 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=4207df0cbc1fcaa2ddb76febf82f25a23a0fb62d;p=paraslash.git gui: Improve config reload. 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(). --- diff --git a/gui.c b/gui.c index e53d5c73..a20750f7 100644 --- 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)