From a8ddbaffa498e5374b7a7ecd31bb0cc2f0b0b90e Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Thu, 8 Dec 2022 11:02:12 +0900 Subject: [PATCH] Try to reprepare when IPC I/O error occurs - Issue: TTS API will be failed when the engine is terminated after the client library already sends request. - Solution: Current client library does not handle the network connection failed situation because almost those situations are covered by reprepare logic. However, if the engine is terminated without handling client IPC message, client library should returns error. Thus, this patch adds new retry logic when network error occurs. Through this logic, some of the issue case will be covered. However, if engine has critical issue, then this logic also can cover those situations. Change-Id: I07075e0139d058f9f9bc84026a00309bf1815066 Signed-off-by: Suyeon Hwang --- client/tts_core.c | 10 ++++++++-- client/tts_tidl.c | 11 +++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/client/tts_core.c b/client/tts_core.c index 34d7679f..74fc0953 100644 --- a/client/tts_core.c +++ b/client/tts_core.c @@ -597,8 +597,14 @@ static inline bool __is_ipc_retry_needed(tts_client_s* client, tts_error_e ret) return true; } - if (TTS_ERROR_INVALID_PARAMETER == ret && false == tts_client_is_reprepared(client)) { - SLOG(LOG_WARN, TAG_TTSC, "[WARNING] IPC is failed by unregistered client. ret(%d/%s)", ret, get_error_message(ret)); + if (tts_client_is_reprepared(client)) { + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Prepare was already tried."); + SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] IPC request is failed. ret(%d/%s)", ret, get_error_message(ret)); + return false; + } + + if (TTS_ERROR_INVALID_PARAMETER == ret || TTS_ERROR_IO_ERROR == ret) { + SLOG(LOG_WARN, TAG_TTSC, "[WARNING] IPC is failed by unregistered client or network error. ret(%d/%s)", ret, get_error_message(ret)); SLOG(LOG_WARN, TAG_TTSC, "[WARNING] Try to prepare again"); tts_client_set_current_state(client, TTS_STATE_CREATED); tts_core_prepare_sync(client); diff --git a/client/tts_tidl.c b/client/tts_tidl.c index 36bfa0e6..dd10bc83 100644 --- a/client/tts_tidl.c +++ b/client/tts_tidl.c @@ -394,8 +394,15 @@ static int __request_tidl_connect_sync(tts_tidl_info_s* info) static int __convert_unhandled_error(int ret) { - if (RPC_PORT_ERROR_IO_ERROR == ret || RPC_PORT_ERROR_OUT_OF_MEMORY == ret) { - return TTS_ERROR_OPERATION_FAILED; + switch (ret) { + case RPC_PORT_ERROR_IO_ERROR: + return TTS_ERROR_IO_ERROR; + + case RPC_PORT_ERROR_OUT_OF_MEMORY: + return TTS_ERROR_OUT_OF_MEMORY; + + default: + break; } return ret; -- 2.34.1