From: sooyeon.kim Date: Wed, 4 Nov 2020 08:40:26 +0000 (+0900) Subject: Add a checker whether pkgmgr_thread is done or not X-Git-Tag: submit/tizen/20201109.074204~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9339aa3a13b0c63d6a0d85bf4d9c4383f749f23e;p=platform%2Fcore%2Fuifw%2Ftts.git Add a checker whether pkgmgr_thread is done or not Change-Id: I78b3c3cbcf6af9b50e2514a1b62837695376bc17 Signed-off-by: sooyeon.kim --- diff --git a/client/tts.c b/client/tts.c index 08283682..3f6a1be2 100644 --- a/client/tts.c +++ b/client/tts.c @@ -59,6 +59,7 @@ static char g_engine_appid[256]; static int g_engine_update_status = 0; static pthread_mutex_t g_pkgmgr_mutex = PTHREAD_MUTEX_INITIALIZER; static Ecore_Thread* g_pkgmgr_thread = NULL; +static volatile bool g_is_finished_pkgmgr_thread = false; static bool __is_engine_launched(const char* appid); /* Function definition */ @@ -319,11 +320,14 @@ static void __create_pkgmgr_thread(void* data, Ecore_Thread* thread) { SLOG(LOG_ERROR, TAG_TTSC, "[DEBUG] create pkgmgr thread"); + g_is_finished_pkgmgr_thread = false; + tts_h tts = (tts_h)data; tts_client_s* client = tts_client_get(tts); /* check handle */ if (NULL == client) { SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] client is null"); + g_is_finished_pkgmgr_thread = true; return ; } @@ -369,6 +373,9 @@ static void __create_pkgmgr_thread(void* data, Ecore_Thread* thread) } pthread_mutex_unlock(&g_pkgmgr_mutex); + g_is_finished_pkgmgr_thread = true; + SLOG(LOG_ERROR, TAG_TTSC, "[INFO] Finish pkgmgr_thread. func_end will be invoked in main thread."); + return ; } @@ -631,8 +638,8 @@ int tts_destroy(tts_h tts) __tts_unset_all_callbacks(tts); /* Cancel and Check threads */ - if (NULL != g_pkgmgr_thread && false == ecore_thread_check(g_pkgmgr_thread)) { - SLOG(LOG_INFO, TAG_TTSC, "[INFO] Cancel pkgmgr thread"); + if (NULL != g_pkgmgr_thread && false == ecore_thread_check(g_pkgmgr_thread) && false == g_is_finished_pkgmgr_thread) { + SLOG(LOG_INFO, TAG_TTSC, "[INFO] pkgmgr thread is not finished. Cancel pkgmgr thread"); ecore_thread_cancel(g_pkgmgr_thread); } if (NULL != client->thread && false == ecore_thread_check(client->thread)) {