]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
[client] Don't exit right away if daemon unavailable
authorRay Strode <rstrode@redhat.com>
Mon, 25 Jan 2010 22:06:53 +0000 (17:06 -0500)
committerRay Strode <rstrode@redhat.com>
Tue, 26 Jan 2010 06:20:00 +0000 (01:20 -0500)
We're going to want to be able to carry on in some cases
even if the daemon isn't there.

src/client/ply-boot-client.c
src/client/plymouth.c

index 917a6199300c455214f2fe60389af8932437d6b8..fef7fb13e7d9ae5eb8da7ac22ae7e5e3177d4382 100644 (file)
@@ -466,16 +466,14 @@ ply_boot_client_queue_request (ply_boot_client_t                  *client,
                                ply_boot_client_response_handler_t  failed_handler,
                                void                               *user_data)
 {
-  ply_boot_client_request_t *request;
-
   assert (client != NULL);
   assert (client->loop != NULL);
-  assert (client->socket_fd >= 0);
   assert (request_command != NULL);
   assert (request_argument == NULL || strlen (request_argument) <= UCHAR_MAX);
   assert (handler != NULL);
 
-  if (client->daemon_can_take_request_watch == NULL)
+  if (client->daemon_can_take_request_watch == NULL &&
+      client->socket_fd >= 0)
     {
       assert (ply_list_get_length (client->requests_to_send) == 0);
       client->daemon_can_take_request_watch = 
@@ -486,10 +484,22 @@ ply_boot_client_queue_request (ply_boot_client_t                  *client,
                                    NULL, client);
     }
 
-  request = ply_boot_client_request_new (client, request_command,
-                                         request_argument, 
-                                         handler, failed_handler, user_data);
-  ply_list_append_data (client->requests_to_send, request);
+  if (!client->is_connected)
+    {
+      if (failed_handler != NULL)
+        {
+          failed_handler (user_data, client);
+        }
+    }
+  else
+    {
+      ply_boot_client_request_t *request;
+
+      request = ply_boot_client_request_new (client, request_command,
+                                             request_argument,
+                                             handler, failed_handler, user_data);
+      ply_list_append_data (client->requests_to_send, request);
+    }
 }
 
 void
@@ -748,15 +758,17 @@ ply_boot_client_attach_to_event_loop (ply_boot_client_t *client,
   assert (client != NULL);
   assert (loop != NULL);
   assert (client->loop == NULL);
-  assert (client->socket_fd >= 0);
 
   client->loop = loop;
 
-  ply_event_loop_watch_fd (client->loop, client->socket_fd,
-                           PLY_EVENT_LOOP_FD_STATUS_NONE,
-                           NULL, 
-                           (ply_event_handler_t) ply_boot_client_on_hangup,
-                           client);
+  if (client->socket_fd >= 0)
+    {
+      ply_event_loop_watch_fd (client->loop, client->socket_fd,
+                               PLY_EVENT_LOOP_FD_STATUS_NONE,
+                               NULL,
+                               (ply_event_handler_t) ply_boot_client_on_hangup,
+                               client);
+    }
 
   ply_event_loop_watch_for_exit (loop, (ply_event_loop_exit_handler_t) 
                                  ply_boot_client_detach_from_event_loop,
index aa20b3e893d487b718c562c14bba9fea7793f637..c00dddaea9cb9f4bbb663a443dbb56a610fbf2b8 100644 (file)
@@ -661,6 +661,7 @@ main (int    argc,
 {
   state_t state = { 0 };
   bool should_help, should_quit, should_ping, should_sysinit, should_ask_for_password, should_show_splash, should_hide_splash, should_wait, should_be_verbose, report_error, should_get_plugin_path;
+  bool is_connected;
   char *status, *chroot_dir, *ignore_keystroke;
   int exit_code;
 
@@ -823,24 +824,12 @@ main (int    argc,
       return 0;
     }
 
-  if (!ply_boot_client_connect (state.client,
-                                (ply_boot_client_disconnect_handler_t)
-                                on_disconnect, &state))
+  is_connected = ply_boot_client_connect (state.client,
+                                          (ply_boot_client_disconnect_handler_t)
+                                          on_disconnect, &state);
+  if (!is_connected && should_ping)
     {
-      if (should_ping)
-         return 1;
-
-#if 0
-      ply_save_errno ();
-
-      if (errno == ECONNREFUSED)
-        ply_error ("error: boot status daemon not running "
-                   "(use --ping to check ahead of time)");
-      else
-        ply_error ("could not connect to boot status daemon: %m");
-      ply_restore_errno ();
-#endif
-      return errno;
+      return 1;
     }
 
   ply_boot_client_attach_to_event_loop (state.client, state.loop);