static GHashTable *sst_vconf_map = NULL;
static GHashTable *sst_vconf_map_new = NULL;
+static pthread_mutex_t sst_vconf_map_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t sst_vconf_map_new_lock = PTHREAD_MUTEX_INITIALIZER;
+
struct sst_vconf_info_s {
system_settings_key_e key;
system_settings_changed_cb cb;
int sst_vconf_add_multi_cb(sst_interface *iface, system_settings_changed_cb cb, void *user_data)
{
GList *list = NULL;
+ int ret;
RETV_IF(NULL == iface, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == cb, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
+ pthread_mutex_lock(&sst_vconf_map_lock);
if (sst_vconf_map) {
list = g_hash_table_lookup(sst_vconf_map, iface->vconf_key);
GList *found = g_list_find_custom(list, cb, _compare_cb);
if (found) {
ERR("callback Already Exist");
+ pthread_mutex_unlock(&sst_vconf_map_lock);
return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
}
} else {
sst_vconf_map = g_hash_table_new(g_str_hash, g_str_equal);
}
- return _subscribe(iface, cb, user_data, &sst_vconf_map, list, _callback_fn, NULL);
+ ret = _subscribe(iface, cb, user_data, &sst_vconf_map, list, _callback_fn, NULL);
+ pthread_mutex_unlock(&sst_vconf_map_lock);
+ return ret;
}
int sst_vconf_del_multi_cb(sst_interface *iface, system_settings_changed_cb cb)
RETV_IF(NULL == cb, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == sst_vconf_map, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
+ pthread_mutex_lock(&sst_vconf_map_lock);
GList *list = g_hash_table_lookup(sst_vconf_map, iface->vconf_key);
GList *found = g_list_find_custom(list, cb, _compare_cb);
+ int ret;
if (NULL == found) {
ERR("No callback");
+ pthread_mutex_unlock(&sst_vconf_map_lock);
return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
}
- return _unsubscribe(iface->vconf_key, found, &sst_vconf_map, _callback_fn);
+ ret = _unsubscribe(iface->vconf_key, found, &sst_vconf_map, _callback_fn);
+ pthread_mutex_unlock(&sst_vconf_map_lock);
+ return ret;
}
static void _callback_fn_new(keynode_t *node, void *user_data)
int sst_vconf_subscribe(sst_interface *iface, system_settings_changed_cb cb, void *user_data, system_settings_cb_id *id)
{
GList *list = NULL;
+ int ret;
RETV_IF(NULL == iface, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == cb, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
+ pthread_mutex_lock(&sst_vconf_map_new_lock);
if (sst_vconf_map_new) {
list = g_hash_table_lookup(sst_vconf_map_new, iface->vconf_key);
} else {
sst_vconf_map_new = g_hash_table_new(g_str_hash, g_str_equal);
}
- return _subscribe(iface, cb, user_data, &sst_vconf_map_new, list, _callback_fn_new, id);
+ ret = _subscribe(iface, cb, user_data, &sst_vconf_map_new, list, _callback_fn_new, id);
+ pthread_mutex_unlock(&sst_vconf_map_new_lock);
+ return ret;
}
int sst_vconf_unsubscribe(sst_interface *iface, system_settings_cb_id id)
RETV_IF(NULL == id, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
RETV_IF(NULL == sst_vconf_map_new, SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER);
+ pthread_mutex_lock(&sst_vconf_map_new_lock);
GList *list = g_hash_table_lookup(sst_vconf_map_new, iface->vconf_key);
GList *found = g_list_find(list, id);
+ int ret;
if (NULL == found) {
ERR("No callback");
+ pthread_mutex_unlock(&sst_vconf_map_new_lock);
return SYSTEM_SETTINGS_ERROR_INVALID_PARAMETER;
}
- return _unsubscribe(iface->vconf_key, found, &sst_vconf_map_new, _callback_fn_new);
+ ret = _unsubscribe(iface->vconf_key, found, &sst_vconf_map_new, _callback_fn_new);
+ pthread_mutex_unlock(&sst_vconf_map_new_lock);
+ return ret;
}