summaryrefslogtreecommitdiffstats
path: root/binding-bluetooth/bluetooth-manager.c
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2017-07-21 17:55:29 -0700
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2017-07-24 21:55:50 +0000
commit2dd4f451d0ca434c662844415bc3a3f3c37a6aa2 (patch)
tree799f09c9e573018bd6007bf865996dc49036d619 /binding-bluetooth/bluetooth-manager.c
parent93e0bcdda8298df869b069661d313e53c87a8b33 (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/bluetooth-manager.c')
-rw-r--r--binding-bluetooth/bluetooth-manager.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/binding-bluetooth/bluetooth-manager.c b/binding-bluetooth/bluetooth-manager.c
index 5ce90ce..e234d9b 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);