Change interval and order when client connect to daemon 61/280261/1
authorulgal-park <ulgal.park@samsung.com>
Thu, 11 Aug 2022 11:58:02 +0000 (20:58 +0900)
committersooyeon <sooyeon.kim@samsung.com>
Fri, 26 Aug 2022 02:49:48 +0000 (11:49 +0900)
Change-Id: Ie6dc0b87e757171b372918d85d99637bd921f0f5

client/vc.c
client/vc_mgr.c
client/vc_mgr_tidl.c
common/vc_defs.h
server/vcd_client_data.c
server/vcd_client_data.h
server/vcd_tidl.c

index 1c9b8b947409fe372baaf3c2da4c864395286687..45fb98c62c6a79ae647aef6291affd11d5ef99ca 100644 (file)
@@ -612,7 +612,7 @@ static void __start_prepare_thread(void *data, Ecore_Thread *thread)
 
        /* Send hello */
        while (0 != ret) {
-               if (retry_count == 20) { // 200 ms * 20 = 4 sec
+               if (retry_count == VC_TIDL_RETRY_COUNT) { // 200 ms * 20 = 4 sec
                        SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request hello !!"); //LCOV_EXCL_LINE
                        return;
                }
index cef9eb460656a008ffdbd121e95ed9c755c8ab12..1202871c76847b371b0b7711839e155c0de3b281 100644 (file)
@@ -526,16 +526,14 @@ static Eina_Bool __send_hello_message(void *data)
 {
        /* Send hello */
        if (0 != vc_mgr_tidl_request_hello()) {
-               if (g_tidl_send_hello_count == VC_TIDL_RETRY_COUNT) {
+               if (g_tidl_send_hello_count == VCM_TIDL_RETRY_COUNT) {
                        g_tidl_send_hello_count = 0;
                        SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to request hello !! send error to manager");
                        __vc_mgr_cb_error(VC_ERROR_TIMED_OUT, -1, "voice_framework.error.vcfw.connect_engine_fail");
                        g_send_hello_timer = NULL;
                        return EINA_FALSE;
                } else {
-                       // TODO: discuss when updating connect/reconnect
                        g_tidl_send_hello_count++;
-                       usleep(200000);
                        return EINA_TRUE;
                }
        }
@@ -575,7 +573,7 @@ int vc_mgr_prepare(void)
                g_tidl_send_hello_count = 0;
                SLOG(LOG_INFO, TAG_VCM, "[DEBUG] Create a new timer for preparation");
                ecore_thread_main_loop_begin();
-               g_send_hello_timer = ecore_timer_add(0.02, __send_hello_message, NULL);
+               g_send_hello_timer = ecore_timer_add(0.1, __send_hello_message, NULL);
                ecore_thread_main_loop_end();
        } else {
                SLOG(LOG_INFO, TAG_VCM, "[INFO] timer handle is already created");
index a6218bae3eda2e9769ea70be1165dd718980cdee..6d095dd7669263fe95d07609ef1992282b26275c 100644 (file)
@@ -517,10 +517,10 @@ static int __vcd_mgr_auth_cancel_cb(rpc_port_stub_vc_mgr_stub_vcd_mgr_context_h
        return ret;
 }
 
-static void __register_stub_callback()
+static int __register_stub_callback()
 {
        if (g_stub_tidl_info->register_callback_requesting) {
-               return;
+               return VC_ERROR_NONE;
        }
 
        SLOG(LOG_DEBUG, TAG_VCM, "[TIDL] __register_stub_callback");
@@ -540,11 +540,11 @@ static void __register_stub_callback()
        if (0 == ret) {
                SLOG(LOG_DEBUG, TAG_VCM, "register callback");
                g_stub_tidl_info->register_callback_requesting = true;
-               return;
+               return VC_ERROR_NONE;
        }
 
-       SLOG(LOG_ERROR, TAG_VCM, "Fail to rister callback(%d)", ret);
-       return;
+       SLOG(LOG_ERROR, TAG_VCM, "Fail to register callback(%d)", ret);
+       return VC_ERROR_OPERATION_FAILED;
 }
 
 int vc_mgr_tidl_open_connection()
@@ -734,8 +734,8 @@ int vc_mgr_tidl_request_hello()
 
        if (!g_stub_tidl_info->connected) {
                SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Stub Not Connected");
-               __register_stub_callback();
-               return VC_ERROR_OPERATION_FAILED;
+               int ret = __register_stub_callback();
+               return ret;
        }
 
        SLOG(LOG_DEBUG, TAG_VCM, ">>>>> VCM Hello");
index 327038d2d7a409202e75e7b2ef86e136d9838930..b5ab4eccf245c516429bd6da0c00c72160c7328a 100644 (file)
@@ -269,7 +269,8 @@ extern "C" {
 #define VC_CONNECTION_RETRY_COUNT      10
 #define VC_INVALID_TTS_UID     0
 #define VC_ENGINE_APPID_LEN            256
-#define VC_TIDL_RETRY_COUNT            100
+#define VCM_TIDL_RETRY_COUNT   200
+#define VC_TIDL_RETRY_COUNT            20
 
 #define VC_MGR_DEFAULT_FARFIELD_DUCKING_RATIO          0.0
 #define VC_MGR_DEFAULT_NEARFIELD_DUCKING_RATIO         0.7
index 6620180bb77bcb8fc4a22e9b34b1f0a07da2f77a..de4c8cf3429d68d1c1c75e22aaa5a91eb3919c33 100644 (file)
@@ -264,15 +264,11 @@ char* vcd_client_manager_get_result_text()
        return g_result_text;
 }
 
-int vcd_client_manager_create_tidl_info(int pid)
+int vcd_client_manager_create_tidl_info()
 {
        /*Check already created*/
        if (NULL != g_mgr_tidl_info) {
                SLOG(LOG_WARN, TAG_VCD, "[Client Data] Manager tidl info pid is already registered");
-               if (pid != g_mgr_tidl_info->pid) {
-                       SLOG(LOG_ERROR, TAG_VCD, "[ERROR] Manager pid is different");
-                       return VCD_ERROR_OPERATION_FAILED;
-               }
                return VCD_ERROR_NONE;
        }
 
@@ -283,7 +279,6 @@ int vcd_client_manager_create_tidl_info(int pid)
                return VCD_ERROR_OUT_OF_MEMORY;
        }
 
-       g_mgr_tidl_info->pid = pid;
        g_mgr_tidl_info->notify_cb = NULL;
        g_mgr_tidl_info->notify_cb_user_data = NULL;
        g_mgr_tidl_info->send_buffer_cb = NULL;
@@ -293,7 +288,7 @@ int vcd_client_manager_create_tidl_info(int pid)
        g_mgr_tidl_info->connection_requesting = false;
        g_mgr_tidl_info->rpc_h = NULL;
 
-       SLOG(LOG_INFO, TAG_VCD, "[Client Data SUCCESS] Add new manager tidl info. pid(%d)", pid);
+       SLOG(LOG_INFO, TAG_VCD, "[Client Data SUCCESS] Add new manager tidl info.");
 
        return VCD_ERROR_NONE;
 }
index 4c7fbdc7e35ed1ef6bb96ed408ea90a040c9dc94..43c35a15fb4fafb7e7a5a0f6daf9b4e8392b9365 100644 (file)
@@ -80,7 +80,6 @@ typedef struct {
 } client_tidl_info_s;
 
 typedef struct {
-       int pid;
        rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_h notify_cb;
        void*   notify_cb_user_data;
        rpc_port_stub_vcd_mgr_stub_vc_mgr_send_buffer_cb_h send_buffer_cb;
@@ -177,7 +176,7 @@ char* vcd_client_manager_get_result_text();
 
 bool vcd_client_manager_is_system_command_valid(int pid);
 
-int vcd_client_manager_create_tidl_info(int pid);
+int vcd_client_manager_create_tidl_info();
 
 int vcd_client_manager_set_tidl_notify_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_notify_cb_h callback, void* user_data);
 
index a881cd742342b4154de9d1d330e78aff1fabc780..3d16d298f9d76a6381340ab004017351b441c0bf 100644 (file)
@@ -844,7 +844,35 @@ static void __vc_mgr_create_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h conte
 
        SLOG(LOG_DEBUG, TAG_VCD, "@@@ Manager connect. appid(%s)", sender);
 
+       pthread_mutex_lock(&g_mgr_tidl_info_mutex);
+       int ret = -1;
+       ret = vcd_client_manager_create_tidl_info();
+
+       if (0 != ret) {
+               SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create manager tidl info.");
+               pthread_mutex_unlock(&g_mgr_tidl_info_mutex);
+               return;
+       }
+
+       manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info();
+
+       if (NULL == mgr_tidl_info) {
+               SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get manager tidl info");
+               pthread_mutex_unlock(&g_mgr_tidl_info_mutex);
+               return;
+       }
+
+       mgr_tidl_info->rpc_h = __mgr_create_rpc_port(sender);
+
+       if (NULL == mgr_tidl_info->rpc_h) {
+               SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create server proxy");
+       } else {
+               SLOG(LOG_INFO, TAG_VCD, "[TIDL] rpc_h(%p), engine_app_id(%s)", mgr_tidl_info->rpc_h, sender);
+       }
+
        free(sender);
+       pthread_mutex_unlock(&g_mgr_tidl_info_mutex);
+       __request_tidl_connect(VCD_CLIENT_TYPE_MANAGER, -1);
 }
 
 static void __vc_mgr_terminate_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h context, void *user_data)
@@ -857,7 +885,7 @@ static void __vc_mgr_terminate_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h co
                return;
        }
 
