revert performance improvement patch in vconf libray side 45/111745/1 tizen_3.0_tv accepted/tizen/3.0/common/20170125.121508 accepted/tizen/3.0/ivi/20170125.083304 accepted/tizen/3.0/mobile/20170125.083218 accepted/tizen/3.0/tv/20170125.083236 accepted/tizen/3.0/wearable/20170125.083250 accepted/tizen/common/20170124.181806 accepted/tizen/ivi/20170125.085044 accepted/tizen/mobile/20170125.085031 accepted/tizen/tv/20170125.085036 accepted/tizen/wearable/20170125.085040 submit/tizen/20170124.012332 submit/tizen_3.0/20170124.012351
authorJiwoong Im <jiwoong.im@samsung.com>
Tue, 24 Jan 2017 01:11:22 +0000 (10:11 +0900)
committerJiwoong Im <jiwoong.im@samsung.com>
Tue, 24 Jan 2017 01:11:22 +0000 (10:11 +0900)
- If a daemon does not use g_main_loop, noti_cb for cache key-value is not
  invoked. In this case, buxton daemon is blocked in sending noti to
  the client.

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

index 3eea5db..cc793b0 100644 (file)
@@ -41,8 +41,6 @@
 
 #define LOG_TAG "VCONF"
 
-#define HASH_SIZE 10
-
 static void _restore_noti_cb(gpointer key, gpointer value, gpointer user_data);
 
 static pthread_mutex_t vconf_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -51,8 +49,6 @@ static struct buxton_client *client;
 static struct buxton_layer *system_layer;
 static struct buxton_layer *memory_layer;
 static GHashTable *noti_tbl;
-static GHashTable *cache_tbl;
-static GQueue *victims;
 
 struct noti {
        char *key;
@@ -205,12 +201,6 @@ static void _close(void)
        g_hash_table_destroy(noti_tbl);
        noti_tbl = NULL;
 
-       g_hash_table_destroy(cache_tbl);
-       cache_tbl = NULL;
-
-       g_queue_free_full(victims, (GDestroyNotify)free);
-       victims = NULL;
-
        buxton_close(client);
        client = NULL;
 }
@@ -265,17 +255,6 @@ static int _open(void)
                                NULL, (GDestroyNotify)free_noti);
        }
 
-       if (!cache_tbl) {
-               cache_tbl = g_hash_table_new_full(g_str_hash, g_str_equal,
-                               (GDestroyNotify)free,
-                               (GDestroyNotify)buxton_value_free);
-       }
-
-       if (!victims) {
-               victims = g_queue_new();
-               g_queue_init(victims);
-       }
-
        if (!system_layer)
                system_layer = buxton_create_layer("system");
        if (!memory_layer)
@@ -659,17 +638,8 @@ static int _vconf_set(const char *key, const struct buxton_value *val)
        }
 
        r = buxton_set_value_sync(client, get_layer(key), key, val);
-       if (r == -1) {
+       if (r == -1)
                LOGE("set value: key '%s' errno %d", key, errno);
-       } else {
-               if (cache_tbl) {
-                       if (g_hash_table_contains(cache_tbl, key)) {
-                               g_hash_table_replace(cache_tbl,
-                                               strdup(key),
-                                               buxton_value_duplicate(val));
-                       }
-               }
-       }
 
        _close();
        pthread_mutex_unlock(&vconf_lock);
@@ -773,63 +743,6 @@ EXPORT int vconf_set_dbl(const char *key, double dblval)
        return r;
 }
 
-static void cache_cb(const struct buxton_layer *layer, const char *key,
-               const struct buxton_value *val, void *user_data)
-{
-       if (g_hash_table_contains(cache_tbl, key)) {
-               g_hash_table_replace(cache_tbl,
-                               strdup(key), buxton_value_duplicate(val));
-       }
-}
-
-
-static void _reduce_cache()
-{
-       char *key;
-       int r;
-
-       key = (char *)g_queue_pop_tail(victims);
-       if (key == NULL)
-               return;
-
-       r = g_hash_table_remove(cache_tbl, key);
-       if (r == false)
-               return;
-
-       r = buxton_unregister_notification_sync(client, get_layer(key),
-                       key, cache_cb);
-       if (r == -1)
-               return;
-
-       _close();
-
-       free(key);
-}
-
-static void _insert_cache(const char *key, struct buxton_value *val)
-{
-       int r;
-
-       r = _open();
-       if (r == -1)
-               return;
-
-       if (g_hash_table_size(cache_tbl) >= HASH_SIZE)
-               _reduce_cache();
-
-       r = buxton_register_notification_sync(client, get_layer(key), key,
-                       cache_cb, NULL);
-
-       if (r == -1) {
-               _close();
-               return;
-       }
-
-       g_queue_push_head(victims, (char *)strdup(key));
-       r = g_hash_table_insert(cache_tbl, strdup(key),
-                       buxton_value_duplicate(val));
-}
-
 static int _vconf_get(const char *key, enum buxton_key_type type,
                struct buxton_value **val)
 {
@@ -840,21 +753,12 @@ static int _vconf_get(const char *key, enum buxton_key_type type,
        assert(val);
 
        pthread_mutex_lock(&vconf_lock);
-
        r = _open();
        if (r == -1) {
                pthread_mutex_unlock(&vconf_lock);
                return -1;
        }
 
-       v = g_hash_table_lookup(cache_tbl, key);
-       if (v) {
-               *val = buxton_value_duplicate(v);
-               _close();
-               pthread_mutex_unlock(&vconf_lock);
-               return 0;
-       }
-
        r = buxton_get_value_sync(client, get_layer(key), key, &v);
        if (r == -1) {
                LOGE("get value: key '%s' errno %d", key, errno);
@@ -874,9 +778,7 @@ static int _vconf_get(const char *key, enum buxton_key_type type,
                }
        }
 
-       _insert_cache(key, v);
        _close();
-
        pthread_mutex_unlock(&vconf_lock);
 
        return r;