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;
/* Function definition */
{
SLOG(LOG_ERROR, TAG_TTSC, "[DEBUG] create pkgmgr thread");
+ 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");
+ return ;
+ }
+
pthread_mutex_lock(&g_pkgmgr_mutex);
while (!g_pkgmgr) {
}
}
usleep(10000);
+
+ /* Checking handle which can be destroyed on other thread */
+ if (false == tts_client_is_valid(tts)) {
+ SLOG(LOG_INFO, TAG_TTSC, "[INFO] client is already destroyed");
+ break;
+ }
}
pthread_mutex_unlock(&g_pkgmgr_mutex);
-
return ;
}
static void __finish_pkgmgr_thread(void* data, Ecore_Thread* thread)
{
SLOG(LOG_ERROR, TAG_TTSC, "[DEBUG] Finish pkgmgr thread");
+ g_pkgmgr_thread = NULL;
}
static void __pkgmgr_thread(void* data)
{
SLOG(LOG_ERROR, TAG_TTSC, "[DEBUG] call pkgmgr_thread");
- ecore_thread_run(__create_pkgmgr_thread, __finish_pkgmgr_thread, NULL, NULL);
+ tts_h tts = (tts_h)data;
+ if (NULL == tts) {
+ SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Input handle is null");
+ return ;
+ }
+ if (NULL == g_pkgmgr_thread) {
+ SLOG(LOG_INFO, TAG_TTSC, "[INFO] ecore thread run: create_pkgmgr_thread");
+ g_pkgmgr_thread = ecore_thread_run(__create_pkgmgr_thread, __finish_pkgmgr_thread, NULL, tts);
+ }
return ;
}
return __tts_convert_config_error_code(ret);
}
- ecore_main_loop_thread_safe_call_async(__pkgmgr_thread, NULL);
+ ecore_main_loop_thread_safe_call_async(__pkgmgr_thread, *tts);
SLOG(LOG_INFO, TAG_TTSC, "[INFO] call ecore thread for creating pkgmgr thread");
/* Unset registered callbacks */
__tts_unset_all_callbacks(tts);
+ /* Check threads */
+ int thread_count = ecore_thread_active_get();
+ SLOG(LOG_INFO, TAG_TTSC, "[INFO] Active thread count: %d", thread_count);
+ int cnt = 0;
+ while (0 < thread_count) {
+ usleep(50000);
+ cnt++;
+ if (30 == cnt) {
+ SLOG(LOG_WARN, TAG_TTSC, "[WARNNING] Thread is blocked, %d", thread_count);
+ break;
+ }
+ thread_count = ecore_thread_active_get();
+ }
+
/* Free resources */
tts_client_destroy(tts);
+
break;
default:
{
SLOG(LOG_ERROR, TAG_TTSC, "[DEBUG] start reprepare thread. engine update status(%d)", g_engine_update_status);
- tts_client_s* temp = (tts_client_s*)data;
- if (NULL == temp) {
- SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] data is null");
- return ;
+ 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");
+ return;
}
int cnt = 0;
- while (!g_engine_update_status && (cnt < 10)) {
+ while (!g_engine_update_status && cnt < 20) {
SLOG(LOG_WARN, TAG_TTSC, "[WARNING] wait for starting update");
+ /* Checking handle which can be destroyed on other thread */
+ if (false == tts_client_is_valid(tts)) {
+ SLOG(LOG_INFO, TAG_TTSC, "[INFO] client is already destroyed");
+ return;
+ }
+
usleep(50000);
cnt++;
}
SLOG(LOG_ERROR, TAG_TTSC, "[DEBUG] update status(%d)", g_engine_update_status);
while (g_engine_update_status && (NULL != g_pkgmgr)) {
-// SLOG(LOG_WARN, TAG_TTSC, "[WARNING] wait for finishing update");
+ /* Checking handle which can be destroyed on other thread */
+ if (false == tts_client_is_valid(tts)) {
+ SLOG(LOG_INFO, TAG_TTSC, "[INFO] client is already destroyed");
+ return;
+ }
+
usleep(200000);
}
SLOG(LOG_INFO, TAG_TTSC, "[INFO] finish updating. request to prepare");
- if (0 != tts_prepare(temp->tts)) {
+ if (0 != tts_prepare(client->tts)) {
SLOG(LOG_ERROR, TAG_TTSC, "[ERROR] Fail to prepare");
}