]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
client: Don't wait forever for a ping reply
authorBrian Murray <brian.murray@ubuntu.com>
Mon, 26 Oct 2020 19:13:20 +0000 (20:13 +0100)
committerRay Strode <rstrode@redhat.com>
Wed, 28 Oct 2020 14:07:27 +0000 (10:07 -0400)
In the event that plymouthd is not responding the plymouth client will
wait forever when sending a ping to the daemon.

This commit introduces a timeout of 30 seconds to better cope with a
hung plymouthd process.

(Some small changes to original patch by Ray Strode)

https://gitlab.freedesktop.org/plymouth/plymouth/-/issues/130

src/client/plymouth.c

index be74ae7bd43f12715503071ed0f05753bb178168..304ea8e23fcc66ed3a6c387eb56c5782158e5bb4 100644 (file)
 #define PLY_MAX_COMMAND_LINE_SIZE 4097
 #endif
 
+
+#ifndef PLY_PING_TIMEOUT
+#define PLY_PING_TIMEOUT 30.0
+#endif
+
+
 #define KEY_CTRL_C ('\100' ^ 'C')
 
 typedef struct
@@ -75,6 +81,13 @@ typedef struct
         char    *keys;
 } key_answer_state_t;
 
+static void
+on_ping_timeout (state_t *state)
+{
+        ply_trace ("ping: timed out waiting for plymouthd");
+        ply_event_loop_exit (state->loop, 1);
+}
+
 static char **
 split_string (const char *command,
               const char  delimiter)
@@ -1145,6 +1158,9 @@ main (int    argc,
                                              on_success,
                                              (ply_boot_client_response_handler_t)
                                              on_failure, &state);
+                ply_event_loop_watch_for_timeout (state.loop, PLY_PING_TIMEOUT,
+                                                  (ply_event_loop_timeout_handler_t)
+                                                  on_ping_timeout, &state);
         } else if (should_check_for_active_vt) {
                 ply_boot_client_ask_daemon_has_active_vt (state.client,
                                                           (ply_boot_client_response_handler_t)