extend lock scope of vconf_lock in notify/ignore api 18/83518/1 accepted/tizen/common/20160823.132554 accepted/tizen/ivi/20160824.021604 accepted/tizen/mobile/20160824.021431 accepted/tizen/tv/20160824.021529 accepted/tizen/wearable/20160824.021637 submit/tizen/20160822.060113
authorJiwoong Im <jiwoong.im@samsung.com>
Thu, 11 Aug 2016 09:43:21 +0000 (18:43 +0900)
committerJiwoong Im <jiwoong.im@samsung.com>
Thu, 11 Aug 2016 09:56:25 +0000 (18:56 +0900)
- Sometimes buxton client is closed by ohter thread,
  if vconf_lock is unlocked in notify/ignore API.
  There is no need to unlock vconf_lock before call buxton api,
  because noti_cb is called in idler.
  (noti callback which is called in wait_msg in buxton api causes dead lock)
  As a result, extend lock scope of vconf_lock.

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

index 10d4173..0171f8b 100644 (file)
@@ -498,8 +498,8 @@ EXPORT int vconf_notify_key_changed(const char *key, vconf_callback_fn cb,
        noti = g_hash_table_lookup(noti_tbl, key);
        if (!noti) {
                noti = create_noti(key, cb, user_data);
-               pthread_mutex_unlock(&vconf_lock);
                if (!noti) {
+                       pthread_mutex_unlock(&vconf_lock);
                        _close_for_noti();
                        return -1;
                }
@@ -508,10 +508,9 @@ EXPORT int vconf_notify_key_changed(const char *key, vconf_callback_fn cb,
                if (r == -1) {
                        LOGE("vconf_notify_key_changed: key '%s' add notify error %d",
                                        key, errno);
-                       pthread_mutex_lock(&vconf_lock);
                        g_hash_table_remove(noti_tbl, key);
-                       pthread_mutex_unlock(&vconf_lock);
                }
+               pthread_mutex_unlock(&vconf_lock);
                /* increase reference count */
                if (r == 0)
                        _open_for_noti();
@@ -580,17 +579,17 @@ EXPORT int vconf_ignore_key_changed(const char *key, vconf_callback_fn cb)
        }
 
        cnt = unregister_noti(noti);
-       pthread_mutex_unlock(&vconf_lock);
 
-       if (cnt > 0)
+       if (cnt > 0) {
+               pthread_mutex_unlock(&vconf_lock);
                return 0;
+       }
 
        r = buxton_unregister_notification_sync(noti_client, get_layer(key),
                        key, notify_cb);
        if (r == -1)
                LOGE("unregister error '%s' %d", noti->key, errno);
 
-       pthread_mutex_lock(&vconf_lock);
        noti = g_hash_table_lookup(noti_tbl, key);
        if (noti)
                g_hash_table_remove(noti_tbl, key);