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 =
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
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,
{
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;
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);