From 28d9a0adfd2762fa8cca8ff3ab62cbf1865fcb26 Mon Sep 17 00:00:00 2001 From: Semun Lee Date: Tue, 7 Jun 2016 12:53:23 +0900 Subject: [PATCH] Fix issue related to noti_tbl hash table - fix wrong copy_noti loop - remove noti from noti_tbl after unregister noti completely Change-Id: Ifd18061783b2c5f2f147dd6c769b6716189be7ba Signed-off-by: Semun Lee --- lib/buxton2.c | 3 +-- vconf-compat/vconf.c | 11 +++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/buxton2.c b/lib/buxton2.c index bc19df5..1898eee 100644 --- a/lib/buxton2.c +++ b/lib/buxton2.c @@ -425,8 +425,7 @@ static GList *copy_noti_callbacks(GList *callbacks) return NULL; for (l = callbacks; l; l = g_list_next(l)) { - struct bxt_noti_cb *noticb; - noticb = callbacks->data; + struct bxt_noti_cb *noticb = l->data; noticb->ref_cnt++; } copy = g_list_copy(callbacks); diff --git a/vconf-compat/vconf.c b/vconf-compat/vconf.c index 3de1328..9ad157f 100644 --- a/vconf-compat/vconf.c +++ b/vconf-compat/vconf.c @@ -307,8 +307,7 @@ static GList *copy_noti_list(GList *noti_list) pthread_mutex_lock(&vconf_lock); for (l = noti_list; l; l = g_list_next(l)) { - struct noti_cb *noticb; - noticb = noti_list->data; + struct noti_cb *noticb = l->data; noticb->ref_cnt++; } copy = g_list_copy(noti_list); @@ -511,8 +510,6 @@ static int unregister_noti(struct noti *noti) if (cnt > 0) return cnt; - g_hash_table_remove(noti_tbl, noti->key); - return 0; } @@ -560,6 +557,12 @@ EXPORT int vconf_ignore_key_changed(const char *key, vconf_callback_fn 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); + pthread_mutex_unlock(&vconf_lock); + /* decrease reference count */ _close_for_noti(); -- 2.7.4