Navigation Menu

Skip to content

Commit

Permalink
[usb-moded] Do not force appsync stop during bootup. MER#1694
Browse files Browse the repository at this point in the history
Starting/stopping appsync related systemd units is relatively expensive
task to perform and can cause timing problems during bootup.

As we know the appsync processes have not been started when device is
booting up, we can skip the explicit stopping when usb-moded is started
as part of bootup sequence.

Also, when usb-moded is exiting, it should be enough to stop only those
units that have been started by usb-moded.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Nov 7, 2016
1 parent 99f2413 commit 9b04af2
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/usb_moded.c
Expand Up @@ -124,6 +124,7 @@ static gboolean set_disconnected_silent(gpointer data);
static void usb_moded_init(void);
static gboolean charging_fallback(gpointer data);
static void usage(void);
static bool init_done_p(void);

/* ============= Implementation starts here =========================================== */
/** set the usb connection status
Expand Down Expand Up @@ -623,8 +624,19 @@ static void usb_moded_init(void)

#ifdef APP_SYNC
readlist(diag_mode);
/* make sure all services are down when starting */
appsync_stop(TRUE);
/* If usb-moded happens to crash, it could leave appsync processes
* running. To make sure things are in the order expected by usb-moded
* force stopping of appsync processes during usb-moded startup.
*
* The exception is: When usb-moded starts as a part of bootup. Then
* we can be relatively sure that usb-moded has not been running yet
* and therefore no appsync processes have been started and we can
* skip the blocking ipc required to stop the appsync systemd units. */
if( init_done_p() )
{
log_warning("usb-moded started after init-done; forcing appsync stop");
appsync_stop(TRUE);
}
#endif /* APP_SYNC */

/* always read dyn modes even if appsync is not used */
Expand Down Expand Up @@ -673,7 +685,10 @@ static gboolean charging_fallback(gpointer data)
static void handle_exit(void)
{
/* exiting and clean-up when mainloop ended */
appsync_stop(TRUE);

/* Stop appsync processes that have been started by usb-moded */
appsync_stop(FALSE);

hwal_cleanup();
usb_moded_dbus_cleanup();
#ifdef MEEGOLOCK
Expand Down

0 comments on commit 9b04af2

Please sign in to comment.