mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-31 01:11:12 +02:00
neutrino: avoid crash when signals are caught during start
this needs more work to avoid crashes when interrupted early Signed-off-by: Jacek Jendrzej <crashdvb@googlemail.com>
This commit is contained in:
committed by
Jacek Jendrzej
parent
0b17e2f98e
commit
b6df7de7f7
@@ -133,9 +133,11 @@ t_channel_id standby_channel_id;
|
|||||||
//NEW
|
//NEW
|
||||||
static pthread_t timer_thread;
|
static pthread_t timer_thread;
|
||||||
void * timerd_main_thread(void *data);
|
void * timerd_main_thread(void *data);
|
||||||
|
static bool timerd_thread_started = false;
|
||||||
|
|
||||||
void * nhttpd_main_thread(void *data);
|
void * nhttpd_main_thread(void *data);
|
||||||
static pthread_t nhttpd_thread ;
|
static pthread_t nhttpd_thread ;
|
||||||
|
static bool nhttpd_thread_started = false;
|
||||||
|
|
||||||
//#define DISABLE_SECTIONSD
|
//#define DISABLE_SECTIONSD
|
||||||
|
|
||||||
@@ -1812,6 +1814,7 @@ TIMER_START();
|
|||||||
bool timer_wakeup = false;
|
bool timer_wakeup = false;
|
||||||
wake_up( timer_wakeup );
|
wake_up( timer_wakeup );
|
||||||
pthread_create (&timer_thread, NULL, timerd_main_thread, (void *) timer_wakeup);
|
pthread_create (&timer_thread, NULL, timerd_main_thread, (void *) timer_wakeup);
|
||||||
|
timerd_thread_started = true;
|
||||||
|
|
||||||
init_cec_setting = true;
|
init_cec_setting = true;
|
||||||
if(!(g_settings.shutdown_timer_record_type && timer_wakeup && g_settings.hdmi_cec_mode)){
|
if(!(g_settings.shutdown_timer_record_type && timer_wakeup && g_settings.hdmi_cec_mode)){
|
||||||
@@ -1844,6 +1847,7 @@ TIMER_START();
|
|||||||
dvbsub_init();
|
dvbsub_init();
|
||||||
|
|
||||||
pthread_create (&nhttpd_thread, NULL, nhttpd_main_thread, (void *) NULL);
|
pthread_create (&nhttpd_thread, NULL, nhttpd_main_thread, (void *) NULL);
|
||||||
|
nhttpd_thread_started = true;
|
||||||
|
|
||||||
CStreamManager::getInstance()->Start();
|
CStreamManager::getInstance()->Start();
|
||||||
|
|
||||||
@@ -3507,14 +3511,18 @@ void stop_daemons(bool stopall)
|
|||||||
g_Radiotext = NULL;
|
g_Radiotext = NULL;
|
||||||
}
|
}
|
||||||
printf("httpd shutdown\n");
|
printf("httpd shutdown\n");
|
||||||
pthread_cancel(nhttpd_thread);
|
if (nhttpd_thread_started) {
|
||||||
pthread_join(nhttpd_thread, NULL);
|
pthread_cancel(nhttpd_thread);
|
||||||
|
pthread_join(nhttpd_thread, NULL);
|
||||||
|
}
|
||||||
printf("httpd shutdown done\n");
|
printf("httpd shutdown done\n");
|
||||||
CStreamManager::getInstance()->Stop();
|
CStreamManager::getInstance()->Stop();
|
||||||
if(stopall) {
|
if(stopall) {
|
||||||
printf("timerd shutdown\n");
|
printf("timerd shutdown\n");
|
||||||
g_Timerd->shutdown();
|
if (g_Timerd)
|
||||||
pthread_join(timer_thread, NULL);
|
g_Timerd->shutdown();
|
||||||
|
if (timerd_thread_started)
|
||||||
|
pthread_join(timer_thread, NULL);
|
||||||
printf("timerd shutdown done\n");
|
printf("timerd shutdown done\n");
|
||||||
}
|
}
|
||||||
#ifndef DISABLE_SECTIONSD
|
#ifndef DISABLE_SECTIONSD
|
||||||
@@ -3575,6 +3583,9 @@ void sighandler (int signum)
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
g_Timerd = NULL;
|
||||||
|
g_Radiotext = NULL;
|
||||||
|
g_Zapit = NULL;
|
||||||
setDebugLevel(DEBUG_NORMAL);
|
setDebugLevel(DEBUG_NORMAL);
|
||||||
signal(SIGTERM, sighandler); // TODO: consider the following
|
signal(SIGTERM, sighandler); // TODO: consider the following
|
||||||
signal(SIGINT, sighandler); // NOTES: The effects of signal() in a multithreaded
|
signal(SIGINT, sighandler); // NOTES: The effects of signal() in a multithreaded
|
||||||
|
Reference in New Issue
Block a user