mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 07:23:09 +02:00
yhttpd: cleaner shutdown
This commit is contained in:
@@ -104,6 +104,15 @@ void yhttpd_reload_config() {
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Main Entry
|
// Main Entry
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void thread_cleanup (void *p)
|
||||||
|
{
|
||||||
|
Cyhttpd *y = (Cyhttpd *)p;
|
||||||
|
if (y)
|
||||||
|
delete y;
|
||||||
|
y = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef Y_CONFIG_BUILD_AS_DAEMON
|
#ifndef Y_CONFIG_BUILD_AS_DAEMON
|
||||||
void * nhttpd_main_thread(void *) {
|
void * nhttpd_main_thread(void *) {
|
||||||
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0);
|
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0);
|
||||||
@@ -116,6 +125,8 @@ void * nhttpd_main_thread(void *) {
|
|||||||
aprintf("Error initializing WebServer\n");
|
aprintf("Error initializing WebServer\n");
|
||||||
return (void *) EXIT_FAILURE;
|
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->flag_threading_off = true;
|
||||||
|
|
||||||
yhttpd->hooks_attach();
|
yhttpd->hooks_attach();
|
||||||
@@ -127,7 +138,9 @@ void * nhttpd_main_thread(void *) {
|
|||||||
|
|
||||||
yhttpd->run();
|
yhttpd->run();
|
||||||
}
|
}
|
||||||
|
pthread_cleanup_pop(0);
|
||||||
delete yhttpd;
|
delete yhttpd;
|
||||||
|
yhttpd = NULL;
|
||||||
|
|
||||||
aprintf("Main end\n");
|
aprintf("Main end\n");
|
||||||
return (void *) EXIT_SUCCESS;
|
return (void *) EXIT_SUCCESS;
|
||||||
@@ -233,8 +246,10 @@ Cyhttpd::Cyhttpd() {
|
|||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
Cyhttpd::~Cyhttpd() {
|
Cyhttpd::~Cyhttpd() {
|
||||||
|
stop_webserver();
|
||||||
if (webserver)
|
if (webserver)
|
||||||
delete webserver;
|
delete webserver;
|
||||||
|
CLanguage::deleteInstance();
|
||||||
webserver = NULL;
|
webserver = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user