From a2b3d86cd444a476d875e7f9be1f913af53cec0f Mon Sep 17 00:00:00 2001 From: "wn.jang" Date: Fri, 23 Sep 2022 16:50:49 +0900 Subject: [PATCH] Add logic to avoid reconnetion when finalize Cause: The on_disconnect() cb is called, even a client requtests to disconnect. Change-Id: I463ad1321968cc86b775125b220dfc8f1ce8b9b3 Solution: Check whether ipc listening state or not when tries to reconnect. --- client/vc.c | 5 +++++ client/vc_client.c | 21 +++++++++++++++++++++ client/vc_client.h | 3 +++ client/vc_tidl.c | 17 ++++------------- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/client/vc.c b/client/vc.c index 1e2cdad..2f18575 100644 --- a/client/vc.c +++ b/client/vc.c @@ -404,6 +404,9 @@ static void __vc_internal_unprepare(void) SLOG(LOG_ERROR, TAG_VCC, "[ERROR] Fail to request finalize : %s", __vc_get_error_code(ret)); //LCOV_EXCL_LINE } + /* TODO set_start_listening should be move to proper place */ + vc_client_set_start_listening(false); + if (NULL != g_focus_in_handler) { ecore_event_handler_del(g_focus_in_handler); g_focus_in_handler = NULL; @@ -599,6 +602,8 @@ static Eina_Bool __vc_connect_daemon(void *data) SLOG(LOG_ERROR, TAG_VCC, "[Not ERROR] The current client is not valid. It is destroyed."); //LCOV_EXCL_LINE return EINA_FALSE; } + /* TODO set_start_listening should be move to proper place */ + vc_client_set_start_listening(true); SLOG(LOG_DEBUG, TAG_VCC, "@@@ [Client] Connect daemon DONE"); diff --git a/client/vc_client.c b/client/vc_client.c index 442ac1f..601b840 100644 --- a/client/vc_client.c +++ b/client/vc_client.c @@ -69,6 +69,9 @@ typedef struct { /* Invocation name */ char* invocation_name; + + /* Listening IPC message from service */ + bool start_listening; } vc_client_s; static vc_client_s *g_client = NULL; @@ -124,6 +127,7 @@ int vc_client_create(void) g_client->is_foreground = false; g_client->invocation_name = NULL; + g_client->start_listening = false; SLOG(LOG_INFO, TAG_VCC, "[INFO] client create. pid(%u)", g_client->pid); @@ -616,3 +620,20 @@ int vc_client_get_tts_utterance_status_cb(vc_tts_utterance_status_cb* callback, return VC_ERROR_NONE; } + +int vc_client_set_start_listening(bool is_listening_started) +{ + if (NULL == g_client) + return VC_ERROR_INVALID_PARAMETER; + + g_client->start_listening = is_listening_started; + return VC_ERROR_NONE; +} + +bool vc_client_is_listening_started() +{ + if (NULL == g_client) + return false; + + return g_client->start_listening; +} \ No newline at end of file diff --git a/client/vc_client.h b/client/vc_client.h index 21c3ea9..3505421 100644 --- a/client/vc_client.h +++ b/client/vc_client.h @@ -126,6 +126,9 @@ int vc_client_set_tts_utterance_status_cb(vc_tts_utterance_status_cb callback, v int vc_client_get_tts_utterance_status_cb(vc_tts_utterance_status_cb* callback, void** user_data); +int vc_client_set_start_listening(bool is_listening_started); + +bool vc_client_is_listening_started(); #ifdef __cplusplus } diff --git a/client/vc_tidl.c b/client/vc_tidl.c index b9c5a18..b38097e 100644 --- a/client/vc_tidl.c +++ b/client/vc_tidl.c @@ -18,6 +18,7 @@ #include "vc_tidl.h" #include "vc_proxy.h" #include "vc_main.h" +#include "vc_client.h" #include @@ -113,8 +114,9 @@ static void __on_disconnected(rpc_port_proxy_vc_proxy_vc_h h, void* user_data) /* retry to connect */ SLOG(LOG_INFO, TAG_VCC, "[INFO] Disconnected to server"); - __vc_cb_error(VC_ERROR_SERVICE_RESET, "Server Disconnected"); - + if (vc_client_is_listening_started()) { + __vc_cb_error(VC_ERROR_SERVICE_RESET, "Server Disconnected"); + } } static void __on_rejected(rpc_port_proxy_vc_proxy_vc_h h, void* user_data) @@ -502,17 +504,6 @@ int vc_tidl_request_finalize(int pid) return ret; } - ret = rpc_port_proxy_vc_proxy_vc_disconnect(info->rpc_h); - exception = get_last_result(); - if (RPC_PORT_ERROR_NONE != exception) { - ret = __convert_unhandled_error(exception); - } - - if (VC_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_VCC, ">>>> Request vc finalize : Fail to disconnect. err(%d)", ret); - return ret; - } - SLOG(LOG_DEBUG, TAG_VCC, "@@ vc finalize : result = %d", ret); return VC_ERROR_NONE; -- 2.7.4