Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'jb45312_sighup_corruption' into 'master'
Fix data corruption after SIGHUP config reload

See merge request mer-core/usb-moded!48
  • Loading branch information
spiiroin committed Apr 9, 2019
2 parents b6f0fda + 8a6390e commit 42eb1ed
Show file tree
Hide file tree
Showing 49 changed files with 873 additions and 438 deletions.
22 changes: 18 additions & 4 deletions Makefile.custom
Expand Up @@ -316,10 +316,24 @@ endif
# ----------------------------------------------------------------------------

.SUFFIXES: .q .p .g

%.q : %.c ; $(CC) -o $@ -E $< $(CPPFLAGS) $(MCE_CFLAGS)
%.p : %.q ; cproto -s < $< | prettyproto.py > $@
%.g : %.q ; cproto < $< | prettyproto.py > $@
.PRECIOUS: .q

PROTO_CPPFLAGS += -DAPP_SYNC
PROTO_CPPFLAGS += -DAPP_SYNC_DBUS
PROTO_CPPFLAGS += -DCONNMAN
PROTO_CPPFLAGS += -DDEAD_CODE
PROTO_CPPFLAGS += -DDEBIAN
PROTO_CPPFLAGS += -DMEEGOLOCK
PROTO_CPPFLAGS += -DOFONO
PROTO_CPPFLAGS += -DSYSTEMD
PROTO_CPPFLAGS += -DUSE_MER_SSU
PROTO_CPPFLAGS += -DCONNMAN_WORKS_BETTER=1
PROTO_CPPFLAGS += -DVERBOSE_WAKELOCKING=1

%.q : CPPFLAGS += $(PROTO_CPPFLAGS)
%.q : %.c ; $(CC) -o $@ -E $< $(CPPFLAGS) -O
%.p : %.q prettyproto.groups ; cproto -s < $< | prettyproto.py > $@
%.g : %.q prettyproto.groups ; cproto < $< | prettyproto.py > $@

clean::
$(RM) *.[qpg] src/*.[qpg] utils/*.[qpg]
Expand Down
9 changes: 6 additions & 3 deletions src/usb_moded-android.c
@@ -1,7 +1,7 @@
/**
* @file usb_moded-android.c
*
* Copyright (C) 2013-2018 Jolla. All rights reserved.
* Copyright (C) 2013-2019 Jolla. All rights reserved.
*
* @author: Philippe De Swert <philippe.deswert@jollamobile.com>
* @author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
Expand Down Expand Up @@ -34,11 +34,14 @@
#include <stdlib.h>

/* ========================================================================= *
* Functions
* Prototypes
* ========================================================================= */

/* -- android -- */
/* ------------------------------------------------------------------------- *
* ANDROID
* ------------------------------------------------------------------------- */

static bool android_write_file (const char *path, const char *text);
bool android_in_use (void);
static bool android_probe (void);
gchar *android_get_serial (void);
Expand Down
6 changes: 4 additions & 2 deletions src/usb_moded-android.h
@@ -1,7 +1,7 @@
/**
* @file usb_moded-android.h
*
* Copyright (C) 2013-2018 Jolla. All rights reserved.
* Copyright (C) 2013-2019 Jolla. All rights reserved.
*
* @author: Philippe De Swert <philippe.deswert@jollamobile.com>
* @author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
Expand Down Expand Up @@ -44,7 +44,9 @@
* Prototypes
* ========================================================================= */

/* -- android -- */
/* ------------------------------------------------------------------------- *
* ANDROID
* ------------------------------------------------------------------------- */

bool android_in_use (void);
gchar *android_get_serial (void);
Expand Down
6 changes: 4 additions & 2 deletions src/usb_moded-appsync-dbus-private.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 Nokia Corporation. All rights reserved.
* Copyright (C) 2018 Jolla Ltd.
* Copyright (C) 2018-2019 Jolla Ltd.
*
* Author: Philippe De Swert <philippe.de-swert@nokia.com>
* Author: Philippe De Swert <phdeswer@lumi.maa>
Expand Down Expand Up @@ -33,7 +33,9 @@
* Prototypes
* ========================================================================= */

/* -- dbusappsync -- */
/* ------------------------------------------------------------------------- *
* DBUSAPPSYNC
* ------------------------------------------------------------------------- */

gboolean dbusappsync_init_connection(void);
gboolean dbusappsync_init (void);
Expand Down
6 changes: 4 additions & 2 deletions src/usb_moded-appsync-dbus.c
Expand Up @@ -2,7 +2,7 @@
* @file usb_moded-dbus.c
*
* Copyright (C) 2010 Nokia Corporation. All rights reserved.
* Copyright (C) 2013-2018 Jolla Ltd.
* Copyright (C) 2013-2019 Jolla Ltd.
*
* @author: Philippe De Swert <philippe.de-swert@nokia.com>
* @author: Philippe De Swert <phdeswer@lumi.maa>
Expand Down Expand Up @@ -38,7 +38,9 @@
* Prototypes
* ========================================================================= */

