using vconf_lock in restore_connection 72/104772/1 accepted/tizen/3.0/common/20161216.122740 accepted/tizen/3.0/ivi/20161216.013909 accepted/tizen/3.0/mobile/20161216.013744 accepted/tizen/3.0/tv/20161216.013837 accepted/tizen/3.0/wearable/20161216.013852 submit/tizen_3.0/20161215.010253
authorJiwoong Im <jiwoong.im@samsung.com>
Wed, 14 Dec 2016 06:53:36 +0000 (15:53 +0900)
committerJiwoong Im <jiwoong.im@samsung.com>
Wed, 14 Dec 2016 07:03:12 +0000 (16:03 +0900)
- To protect noti_tbl & client data in multi-thread situations

Change-Id: Ic1d2d29a86bffdfd5872c74109e2e92e51d1be5e
Signed-off-by: Jiwoong Im <jiwoong.im@samsung.com>
vconf-compat/vconf.c

index 0fc431d..cc793b0 100644 (file)
@@ -212,15 +212,24 @@ static void _restore_connection(enum buxton_status status,
        if (status != BUXTON_STATUS_CONNECTION_CLOSED)
                return;
 
+       pthread_mutex_lock(&vconf_lock);
+       if (!noti_tbl) {
+               _refcnt = 0;
+               pthread_mutex_unlock(&vconf_lock);
+               return;
+       }
+
        buxton_close(client);
        r = buxton_open(&client, _restore_connection, NULL);
        if (r == -1) {
                _refcnt = 0;
                LOGE("Can't connect to buxton: %d", errno);
+               pthread_mutex_unlock(&vconf_lock);
                return;
        }
 
        g_hash_table_foreach(noti_tbl, (GHFunc)_restore_noti_cb, NULL);
+       pthread_mutex_unlock(&vconf_lock);
 }
 
 static int _open(void)