From: Suyeon Hwang Date: Fri, 2 Jun 2023 11:27:19 +0000 (+0900) Subject: Destroy old rpc handle for clean reconnection X-Git-Tag: accepted/tizen/7.0/unified/20230904.170929~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f54552f9ce0be1f3035d4d2cea14511a23c15e7a;p=platform%2Fcore%2Fuifw%2Ftts.git Destroy old rpc handle for clean reconnection - Issue: When the client is disconnected, sometimes, the rpc handle can be expired. - Solution: When the client is disconnected, the client should try to reconnect. However, sometimes, the client can try to reconnect with expired rpc handle. In this case, the client library can not create new rpc handle, because current logic only makes new rpc handle if the function returns I/O error. To resolve this issue, this patch destroyes the old handle if the client is disconnected. Through this change, the client will be sure to reconnect with new rpc handle. Change-Id: Ic801abf2f69a291ca6b5c8748a67f987be81aa93 Signed-off-by: Suyeon Hwang --- diff --git a/client/tts_tidl.c b/client/tts_tidl.c index 7a1f0123..aef57d6b 100644 --- a/client/tts_tidl.c +++ b/client/tts_tidl.c @@ -134,6 +134,45 @@ static void __notify_cb(void *user_data, int pid, int uid, bundle *msg) } } +static void destroy_scheduled_handle(gpointer data) +{ + rpc_port_proxy_tts_h rpc_h = (rpc_port_proxy_tts_h)data; + int ret = rpc_port_proxy_tts_destroy(rpc_h); + if (RPC_PORT_ERROR_NONE != ret) { + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to destroy handle. ret(%d/%s)", ret, get_error_message(ret)); + } +} + +static Eina_Bool destroy_scheduled_handles_by_ecore_idler(void *user_data) +{ + SLOG(LOG_INFO, TAG_TTSC, "[INFO] Destroy RPC handles those are scheduled to be destroyed."); + g_slist_free_full(g_destruction_scheduled_handles, destroy_scheduled_handle); + g_destruction_scheduled_handles = NULL; + g_destroy_handles_idler = NULL; + + return EINA_FALSE; +} + +static inline void destroy_rpc_port(tts_tidl_info_s* info) +{ + RETM_IF(NULL == info->rpc_h, "[TIDL] Handle is already destroyed"); + + g_destruction_scheduled_handles = g_slist_append(g_destruction_scheduled_handles, info->rpc_h); + if (NULL == g_destroy_handles_idler) { + g_destroy_handles_idler = ecore_idler_add(destroy_scheduled_handles_by_ecore_idler, NULL); + } + + info->rpc_h = NULL; + info->notify_cb_h = NULL; + + free(info->engine_app_id); + info->engine_app_id = NULL; + + info->register_callback_invoked = false; + info->connection_requesting = false; + info->connected = false; +} + static void __on_connected(rpc_port_proxy_tts_h h, void *user_data) { unsigned int uid = (uintptr_t)user_data; @@ -167,6 +206,7 @@ static void __on_disconnected(rpc_port_proxy_tts_h h, void *user_data) SLOG(LOG_DEBUG, TAG_TTSC, "Disconnected from server"); if (tts_client_is_listening_started(uid)) { SLOG(LOG_DEBUG, TAG_TTSC, "Try to reconnect to server"); + destroy_rpc_port(info); tts_core_handle_service_reset(); } } @@ -223,45 +263,6 @@ int tts_tidl_open_connection(unsigned int uid) return TTS_ERROR_NONE; } -static void destroy_scheduled_handle(gpointer data) -{ - rpc_port_proxy_tts_h rpc_h = (rpc_port_proxy_tts_h)data; - int ret = rpc_port_proxy_tts_destroy(rpc_h); - if (RPC_PORT_ERROR_NONE != ret) { - SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to destroy handle. ret(%d/%s)", ret, get_error_message(ret)); - } -} - -static Eina_Bool destroy_scheduled_handles_by_ecore_idler(void *user_data) -{ - SLOG(LOG_INFO, TAG_TTSC, "[INFO] Destroy RPC handles those are scheduled to be destroyed."); - g_slist_free_full(g_destruction_scheduled_handles, destroy_scheduled_handle); - g_destruction_scheduled_handles = NULL; - g_destroy_handles_idler = NULL; - - return EINA_FALSE; -} - -static inline void destroy_rpc_port(tts_tidl_info_s* info) -{ - RETM_IF(NULL == info->rpc_h, "[TIDL] Handle is already destroyed"); - - g_destruction_scheduled_handles = g_slist_append(g_destruction_scheduled_handles, info->rpc_h); - if (NULL == g_destroy_handles_idler) { - g_destroy_handles_idler = ecore_idler_add(destroy_scheduled_handles_by_ecore_idler, NULL); - } - - info->rpc_h = NULL; - info->notify_cb_h = NULL; - - free(info->engine_app_id); - info->engine_app_id = NULL; - - info->register_callback_invoked = false; - info->connection_requesting = false; - info->connected = false; -} - int tts_tidl_close_connection(unsigned int uid) { SLOG(LOG_DEBUG, TAG_TTSC, "[TIDL] tts_tidl_close_connection");