summaryrefslogtreecommitdiffstats
path: root/src/Client/InformationManager.cpp
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-05-21 22:38:30 +0200
committerMatthias Schiffer <matthias@gamezock.de>2009-05-21 22:38:30 +0200
commite0e254548b6200d16bc3f4be3bd255b041a76532 (patch)
tree5665e3e5f3a54f63495f8f671fe911013a854ba5 /src/Client/InformationManager.cpp
parent02f8f9fe5ff81d5723bcbffef5a8dcc4e2adb156 (diff)
downloadmad-e0e254548b6200d16bc3f4be3bd255b041a76532.tar
mad-e0e254548b6200d16bc3f4be3bd255b041a76532.zip
InformationManager Thread-safe gemacht
Diffstat (limited to 'src/Client/InformationManager.cpp')
-rw-r--r--src/Client/InformationManager.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/Client/InformationManager.cpp b/src/Client/InformationManager.cpp
index f1627f4..8fde6f7 100644
--- a/src/Client/InformationManager.cpp
+++ b/src/Client/InformationManager.cpp
@@ -45,11 +45,15 @@ void InformationManager::DaemonStateUpdateRequestHandler::handlePacket(const Com
// TODO Require authentication
- std::map<std::string, Common::HostInfo>::iterator host = informationManager.get()->daemons.find(packet["name"]);
- if(host != informationManager.get()->daemons.end())
- host->second.setState(packet["state"]);
- else
- Common::Logger::log(Common::Logger::WARNING, "Received a state update for an unknown host.");
+ {
+ boost::lock_guard<boost::mutex> lock(informationManager.mutex);
+
+ std::map<std::string, Common::HostInfo>::iterator host = informationManager.daemons.find(packet["name"]);
+ if(host != informationManager.daemons.end())
+ host->second.setState(packet["state"]);
+ else
+ Common::Logger::log(Common::Logger::WARNING, "Received a state update for an unknown host.");
+ }
Common::XmlPacket ret;
ret.setType("OK");
@@ -68,6 +72,8 @@ void InformationManager::doDeinit() {
}
void InformationManager::updateDaemonList(Common::Connection *con) {
+ boost::lock_guard<boost::mutex> lock(mutex);
+
if(updating)
return;
@@ -78,6 +84,8 @@ void InformationManager::updateDaemonList(Common::Connection *con) {
}
void InformationManager::daemonListRequestFinished(const Common::Request &request) {
+ boost::lock_guard<boost::mutex> lock(mutex);
+
try {
const Common::XmlPacket &packet = request.getResult();
@@ -99,6 +107,8 @@ void InformationManager::daemonListRequestFinished(const Common::Request &reques
}
updating = false;
+
+ updateCond.notify_all();
}
}