diff --git a/src/gui/components/cc_timer.cpp b/src/gui/components/cc_timer.cpp index 566a829e1..11ae9b35e 100644 --- a/src/gui/components/cc_timer.cpp +++ b/src/gui/components/cc_timer.cpp @@ -98,7 +98,8 @@ void CComponentsTimer::initThread() if (res != 0){ dprintf(DEBUG_NORMAL,"\033[33m[CComponentsTimer] [%s - %d] ERROR! pthread_create\033[0m\n", __func__, __LINE__); return; - } + }else + dprintf(DEBUG_DEBUG,"\033[33m[CComponentsTimer] [%s - %d] started thread ID:%ld \033[0m\n", __func__, __LINE__, pthread_self()); if (res == 0) CNeutrinoApp::getInstance()->OnBeforeRestart.connect(sl_stop_timer); @@ -111,17 +112,17 @@ void CComponentsTimer::stopThread() while (!sl_stop_timer.empty()) sl_stop_timer.disconnect(); - if(tm_thread) { + while(tm_thread) { int thres = pthread_cancel(tm_thread); if (thres != 0) - dprintf(DEBUG_NORMAL,"\033[33m[CComponentsTimer] [%s - %d] ERROR! pthread_cancel, [%d]\033[0m\n", __func__, __LINE__, thres); + dprintf(DEBUG_NORMAL,"\033[33m[CComponentsTimer] [%s - %d] ERROR! pthread_cancel, error [%d] %s\033[0m\n", __func__, __LINE__, thres, strerror(thres)); - thres = pthread_join(tm_thread, NULL); + void* res; + thres = pthread_join(tm_thread, &res); - if (thres != 0) - dprintf(DEBUG_NORMAL, "\033[33m[CComponentsTimer] [%s - %d] ERROR! pthread_join, [%d]\033[0m\n", __func__, __LINE__, thres); - - if (thres == 0) + if (res != PTHREAD_CANCELED) + dprintf(DEBUG_NORMAL, "\033[33m[CComponentsTimer] [%s - %d] ERROR! pthread_join, thread ID:%ld, error [%d] %s\033[0m\n", __func__, __LINE__, pthread_self(), thres, strerror(thres)); + else tm_thread = 0; } }