Add prepare_sync function to connect directly 92/281692/1 accepted/tizen/unified/20220921.091827
authorwn.jang <wn.jang@samsung.com>
Tue, 20 Sep 2022 23:46:22 +0000 (08:46 +0900)
committerTizen AI <ai.tzn.sec@samsung.com>
Wed, 21 Sep 2022 01:25:33 +0000 (10:25 +0900)
Cause: The Web TCs were blocked and failed.

Change-Id: I5b64a3f281b59191d8c41fc60a44eacdcdd5edb3
Solution: Connect directly when web api request to prepare

client/vc.c
client/vc_tidl.c
client/vc_tidl.h

index 45fb98c62c6a79ae647aef6291affd11d5ef99ca..1e2cdad739203d572f534ea7a420e3fb49a42af1 100644 (file)
@@ -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++;
index c92aa53b51dd095687a8ac62c65a06fb415127ba..b9c5a18b66213caa86042462676f62647109ade4 100644 (file)
@@ -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) {
index 7b84703abe47f36d57f3e9cc3f4767724d91b350..b2d80f6d2c90ee9c22db22ee2e15f721b041de31 100644 (file)
@@ -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);