Fix bug in restore connection 17/112417/3
authorJiwoong Im <jiwoong.im@samsung.com>
Wed, 1 Feb 2017 01:40:46 +0000 (10:40 +0900)
committerJiwoong Im <jiwoong.im@samsung.com>
Wed, 1 Feb 2017 05:30:31 +0000 (14:30 +0900)
- vconf_ignore_key_changed should be called without a connection
  initialization, if connection is closed and not restored immediately.
  This situation causes SIGABRT on the client.
  To prevent this, add _open/_close in vconf_ignore_key_changed.
- Increase _refcnt in restoring vconf notify callback.

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

index e404c2c..5fd6fa8 100644 (file)
@@ -534,6 +534,8 @@ static void _restore_noti_cb(gpointer key, gpointer value, gpointer user_data)
                LOGE("vconf_notify_key_changed: key '%s' add notify error %d",
                                key, errno);
                g_hash_table_remove(noti_tbl, key);
+       } else {
+               _refcnt++;
        }
 }
 
@@ -618,6 +620,12 @@ EXPORT int vconf_ignore_key_changed(const char *key, vconf_callback_fn cb)
        }
 
        pthread_mutex_lock(&vconf_lock);
+       r = _open();
+       if (r == -1) {
+               pthread_mutex_unlock(&vconf_lock);
+               return -1;
+       }
+
        noti = g_hash_table_lookup(noti_tbl, key);
        if (!noti) {
                pthread_mutex_unlock(&vconf_lock);
@@ -649,6 +657,8 @@ EXPORT int vconf_ignore_key_changed(const char *key, vconf_callback_fn cb)
                        key, notify_cb);
        if (r == -1)
                LOGE("unregister error '%s' %d", noti->key, errno);
+       else
+               _close();
 
        noti = g_hash_table_lookup(noti_tbl, key);
        if (noti)