From c9db4e87685388b6c35e8c824f906957a3657218 Mon Sep 17 00:00:00 2001 From: "sooyeon.kim" Date: Wed, 3 Jan 2018 16:35:21 +0900 Subject: [PATCH] Fix to check whether handle is valid in connect daemon Change-Id: If15a3be995711242abe82eb0ded86d0d1d1be659 Signed-off-by: sooyeon.kim (cherry picked from commit 45ae7486778042c430ac66c7d6275ab0358c34cd) --- client/vc.c | 100 ++++++++++++++++++++++++++++++++---------------------------- 1 file changed, 54 insertions(+), 46 deletions(-) diff --git a/client/vc.c b/client/vc.c index bf61429..9d0248c 100644 --- a/client/vc.c +++ b/client/vc.c @@ -484,67 +484,75 @@ static Eina_Bool __vc_connect_daemon(void *data) if (0 != ret) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to delete file, type(%d), ret(%d)", VC_COMMAND_TYPE_FOREGROUND, ret); - ret = vc_dbus_request_initialize(g_vc->handle, &mgr_pid, &service_state, &g_daemon_pid); - if (VC_ERROR_ENGINE_NOT_FOUND == ret) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to initialize : %s", __vc_get_error_code(ret)); + /* check handle */ + if (true == vc_client_is_valid(g_vc)) { + SLOG(LOG_DEBUG, TAG_VCC, "[DEBUG] g_vc is valid"); - vc_client_set_error(g_vc, VC_ERROR_ENGINE_NOT_FOUND); - ecore_main_loop_thread_safe_call_async(__vc_notify_error, (void*)g_vc); + ret = vc_dbus_request_initialize(g_vc->handle, &mgr_pid, &service_state, &g_daemon_pid); + if (VC_ERROR_ENGINE_NOT_FOUND == ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to initialize : %s", __vc_get_error_code(ret)); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return EINA_FALSE; + vc_client_set_error(g_vc, VC_ERROR_ENGINE_NOT_FOUND); + ecore_main_loop_thread_safe_call_async(__vc_notify_error, (void*)g_vc); - } else if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to initialize :%s", __vc_get_error_code(ret)); + SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + return EINA_FALSE; - vc_client_set_error(g_vc, VC_ERROR_TIMED_OUT); - ecore_main_loop_thread_safe_call_async(__vc_notify_error, (void*)g_vc); + } else if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to initialize :%s", __vc_get_error_code(ret)); - SLOG(LOG_DEBUG, TAG_VCC, "@@@"); - return EINA_FALSE; - } else { - /* Success to connect */ - } + vc_client_set_error(g_vc, VC_ERROR_TIMED_OUT); + ecore_main_loop_thread_safe_call_async(__vc_notify_error, (void*)g_vc); - /* Set service state */ - vc_client_set_service_state(g_vc, (vc_service_state_e)service_state); + SLOG(LOG_DEBUG, TAG_VCC, "@@@"); + return EINA_FALSE; + } else { + /* Success to connect */ + } - g_focus_in_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, __focus_changed_cb, NULL); - g_focus_out_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, __focus_changed_cb, NULL); + /* Set service state */ + vc_client_set_service_state(g_vc, (vc_service_state_e)service_state); - char appid[1024] = {'\0',}; - aul_app_get_appid_bypid(getpid(), appid, sizeof(appid) - 1); + g_focus_in_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_IN, __focus_changed_cb, NULL); + g_focus_out_handler = ecore_event_handler_add(ECORE_WL_EVENT_FOCUS_OUT, __focus_changed_cb, NULL); - int status = aul_app_get_status(appid); - if (STATUS_FOCUS == status) { - SLOG(LOG_DEBUG, TAG_VCC, "@@@ Set foreground"); - ret = vc_dbus_set_foreground(getpid(), true); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set foreground (true) : %d", ret); - } + char appid[1024] = {'\0',}; + aul_app_get_appid_bypid(getpid(), appid, sizeof(appid) - 1); - ret = vc_client_set_is_foreground(g_vc, true); - if (0 != ret) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to save is_foreground (true) : %d", ret); - } + int status = aul_app_get_status(appid); + if (STATUS_FOCUS == status) { + SLOG(LOG_DEBUG, TAG_VCC, "@@@ Set foreground"); + ret = vc_dbus_set_foreground(getpid(), true); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to set foreground (true) : %d", ret); + } - /* set authority valid */ - vc_auth_state_e state = VC_AUTH_STATE_NONE; - if (0 != vc_client_get_auth_state(g_vc, &state)) { - SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get auth state"); - } - if (VC_AUTH_STATE_INVALID == state) { - vc_client_set_auth_state(g_vc, VC_AUTH_STATE_VALID); + ret = vc_client_set_is_foreground(g_vc, true); + if (0 != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to save is_foreground (true) : %d", ret); + } - /* notify auth changed cb */ - ecore_idler_add(__notify_auth_changed_cb, NULL); + /* set authority valid */ + vc_auth_state_e state = VC_AUTH_STATE_NONE; + if (0 != vc_client_get_auth_state(g_vc, &state)) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to get auth state"); + } + if (VC_AUTH_STATE_INVALID == state) { + vc_client_set_auth_state(g_vc, VC_AUTH_STATE_VALID); + + /* notify auth changed cb */ + ecore_idler_add(__notify_auth_changed_cb, NULL); + } } - } - vc_client_set_client_state(g_vc, VC_STATE_READY); - ecore_main_loop_thread_safe_call_async(__vc_notify_state_changed, (void*)g_vc); + vc_client_set_client_state(g_vc, VC_STATE_READY); + ecore_main_loop_thread_safe_call_async(__vc_notify_state_changed, (void*)g_vc); - vc_client_set_mgr_pid(g_vc, mgr_pid); + vc_client_set_mgr_pid(g_vc, mgr_pid); + } else { + SLOG(LOG_ERROR, TAG_VCC, "[Not ERROR] g_vc is not valid. It is destroyed."); + return EINA_FALSE; + } SLOG(LOG_DEBUG, TAG_VCC, "@@@"); -- 2.7.4