static GDBusConnection *_gdbus_conn;
static pthread_mutex_t __data_control_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t __data_control_socket_mutex = PTHREAD_MUTEX_INITIALIZER;
/* 100 milliseconds */
const struct timespec TRY_SLEEP_TIME = { 0, 100 * 1000 * 1000 };
+void __remove_socket_pair_hash(const char *provider_id)
+{
+ pthread_mutex_lock(&__data_control_socket_mutex);
+ g_hash_table_remove(__socket_pair_hash, provider_id);
+ pthread_mutex_unlock(&__data_control_socket_mutex);
+}
+
int __get_unique_handle_id(void)
{
static int id = 0;
if (((__response_cb_s *)data) != NULL) {
_dc = (__response_cb_s *)data;
- g_hash_table_remove(__socket_pair_hash, _dc->provider_id);
+ __remove_socket_pair_hash(_dc->provider_id);
itr = g_list_first(_dc->request_info_list);
while (itr != NULL) {
const struct timespec TRY_SLEEP_TIME = { 0, 1000 * 1000 * 1000 };
bundle *send_data;
char *socket_hash_key;
+ int socket;
_LOGI("Data control request, type: %d, request id: %d", type, request_id);
_LOGI("caller_id %s, app_id %s", caller_app_id, app_id);
do {
+ pthread_mutex_lock(&__data_control_socket_mutex);
datacontrol_socket_info *socket_info =
g_hash_table_lookup(__socket_pair_hash, provider->provider_id);
if (socket_info == NULL) {
&socket_info);
if (ret != DATA_CONTROL_ERROR_NONE) {
bundle_free(send_data);
+ pthread_mutex_unlock(&__data_control_socket_mutex);
return ret;
}
bundle_free(send_data);
_socket_info_free((gpointer)socket_info);
_LOGE("Out of memory");
+ pthread_mutex_unlock(&__data_control_socket_mutex);
return DATA_CONTROL_ERROR_OUT_OF_MEMORY;
}
bundle_free(send_data);
_socket_info_free((gpointer)socket_info);
free(socket_hash_key);
+ pthread_mutex_unlock(&__data_control_socket_mutex);
return ret;
}
socket_hash_key, socket_info);
}
+ socket = socket_info->socket_fd;
+ pthread_mutex_unlock(&__data_control_socket_mutex);
+
_LOGI("send data from consumer");
- ret = __datacontrol_send_async(socket_info->socket_fd, send_data,
+ ret = __datacontrol_send_async(socket, send_data,
extra_data, type, NULL);
if (ret != DATA_CONTROL_ERROR_NONE)
- g_hash_table_remove(__socket_pair_hash, provider->provider_id);
+ __remove_socket_pair_hash(provider->provider_id);
else
break;
+
count++;
nanosleep(&TRY_SLEEP_TIME, 0);
} while (ret != DATA_CONTROL_ERROR_NONE && count < TRY_COUNT);
if (has_bound_cb == NULL && _dc_temp->registered_cb == NULL) {
g_hash_table_remove(__response_table, provider->provider_id);
- g_hash_table_remove(__socket_pair_hash, provider->provider_id);
+ __remove_socket_pair_hash(provider->provider_id);
_LOGI("All of registered callback was removed");
}
}