mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-31 01:11:06 +02:00
CComponentsTimer: try to fix possible uncanceled thread
Origin commit data
------------------
Commit: e9122fbc4b
Author: Thilo Graf <dbt@novatux.de>
Date: 2016-12-29 (Thu, 29 Dec 2016)
This commit is contained in:
@@ -98,7 +98,8 @@ void CComponentsTimer::initThread()
|
|||||||
if (res != 0){
|
if (res != 0){
|
||||||
dprintf(DEBUG_NORMAL,"\033[33m[CComponentsTimer] [%s - %d] ERROR! pthread_create\033[0m\n", __func__, __LINE__);
|
dprintf(DEBUG_NORMAL,"\033[33m[CComponentsTimer] [%s - %d] ERROR! pthread_create\033[0m\n", __func__, __LINE__);
|
||||||
return;
|
return;
|
||||||
}
|
}else
|
||||||
|
dprintf(DEBUG_DEBUG,"\033[33m[CComponentsTimer] [%s - %d] started thread ID:%ld \033[0m\n", __func__, __LINE__, pthread_self());
|
||||||
|
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
CNeutrinoApp::getInstance()->OnBeforeRestart.connect(sl_stop_timer);
|
CNeutrinoApp::getInstance()->OnBeforeRestart.connect(sl_stop_timer);
|
||||||
@@ -111,17 +112,17 @@ void CComponentsTimer::stopThread()
|
|||||||
while (!sl_stop_timer.empty())
|
while (!sl_stop_timer.empty())
|
||||||
sl_stop_timer.disconnect();
|
sl_stop_timer.disconnect();
|
||||||
|
|
||||||
if(tm_thread) {
|
while(tm_thread) {
|
||||||
int thres = pthread_cancel(tm_thread);
|
int thres = pthread_cancel(tm_thread);
|
||||||
if (thres != 0)
|
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)
|
if (res != PTHREAD_CANCELED)
|
||||||
dprintf(DEBUG_NORMAL, "\033[33m[CComponentsTimer] [%s - %d] ERROR! pthread_join, [%d]\033[0m\n", __func__, __LINE__, thres);
|
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
|
||||||
if (thres == 0)
|
|
||||||
tm_thread = 0;
|
tm_thread = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user