static Ecore_Timer* g_w_notify_state_timer = NULL;
static Ecore_Timer* g_w_notify_result_timer = NULL;
+static pthread_mutex_t g_w_init_mutex = PTHREAD_MUTEX_INITIALIZER;
+
static Ecore_Thread* g_w_prepare_thread = NULL;
static int g_w_prepare_canceled = 0;
}
}
+ pthread_mutex_lock(&g_w_init_mutex);
if (0 != vc_widget_client_create(vc_w)) {
SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to create client!!!!!");
+ pthread_mutex_unlock(&g_w_init_mutex);
return VC_ERROR_OUT_OF_MEMORY;
}
SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to init config manager : %s",
__vc_widget_get_error_code(__vc_widget_convert_config_error_code(ret)));
vc_widget_client_destroy((*vc_w));
+ pthread_mutex_unlock(&g_w_init_mutex);
return __vc_widget_convert_config_error_code(ret);
}
SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to set config changed : %d", ret);
vc_config_mgr_finalize((*vc_w)->handle);
vc_widget_client_destroy((*vc_w));
+ pthread_mutex_unlock(&g_w_init_mutex);
return __vc_widget_convert_config_error_code(ret);
}
SLOG(LOG_ERROR, TAG_VCW, "[ERROR] Fail to initialize DB : %d", ret);
vc_config_mgr_finalize((*vc_w)->handle);
vc_widget_client_destroy((*vc_w));
+ pthread_mutex_unlock(&g_w_init_mutex);
return ret;
}
}
SLOG(LOG_DEBUG, TAG_VCW, "@@@");
+ pthread_mutex_unlock(&g_w_init_mutex);
return VC_ERROR_NONE;
}
return VC_ERROR_NONE;
}
+ pthread_mutex_lock(&g_w_init_mutex);
if (false == vc_widget_client_is_valid(vc_w)) {
SLOG(LOG_ERROR, TAG_VCW, "[ERROR] NOT initialized");
SLOG(LOG_DEBUG, TAG_VCW, "@@@");
+ pthread_mutex_unlock(&g_w_init_mutex);
return VC_ERROR_INVALID_STATE;
}
SLOG(LOG_DEBUG, TAG_VCW, "@@@");
+ pthread_mutex_unlock(&g_w_init_mutex);
return VC_ERROR_NONE;
}
ecore_thread_cancel(g_w_prepare_thread);
}
+ SLOG(LOG_WARN, TAG_VCW, "[Widget] thread info %d %d %d", curr_thread_count, prev_thread_count - curr_thread_count, !ecore_thread_check(g_w_prepare_thread));
+ SLOG(LOG_WARN, TAG_VCW, "[Widget] thread count %d", count);
while (0 < curr_thread_count && 1 != prev_thread_count - curr_thread_count && !ecore_thread_check(g_w_prepare_thread)) {
usleep(50000);
static pthread_mutex_t g_w_dbus_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t g_w_init_mutex = PTHREAD_MUTEX_INITIALIZER;
static int g_w_waiting_time = 3000;
static bool g_is_connection_opened = false;
int vc_widget_dbus_request_initialize(int pid, int* service_state, int* daemon_pid)
{
+ pthread_mutex_lock(&g_w_init_mutex);
if (0 != __dbus_check()) {
+ pthread_mutex_unlock(&g_w_init_mutex);
return VC_ERROR_OPERATION_FAILED;
}
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_VCW, "@@ vc widget initialize : Fail to make message ");
+ pthread_mutex_unlock(&g_w_init_mutex);
return VC_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_VCW, "@@ vc widget initialize : pid(%d)", pid);
if (NULL == g_w_conn_listener) {
if (g_is_connection_opened) {
SLOG(LOG_ERROR, TAG_VCW, "[ERROR] g_w_conn_listener is NULL abnormally");
+ pthread_mutex_unlock(&g_w_init_mutex);
return VC_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_INFO, TAG_VCW, "[INFO] g_w_conn_listener is NULL and DBUS connection was closed");
+ pthread_mutex_unlock(&g_w_init_mutex);
return VC_ERROR_NONE;
}
}
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_VCW, "Match Error (%s)", err.message);
dbus_error_free(&err);
+ pthread_mutex_unlock(&g_w_init_mutex);
return VC_ERROR_OPERATION_FAILED;
}
result = VC_ERROR_TIMED_OUT;
}
+ pthread_mutex_unlock(&g_w_init_mutex);
return result;
}
int vc_widget_dbus_request_finalize(int pid)
{
+ pthread_mutex_lock(&g_w_init_mutex);
if (0 != __dbus_check()) {
+ pthread_mutex_unlock(&g_w_init_mutex);
return VC_ERROR_OPERATION_FAILED;
}
if (dbus_error_is_set(&err)) {
SLOG(LOG_ERROR, TAG_VCW, "Match Error (%s)", err.message);
dbus_error_free(&err);
+ pthread_mutex_unlock(&g_w_init_mutex);
return VC_ERROR_OPERATION_FAILED;
}
if (NULL == msg) {
SLOG(LOG_ERROR, TAG_VCW, "@@ vc widget finalize : Fail to make message ");
+ pthread_mutex_unlock(&g_w_init_mutex);
return VC_ERROR_OPERATION_FAILED;
} else {
SLOG(LOG_DEBUG, TAG_VCW, "@@ vc widget finalize : pid(%d)", pid);
result = VC_ERROR_TIMED_OUT;
}
+ pthread_mutex_unlock(&g_w_init_mutex);
return result;
}