/* -- dbusappsync -- */
/* ------------------------------------------------------------------------- *
* DBUSAPPSYNC
* ------------------------------------------------------------------------- */

static void dbusappsync_release_name (void);
static gboolean dbusappsync_obtain_name (void);
Expand Down
10 changes: 5 additions & 5 deletions src/usb_moded-appsync.c
Expand Up @@ -2,7 +2,7 @@
* @file usb_moded-appsync.c
*
* Copyright (C) 2010 Nokia Corporation. All rights reserved.
* Copyright (C) 2013-2018 Jolla Ltd.
* Copyright (C) 2013-2019 Jolla Ltd.
*
* @author: Philippe De Swert <philippe.de-swert@nokia.com>
* @author: Philippe De Swert <phdeswer@lumi.maa>
Expand Down Expand Up @@ -40,7 +40,9 @@
* Prototypes
* ========================================================================= */

/* -- appsync -- */
/* ------------------------------------------------------------------------- *
* APPSYNC
* ------------------------------------------------------------------------- */

static void appsync_free_elem (list_elem_t *elem);
static void appsync_free_elem_cb (gpointer elem, gpointer user_data);
Expand All @@ -51,14 +53,12 @@ static list_elem_t *appsync_read_file (const gchar *filenam
int appsync_activate_sync (const char *mode);
int appsync_activate_sync_post (const char *mode);
int appsync_mark_active (const gchar *name, int post);

#ifdef APP_SYNC_DBUS
static gboolean appsync_enumerate_usb_cb (gpointer data);
static void appsync_start_enumerate_usb_timer (void);
static void appsync_cancel_enumerate_usb_timer(void);
static void appsync_enumerate_usb (void);
#endif

#endif // APP_SYNC_DBUS
void appsync_stop_apps (int post);
int appsync_stop (gboolean force);

Expand Down
8 changes: 5 additions & 3 deletions src/usb_moded-appsync.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 Nokia Corporation. All rights reserved.
* Copyright (C) 2013-2018 Jolla Ltd.
* Copyright (C) 2013-2019 Jolla Ltd.
*
* author: Philippe De Swert <philippe.de-swert@nokia.com>
* author: Philippe De Swert <phdeswer@lumi.maa>
Expand Down Expand Up @@ -74,14 +74,16 @@ typedef struct list_elem_t
* Prototypes
* ========================================================================= */

/* -- appsync -- */
/* ------------------------------------------------------------------------- *
* APPSYNC
* ------------------------------------------------------------------------- */

void appsync_free_appsync_list (void);
void appsync_read_list (int diag);
int appsync_activate_sync (const char *mode);
int appsync_activate_sync_post(const char *mode);
int appsync_mark_active (const gchar *name, int post);
int appsync_stop (gboolean force);
void appsync_stop_apps (int post);
int appsync_stop (gboolean force);

#endif /* USB_MODED_APPSYNC_H_ */
41 changes: 31 additions & 10 deletions src/usb_moded-common.c
Expand Up @@ -35,11 +35,15 @@ typedef struct modemapping_t
* Prototypes
* ========================================================================= */

/* -- cable -- */
/* ------------------------------------------------------------------------- *
* CABLE_STATE
* ------------------------------------------------------------------------- */

const char *cable_state_repr(cable_state_t state);

/* -- common -- */
/* ------------------------------------------------------------------------- *
* COMMON
* ------------------------------------------------------------------------- */

const char *common_map_mode_to_hardware (const char *internal_mode);
const char *common_map_mode_to_external (const char *internal_mode);
Expand All @@ -55,6 +59,7 @@ FILE *common_popen_ (const char *file, int line, co
waitres_t common_wait (unsigned tot_ms, bool (*ready_cb)(void *aptr), void *aptr);
bool common_msleep_ (const char *file, int line, const char *func, unsigned msec);
static bool common_mode_in_list (const char *mode, char *const *modes);
bool common_modename_is_internal (const char *modename);
int common_valid_mode (const char *mode);
gchar *common_get_mode_list (mode_list_type_t type);

Expand Down Expand Up @@ -439,6 +444,25 @@ static bool common_mode_in_list(const char *mode, char * const *modes)
return false;
}

/** Check if given usb mode is internal
*
* @param modename name of a more
*
* @return true if mode is internal, false otherwise
*/
bool
common_modename_is_internal(const char *modename)
{
LOG_REGISTER_CONTEXT;

return (!g_strcmp0(modename, MODE_UNDEFINED) ||
!g_strcmp0(modename, MODE_CHARGER) ||
!g_strcmp0(modename, MODE_CHARGING_FALLBACK) ||
!g_strcmp0(modename, MODE_ASK) ||
!g_strcmp0(modename, MODE_CHARGING) ||
!g_strcmp0(modename, MODE_BUSY));
}

/** check if a given usb_mode exists
*
* @param mode The mode to look for
Expand All @@ -457,25 +481,22 @@ int common_valid_mode(const char *mode)
}
else
{
const modedata_t *data = usbmoded_get_modedata(mode);

if( data ) {
gchar *whitelist_value = 0;
gchar **whitelist_array = 0;

if( (whitelist_value = config_get_mode_whitelist()) )
whitelist_array = g_strsplit(whitelist_value, ",", 0);

for( GList *iter = usbmoded_get_modelist(); iter; iter = g_list_next(iter) ) {
mode_list_elem_t *data = iter->data;
if( strcmp(mode, data->mode_name) )
continue;

if (!whitelist_array || common_mode_in_list(data->mode_name, whitelist_array))
valid = 0;
break;
}

g_strfreev(whitelist_array);
g_free(whitelist_value);
}
}
return valid;
}

Expand Down Expand Up @@ -521,7 +542,7 @@ gchar *common_get_mode_list(mode_list_type_t type)

for( GList *iter = usbmoded_get_modelist(); iter; iter = g_list_next(iter) )
{
mode_list_elem_t *data = iter->data;
modedata_t *data = iter->data;

/* skip items in the hidden list */
if (common_mode_in_list(data->mode_name, hidden_modes_array))
Expand Down
11 changes: 8 additions & 3 deletions src/usb_moded-common.h
Expand Up @@ -34,14 +34,18 @@ typedef enum waitres_t
} waitres_t;

