Commit 91ceea33 authored by spiiroin's avatar spiiroin

Merge branch 'mer1678_end_rescue_mode' into 'master'

Disable rescue mode when/if init done is reached



See merge request !16
parents 8714bf4d a53740d6
......@@ -39,6 +39,10 @@
#include "usb_moded-network.h"
#include "usb_moded-log.h"
#define INIT_DONE_INTERFACE "com.nokia.startup.signal"
#define INIT_DONE_SIGNAL "init_done"
#define INIT_DONE_MATCH "type='signal',interface='"INIT_DONE_INTERFACE"',member='"INIT_DONE_SIGNAL"'"
static DBusConnection *dbus_connection_sys = NULL;
extern gboolean rescue_mode;
......@@ -129,6 +133,18 @@ static DBusHandlerResult msg_handler(DBusConnection *const connection, DBusMessa
if(!interface || !member || !object) goto EXIT;
if( type == DBUS_MESSAGE_TYPE_SIGNAL )
{
if( !strcmp(interface, INIT_DONE_INTERFACE) && !strcmp(member, INIT_DONE_SIGNAL) ) {
/* Auto-disable rescue mode when bootup is finished */
if( rescue_mode ) {
rescue_mode = FALSE;
log_debug("init done reached - rescue mode disabled");
}
}
goto EXIT;
}
if( type == DBUS_MESSAGE_TYPE_METHOD_CALL && !strcmp(interface, USB_MODE_INTERFACE) && !strcmp(object, USB_MODE_OBJECT))
{
status = DBUS_HANDLER_RESULT_HANDLED;
......@@ -403,6 +419,9 @@ gboolean usb_moded_dbus_init(void)
dbus_bus_add_match(dbus_connection_sys, USB_MODE_INTERFACE, &error);
*/
/* Listen to init-done signals */
dbus_bus_add_match(dbus_connection_sys, INIT_DONE_MATCH, 0);
dbus_threads_init_default();
/* Connect D-Bus to the mainloop */
......
......@@ -1052,6 +1052,16 @@ void delay_suspend(void)
allow_suspend_cb, 0);
}
/** Check if system has already been successfully booted up
*
* @return true if init-done has been reached, or false otherwise
*/
static bool init_done_p(void)
{
return access("/run/systemd/boot-status/init-done", F_OK) == 0;
}
int main(int argc, char* argv[])
{
int result = EXIT_FAILURE;
......@@ -1146,6 +1156,12 @@ int main(int argc, char* argv[])
#endif
mainloop = g_main_loop_new(NULL, FALSE);
if (rescue_mode && init_done_p())
{
rescue_mode = FALSE;
log_warning("init done passed; rescue mode ignored");
}
/* init daemon into a clean state first, then dbus and hw_abstraction last */
usb_moded_init();
if( !usb_moded_dbus_init() )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment