mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-26 15:02:56 +02:00
yhttpd: cleaner shutdown
This commit is contained in:
@@ -104,6 +104,15 @@ void yhttpd_reload_config() {
|
||||
//-----------------------------------------------------------------------------
|
||||
// Main Entry
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void thread_cleanup (void *p)
|
||||
{
|
||||
Cyhttpd *y = (Cyhttpd *)p;
|
||||
if (y)
|
||||
delete y;
|
||||
y = NULL;
|
||||
}
|
||||
|
||||
#ifndef Y_CONFIG_BUILD_AS_DAEMON
|
||||
void * nhttpd_main_thread(void *) {
|
||||
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0);
|
||||
@@ -116,6 +125,8 @@ void * nhttpd_main_thread(void *) {
|
||||
aprintf("Error initializing WebServer\n");
|
||||
return (void *) EXIT_FAILURE;
|
||||
}
|
||||
/* we pthread_cancel this thread from the main thread, but still want to clean up */
|
||||
pthread_cleanup_push(thread_cleanup, yhttpd);
|
||||
yhttpd->flag_threading_off = true;
|
||||
|
||||
yhttpd->hooks_attach();
|
||||
@@ -127,7 +138,9 @@ void * nhttpd_main_thread(void *) {
|
||||
|
||||
yhttpd->run();
|
||||
}
|
||||
pthread_cleanup_pop(0);
|
||||
delete yhttpd;
|
||||
yhttpd = NULL;
|
||||
|
||||
aprintf("Main end\n");
|
||||
return (void *) EXIT_SUCCESS;
|
||||
@@ -233,8 +246,10 @@ Cyhttpd::Cyhttpd() {
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
Cyhttpd::~Cyhttpd() {
|
||||
stop_webserver();
|
||||
if (webserver)
|
||||
delete webserver;
|
||||
CLanguage::deleteInstance();
|
||||
webserver = NULL;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user