summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/contentDirectory.h2
-rw-r--r--include/webserver.h1
-rw-r--r--media/pluginManager.cpp1
-rw-r--r--plugins/provider/recProvider/recProvider.cpp8
-rw-r--r--plugins/provider/vdrProvider/vdrProvider.cpp7
-rw-r--r--server/contentDirectory.cpp3
-rw-r--r--server/webserver.cpp21
7 files changed, 31 insertions, 12 deletions
diff --git a/include/contentDirectory.h b/include/contentDirectory.h
index 92544a0..8c9a4b7 100644
--- a/include/contentDirectory.h
+++ b/include/contentDirectory.h
@@ -52,6 +52,8 @@ private:
void Action();
+ cCondWait sleep;
+
} ContentDirectory;
} // namespace upnp
diff --git a/include/webserver.h b/include/webserver.h
index 1147b04..2509870 100644
--- a/include/webserver.h
+++ b/include/webserver.h
@@ -58,6 +58,7 @@ namespace upnp {
class cWSThread : public cThread {
public:
cWSThread(cWebserver& webServer);
+ virtual ~cWSThread();
void Stop();
virtual void Action(void);
private:
diff --git a/media/pluginManager.cpp b/media/pluginManager.cpp
index 5f38aa8..67b24c6 100644
--- a/media/pluginManager.cpp
+++ b/media/pluginManager.cpp
@@ -425,6 +425,7 @@ bool upnp::cPluginManager::LoadPlugins(){
boost::shared_ptr<cUPnPResourceProvider> provider((cUPnPResourceProvider*)(dll->GetFunc()()));
providerFactory[provider->ProvidesSchema()] = (ResourceProviderFuncPtr)dll->GetFunc();
providers.push_back( provider );
+ provider->SetDescription("%s", provider->ProvidesSchema().c_str());
provider->Start();
} else {
boost::shared_ptr<cMediaProfiler> profiler((cMediaProfiler*)(dll->GetFunc()()));
diff --git a/plugins/provider/recProvider/recProvider.cpp b/plugins/provider/recProvider/recProvider.cpp
index 41ca849..8657cb3 100644
--- a/plugins/provider/recProvider/recProvider.cpp
+++ b/plugins/provider/recProvider/recProvider.cpp
@@ -80,6 +80,8 @@ private:
return OpenFile(1);
}
+ cCondWait sleep;
+
public:
RecProvider()
@@ -92,7 +94,8 @@ public:
}
virtual ~RecProvider(){
- Cancel(2);
+ sleep.Signal();
+ Cancel(5);
}
virtual string ProvidesSchema(){ return "rec"; }
@@ -256,6 +259,7 @@ public:
int state = 0;
time_t now;
bool update = false;
+
while(Running()){
update = false;
@@ -276,7 +280,7 @@ public:
if(update){
OnContainerUpdate(GetRootContainer(), GetContainerUpdateId(GetRootContainer()));
}
- sleep(10);
+ sleep.Wait(10000);
}
}
diff --git a/plugins/provider/vdrProvider/vdrProvider.cpp b/plugins/provider/vdrProvider/vdrProvider.cpp
index 6b4c1b1..f54f4e7 100644
--- a/plugins/provider/vdrProvider/vdrProvider.cpp
+++ b/plugins/provider/vdrProvider/vdrProvider.cpp
@@ -53,6 +53,8 @@ private:
return uri.substr(6,uri.size()-7);
}
+ cCondWait sleep;
+
public:
VdrProvider()
@@ -64,7 +66,8 @@ public:
}
virtual ~VdrProvider(){
- Cancel(2);
+ sleep.Signal();
+ Cancel(5);
}
virtual string ProvidesSchema(){ return "vdr"; }
@@ -207,7 +210,7 @@ public:
lastModified = now;
}
- sleep(2);
+ sleep.Wait(2000);
}
}
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);
}