diff options
author | Matt Ranostay <matt.ranostay@konsulko.com> | 2017-07-21 17:55:29 -0700 |
---|---|---|
committer | Matt Ranostay <matt.ranostay@konsulko.com> | 2017-07-21 19:07:13 -0700 |
commit | 66f8a3960ee117e36138e5857269fe2528406cdf (patch) | |
tree | 532cc6837deeea80ce8c239ee6b0130baad80237 /binding-bluetooth | |
parent | cdc8c5a82fa158f042a4adc7321da890ea8daf38 (diff) |
binding: bluetooth: lock around BluetoothManage.inited flag
inited flag could be written during a read, and this should be
prevented via a mutex.
Bug-AGL: SPEC-768
Change-Id: Ie8ff57e931b3c9d73b52c6c6082100cb620ca9d8
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding-bluetooth')
-rw-r--r-- | binding-bluetooth/bluetooth-manager.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/binding-bluetooth/bluetooth-manager.c b/binding-bluetooth/bluetooth-manager.c index 007986c..24312c2 100644 --- a/binding-bluetooth/bluetooth-manager.c +++ b/binding-bluetooth/bluetooth-manager.c @@ -38,12 +38,20 @@ static FILE *logfp= NULL; /* ------ LOCAL FUNCTIONS --------- */ void BluetoothManage_InitFlag_Set(gboolean value) { + g_mutex_lock(&(BluetoothManage.m)); BluetoothManage.inited = value; + g_mutex_unlock(&(BluetoothManage.m)); } gboolean BluetoothManage_InitFlag_Get(void) { - return BluetoothManage.inited; + gboolean inited; + + g_mutex_lock(&(BluetoothManage.m)); + inited = BluetoothManage.inited; + g_mutex_unlock(&(BluetoothManage.m)); + + return inited; } void devices_list_lock(void) @@ -976,7 +984,7 @@ static void *bt_event_loop_thread() devices_list_update(); - BluetoothManage.inited = TRUE; + BluetoothManage_InitFlag_Set(TRUE); LOGD("g_main_loop_run\n"); g_main_loop_run(cli.clientloop); |