]> git.tue.mpg.de Git - paraslash.git/commitdiff
gui: Move signal handling code out of do_select().
authorAndre Noll <maan@systemlinux.org>
Fri, 3 Jan 2014 19:03:22 +0000 (19:03 +0000)
committerAndre Noll <maan@systemlinux.org>
Sun, 4 May 2014 13:48:54 +0000 (15:48 +0200)
As a further preparation for employing the standard paraslash scheduler
within para_gui, this simple patch introduces signal_pre_select()
and renames handle_signal() to signal_post_select().

The signal related part of do_select() is moved to these two functions
so that do_select() is reduced to the bare minimum: one call to each
of the two new functions.

gui.c

diff --git a/gui.c b/gui.c
index ae585b8b3434d6253cc382cf310a3b2560de5ef4..70981e898ba7de929d56a8ee448cbbeff10040c3 100644 (file)
--- a/gui.c
+++ b/gui.c
@@ -916,9 +916,12 @@ static void reread_conf(void)
 /*
  * React to various signal-related events
  */
-static void handle_signal(int sig)
+static void signal_post_select(fd_set *rfds)
 {
-       switch (sig) {
+       int ret = para_next_signal(rfds);
+       if (ret <= 0)
+               return;
+       switch (ret) {
        case SIGTERM:
                die(EXIT_FAILURE, "only the good die young (caught SIGTERM)\n");
                return;
@@ -1063,6 +1066,11 @@ static int input_post_select(int mode)
        }
 }
 
+static void signal_pre_select(fd_set *rfds, int *max_fileno)
+{
+       para_fd_set(signal_pipe, rfds, max_fileno);
+}
+
 /*
  * This is the core select loop. Besides the (internal) signal
  * pipe, the following other fds are checked according to the mode:
@@ -1089,17 +1097,13 @@ repeat:
        FD_ZERO(&rfds);
        max_fileno = 0;
        status_pre_select(&rfds, &max_fileno, &tv);
-       /* signal pipe */
-       para_fd_set(signal_pipe, &rfds, &max_fileno);
+       signal_pre_select(&rfds, &max_fileno);
        command_pre_select(mode, &rfds, &max_fileno);
        input_pre_select(mode, &rfds, &max_fileno);
        ret = para_select(max_fileno + 1, &rfds, NULL, &tv);
        if (ret <= 0)
                goto check_return; /* skip fd checks */
-       /* signals */
-       ret = para_next_signal(&rfds);
-       if (ret > 0)
-               handle_signal(ret);
+       signal_post_select(&rfds);
        /* read command pipe if ready */
        ret = command_post_select(mode, &rfds);
        if (ret < 0)