From: Ray Strode Date: Mon, 25 Jan 2010 22:06:53 +0000 (-0500) Subject: [client] Don't exit right away if daemon unavailable X-Git-Tag: 0.8.0~73 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6a9c53419527e88edef1e2a1ed9347a16cd4f59b;p=thirdparty%2Fplymouth.git [client] Don't exit right away if daemon unavailable We're going to want to be able to carry on in some cases even if the daemon isn't there. --- diff --git a/src/client/ply-boot-client.c b/src/client/ply-boot-client.c index 917a6199..fef7fb13 100644 --- a/src/client/ply-boot-client.c +++ b/src/client/ply-boot-client.c @@ -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, diff --git a/src/client/plymouth.c b/src/client/plymouth.c index aa20b3e8..c00dddae 100644 --- a/src/client/plymouth.c +++ b/src/client/plymouth.c @@ -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);