-       SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC MANAGER FINALIZE. pid(%u)", mgr_tidl_info->pid);
+       SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC MANAGER FINALIZE.");
 
        if (0 != vcd_client_manager_unset_tidl_notify_cb()) {
                SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to unset notify callback");
@@ -890,42 +918,6 @@ static void  __vc_mgr_register_cb_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h
        pthread_mutex_lock(&g_mgr_tidl_info_mutex);
        SLOG(LOG_INFO, TAG_VCD, "@@@ VC MANAGER REGISTER CALLBACK");
 
-       int ret = -1;
-       ret = vcd_client_manager_create_tidl_info(pid);
-
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create manager tidl info.");
-               pthread_mutex_unlock(&g_mgr_tidl_info_mutex);
-               return;
-       }
-
-       manager_tidl_info_s* mgr_tidl_info = vcd_client_manager_get_tidl_info();
-
-       if (NULL == mgr_tidl_info) {
-               SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to get manager tidl info. pid(%d)", pid);
-               pthread_mutex_unlock(&g_mgr_tidl_info_mutex);
-               return;
-       }
-
-       char *sender = NULL;
-       rpc_port_stub_vcd_mgr_stub_vc_mgr_context_get_sender(context, &sender);
-
-       if (!sender){
-               SLOG(LOG_ERROR, TAG_VCD, "Sender is NULL");
-               pthread_mutex_unlock(&g_mgr_tidl_info_mutex);
-               return;
-       }
-
-       mgr_tidl_info->rpc_h = __mgr_create_rpc_port(sender);
-
-       if (NULL == mgr_tidl_info->rpc_h) {
-               SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to create server proxy");
-       } else {
-               SLOG(LOG_INFO, TAG_VCD, "[TIDL] rpc_h(%p), engine_app_id(%s)", mgr_tidl_info->rpc_h, sender);
-       }
-
-       free(sender);
-
        if (0 != vcd_client_manager_set_tidl_notify_cb(notify_callback, user_data)) {
                SLOG(LOG_ERROR, TAG_VCD, "[TIDL ERROR] Fail to set notify callback");
        } else {
@@ -940,8 +932,6 @@ static void  __vc_mgr_register_cb_cb(rpc_port_stub_vcd_mgr_stub_vc_mgr_context_h
 
        pthread_mutex_unlock(&g_mgr_tidl_info_mutex);
 
-       __request_tidl_connect(VCD_CLIENT_TYPE_MANAGER, pid);
-
        SLOG(LOG_DEBUG, TAG_VCD, "@@@ VC MANAGER REGISTER CALLBACK DONE");
 }