summaryrefslogtreecommitdiff
path: root/server/src/macrolist.cc
diff options
context:
space:
mode:
authordeva <deva>2010-01-06 08:50:13 +0000
committerdeva <deva>2010-01-06 08:50:13 +0000
commit91988574b7b8d3ccdf186daee9a0f9c33b3803bb (patch)
tree77628545d616be4b4a7bf23ec8f175cfe483e5f2 /server/src/macrolist.cc
parent0e819eb42b4d680a99ae7b04702bfc9510495aee (diff)
Made MacroList and TemplateList threadsafe.
Diffstat (limited to 'server/src/macrolist.cc')
-rw-r--r--server/src/macrolist.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/server/src/macrolist.cc b/server/src/macrolist.cc
index b67f239..0d0916d 100644
--- a/server/src/macrolist.cc
+++ b/server/src/macrolist.cc
@@ -58,6 +58,8 @@ static std::vector<std::string> listdir(std::string path)
MacroList::MacroList(std::string macropath)
{
+ MutexAutolock lock(mutex);
+
this->macropath = macropath;
std::vector<std::string> macros = listdir(macropath);
std::vector<std::string>::iterator i = macros.begin();
@@ -91,6 +93,8 @@ MacroList::MacroList(std::string macropath)
std::string MacroList::getLatestVersion(std::string macro) throw(Exception)
{
+ MutexAutolock lock(mutex);
+
if(find(macro) == end()) throw Exception("Macro ["+macro+"] does not exist");
MacroListItem mli = (*this)[macro];
if(mli.size() == 0) return "";
@@ -98,6 +102,7 @@ std::string MacroList::getLatestVersion(std::string macro) throw(Exception)
macro.c_str(),
(macropath + "/" + mli.begin()->second).c_str(),
((std::string)mli.begin()->first).c_str());
+
return macropath + "/" + mli.begin()->second;
}