diff options
author | Matthias Schiffer <matthias@gamezock.de> | 2009-09-03 20:16:23 +0200 |
---|---|---|
committer | Matthias Schiffer <matthias@gamezock.de> | 2009-09-03 20:16:23 +0200 |
commit | fca6c1a831393e173706a5b5c798c35dc5f7d3e6 (patch) | |
tree | 38b4b6f59a10736e869eaf460020bf28b4bc8c3d /src/modules/AuthProviderFile | |
parent | 23d4cc1dfa5602c266f2f3d71f845f9ef0789b89 (diff) | |
download | mad-fca6c1a831393e173706a5b5c798c35dc5f7d3e6.tar mad-fca6c1a831393e173706a5b5c798c35dc5f7d3e6.zip |
Thread-Sicherheit verbessert
Diffstat (limited to 'src/modules/AuthProviderFile')
-rw-r--r-- | src/modules/AuthProviderFile/AuthProviderFile.cpp | 8 | ||||
-rw-r--r-- | src/modules/AuthProviderFile/AuthProviderFile.h | 4 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/modules/AuthProviderFile/AuthProviderFile.cpp b/src/modules/AuthProviderFile/AuthProviderFile.cpp index 99af6b6..1756747 100644 --- a/src/modules/AuthProviderFile/AuthProviderFile.cpp +++ b/src/modules/AuthProviderFile/AuthProviderFile.cpp @@ -26,6 +26,7 @@ #include <fstream> #include <boost/regex.hpp> +#include <boost/thread/locks.hpp> namespace Mad { namespace Modules { @@ -56,6 +57,7 @@ void AuthProviderFile::readFile(const std::string &name) { std::string password = match[2].str(); if(filehash.empty()) { + boost::lock_guard<boost::mutex> lock(mutex); userMap.insert(std::make_pair(match[1].str(), std::vector<boost::uint8_t>(password.begin(), password.end()))); } else { @@ -75,8 +77,10 @@ void AuthProviderFile::readFile(const std::string &name) { data.push_back(byte); } - if(!data.empty()) + if(!data.empty()) { + boost::lock_guard<boost::mutex> lock(mutex); userMap.insert(std::make_pair(match[1].str(), data)); + } } } } @@ -137,6 +141,8 @@ bool AuthProviderFile::checkPassword(const std::string &user, const std::vector< } std::vector<boost::uint8_t> AuthProviderFile::getPassword(const std::string &user, const std::string &hash) throw(Core::Exception) { + boost::lock_guard<boost::mutex> lock(mutex); + std::map<std::string, std::vector<boost::uint8_t> >::iterator userIt = userMap.find(user); if(userIt == userMap.end()) return std::vector<boost::uint8_t>(); diff --git a/src/modules/AuthProviderFile/AuthProviderFile.h b/src/modules/AuthProviderFile/AuthProviderFile.h index 99deaa0..63f3d28 100644 --- a/src/modules/AuthProviderFile/AuthProviderFile.h +++ b/src/modules/AuthProviderFile/AuthProviderFile.h @@ -28,6 +28,8 @@ #include <Core/Configurable.h> #include <Core/ConfigManager.h> +#include <boost/thread/mutex.hpp> + namespace Mad { namespace Modules { namespace AuthProviderFile { @@ -38,6 +40,8 @@ class MAD_MODULE_EXPORT AuthProviderFile : public Common::AuthProvider, private Common::Application *application; + boost::mutex mutex; + std::map<std::string, std::vector<boost::uint8_t> > userMap; std::vector<std::string> files; |