From 5218c956d8e76ce58300b81921b6b359435735bf Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Wed, 21 Sep 2022 08:46:22 +0900 Subject: [PATCH] Add prepare_sync function to connect directly Cause: The Web TCs were blocked and failed. Change-Id: I5b64a3f281b59191d8c41fc60a44eacdcdd5edb3 Solution: Connect directly when web api request to prepare --- client/vc.c | 6 ++++++ client/vc_tidl.c | 41 +++++++++++++++++++++++++++++++++++++++++ client/vc_tidl.h | 2 ++ 3 files changed, 49 insertions(+) diff --git a/client/vc.c b/client/vc.c index 45fb98c..1e2cdad 100644 --- a/client/vc.c +++ b/client/vc.c @@ -692,6 +692,12 @@ int vc_prepare_sync(void) /* check state */ RETVM_IF(state != VC_STATE_INITIALIZED, VC_ERROR_INVALID_STATE, TAG_VCC, "[ERROR] Invalid State: Current state(%d) is not 'Initialized'", state); + ret = vc_tidl_request_hello_sync(); + if (VC_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request hello_sync, ret(%d)", ret); + return ret; + } + int cnt = 0; while (EINA_TRUE == __vc_connect_daemon(NULL) && VC_CONNECTION_RETRY_COUNT > cnt) { cnt++; diff --git a/client/vc_tidl.c b/client/vc_tidl.c index c92aa53..b9c5a18 100644 --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -168,6 +168,19 @@ static void __request_tidl_connect(vc_tidl_info_s* info) info->connection_requesting = true; } +static int __request_tidl_connect_sync(vc_tidl_info_s* info) +{ + int ret = rpc_port_proxy_vc_proxy_vc_connect_sync(info->rpc_h); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request connection to stub. ret(%d)", ret); + return VC_ERROR_OPERATION_FAILED; + } + + SLOG(LOG_INFO, TAG_VCC, "[INFO] Success to connect stub synchronously. ret(%d)", ret); + return VC_ERROR_NONE; +} + + static void __notify_cb(void* user_data, int pid, bundle* msg) { // corresponding to listener_event_callback @@ -409,6 +422,34 @@ int vc_tidl_request_hello() } +int vc_tidl_request_hello_sync() +{ + SLOG(LOG_INFO, TAG_VCC, "[TIDL] vc_tidl_request_hello"); + + int pid = getpid(); + vc_tidl_info_s* info = __get_tidl_info_s(pid); + RETVM_IF(NULL == info, VC_ERROR_INVALID_PARAMETER, TAG_VCC, "[ERROR] Fail to get tidl info"); + + if (!info->connected) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Not Connected. Call __request_tidl_connect()"); + int ret = __request_tidl_connect_sync(info); + if (VC_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_VCC, "[TIDL] Fail to connect, ret(%d)", ret); + return VC_ERROR_OPERATION_FAILED; + } + SLOG(LOG_ERROR, TAG_VCC, "[TIDL] Stub is connected"); + } + + SLOG(LOG_DEBUG, TAG_VCC, ">>>>> VCC Hello"); + if (VC_ERROR_NONE != __invoke_register_notify_callback(pid, info)) { + SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to invoke register callback"); + return VC_ERROR_OPERATION_FAILED; + } + + SLOG(LOG_DEBUG, TAG_VCC, "<<<<"); + return VC_ERROR_NONE; +} + static int __convert_unhandled_error(int ret) { if (RPC_PORT_ERROR_IO_ERROR == ret || RPC_PORT_ERROR_OUT_OF_MEMORY == ret) { diff --git a/client/vc_tidl.h b/client/vc_tidl.h index 7b84703..b2d80f6 100644 --- a/client/vc_tidl.h +++ b/client/vc_tidl.h @@ -31,6 +31,8 @@ int vc_tidl_close_connection(); int vc_tidl_request_hello(); +int vc_tidl_request_hello_sync(); + int vc_tidl_request_initialize(int pid, int* mgr_pid, int* service_state, int* daemon_pid); int vc_tidl_request_finalize(int pid); -- 2.34.1