/* ========================================================================= *
* Functions
* Prototypes
* ========================================================================= */

/* -- cable -- */
/* ------------------------------------------------------------------------- *
* CABLE_STATE
* ------------------------------------------------------------------------- */

const char *cable_state_repr(cable_state_t state);

/* -- common -- */
/* ------------------------------------------------------------------------- *
* COMMON
* ------------------------------------------------------------------------- */

const char *common_map_mode_to_hardware (const char *internal_mode);
const char *common_map_mode_to_external (const char *internal_mode);
Expand All @@ -55,6 +59,7 @@ int common_system_ (const char *file, int line, con
FILE *common_popen_ (const char *file, int line, const char *func, const char *command, const char *type);
waitres_t common_wait (unsigned tot_ms, bool (*ready_cb)(void *aptr), void *aptr);
bool common_msleep_ (const char *file, int line, const char *func, unsigned msec);
bool common_modename_is_internal (const char *modename);
int common_valid_mode (const char *mode);
gchar *common_get_mode_list (mode_list_type_t type);

Expand Down
9 changes: 5 additions & 4 deletions src/usb_moded-config-private.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2010 Nokia Corporation. All rights reserved.
* Copyright (C) 2012-2018 Jolla. All rights reserved.
* Copyright (C) 2012-2019 Jolla. All rights reserved.
*
* Author: Philippe De Swert <philippe.de-swert@nokia.com>
* Author: Philippe De Swert <philippedeswert@gmail.com>
Expand Down Expand Up @@ -53,7 +53,9 @@
* Prototypes
* ========================================================================= */

/* -- config -- */
/* ------------------------------------------------------------------------- *
* CONFIG
* ------------------------------------------------------------------------- */

char *config_find_mounts (void);
int config_find_sync (void);
Expand All @@ -65,8 +67,8 @@ char *config_get_trigger_subsystem (void);
char *config_get_trigger_mode (void);
char *config_get_trigger_property (void);
char *config_get_trigger_value (void);
char *config_get_conf_string (const gchar *entry, const gchar *key);
char *config_get_mode_setting (void);
int config_value_changed (GKeyFile *settingsfile, const char *entry, const char *key, const char *new_value);
set_config_result_t config_set_config_setting (const char *entry, const char *key, const char *value);
set_config_result_t config_set_mode_setting (const char *mode);
set_config_result_t config_set_hide_mode_setting (const char *mode);
Expand All @@ -83,7 +85,6 @@ char *config_get_android_product_id (void);
char *config_get_hidden_modes (void);
char *config_get_mode_whitelist (void);
int config_is_roaming_not_allowed (void);
char *config_get_conf_string (const gchar *entry, const gchar *key);

/* ========================================================================= *
* Macros
Expand Down

0 comments on commit 42eb1ed

Please sign in to comment.