diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/contentDirectory.cpp | 3 | ||||
-rw-r--r-- | server/webserver.cpp | 21 |
2 files changed, 16 insertions, 8 deletions
diff --git a/server/contentDirectory.cpp b/server/contentDirectory.cpp index c014804..9b30c5f 100644 --- a/server/contentDirectory.cpp +++ b/server/contentDirectory.cpp @@ -104,11 +104,12 @@ void cContentDirectory::Action(){ this->Cancel(); } // Sleep 2 seconds - cCondWait::SleepMs(2000); + sleep.Wait(2000); } } void cContentDirectory::Stop(){ + this->sleep.Signal(); this->Cancel(2); } diff --git a/server/webserver.cpp b/server/webserver.cpp index b440a83..e76d519 100644 --- a/server/webserver.cpp +++ b/server/webserver.cpp @@ -26,7 +26,6 @@ cWebserver::cWebserver(std::string address) } cWebserver::~cWebserver(){ - mWebserverThread.Stop(); Stop(); } @@ -35,11 +34,7 @@ bool cWebserver::Start(){ } void cWebserver::Stop(){ - try { - mApplication.shutdown(); - } catch (const std::exception& e){ - esyslog("UPnP\tError while stopping web server: %s", e.what()); - } + mWebserverThread.Stop(); } bool cWebserver::Initialise(){ @@ -166,15 +161,27 @@ cWebserver::cWSThread::cWSThread(cWebserver& webServer) { } +cWebserver::cWSThread::~cWSThread(){ + Stop(); +} + void cWebserver::cWSThread::Action(){ try { - mWebserver.mApplication.run(); + if(Running()){ + mWebserver.mApplication.run(); + dsyslog("UPnP\tStarted web server thread."); + } } catch (const std::exception& e){ esyslog("UPnP\tError while starting web server: %s", e.what()); } } void cWebserver::cWSThread::Stop(){ + try { + tnt::Tntnet::shutdown(); + } catch (const std::exception& e){ + esyslog("UPnP\tError while stopping web server: %s", e.what()); + } Cancel(5); } |