Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'mer1678_end_rescue_mode' into 'master'
Disable rescue mode when/if init done is reached



See merge request !16
  • Loading branch information
spiiroin committed Oct 18, 2016
2 parents 8714bf4 + a53740d commit 91ceea3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/usb_moded-dbus.c
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand Down
16 changes: 16 additions & 0 deletions src/usb_moded.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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() )
Expand Down

0 comments on commit 91ceea3

Please sign in to comment.