From 07add5b5be10e99d069c163b35448101e2ffb73e Mon Sep 17 00:00:00 2001 From: Jiwoong Im Date: Thu, 11 Aug 2016 18:43:21 +0900 Subject: [PATCH] extend lock scope of vconf_lock in notify/ignore api - 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 --- vconf-compat/vconf.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/vconf-compat/vconf.c b/vconf-compat/vconf.c index 10d4173..0171f8b 100644 --- a/vconf-compat/vconf.c +++ b/vconf-compat/vconf.c @@ -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); -- 2.7.4