|
@@ -414,6 +414,7 @@ CmdMan::CmdRet CmdMan::execute(string cmd, vector<string> args) {
|
|
|
for (string s : args)
|
|
|
DEBUGPRINT(s + " ");
|
|
|
DEBUGPRINT("]");
|
|
|
+ cmdmutex.lock();
|
|
|
map<string, CmdRet (CmdMan::*)(vector<string>)>::iterator execit = execmap.find(cmd);
|
|
|
vector<string>::const_iterator alwaysit;
|
|
|
vector<string>::const_iterator connectit;
|
|
@@ -431,6 +432,7 @@ CmdMan::CmdRet CmdMan::execute(string cmd, vector<string> args) {
|
|
|
root["command"] = "error";
|
|
|
root["error"] = string(__PRETTY_FUNCTION__) + " unknown command \"" + cmd + "\".\ntype help to list available commands.";
|
|
|
retval.msg = root;
|
|
|
+ cmdmutex.unlock();
|
|
|
return retval;
|
|
|
} else if (alwaysit != cmdAllowAlways.cend()) {
|
|
|
// Command should be usable in all cases
|
|
@@ -449,6 +451,7 @@ CmdMan::CmdRet CmdMan::execute(string cmd, vector<string> args) {
|
|
|
root["command"] = "error";
|
|
|
root["error"] = string("Not logged in. Available commands are limited to ") + allowedCommands + "\n" + "Use help for usage of these commands.";
|
|
|
retval.msg = root;
|
|
|
+ cmdmutex.unlock();
|
|
|
return retval;
|
|
|
}
|
|
|
} else if (currentState == versionpossible || currentState == doversion) {
|
|
@@ -459,6 +462,7 @@ CmdMan::CmdRet CmdMan::execute(string cmd, vector<string> args) {
|
|
|
root["command"] = "error";
|
|
|
root["error"] = string("Version not checked yet. No commands avalable.");
|
|
|
retval.msg = root;
|
|
|
+ cmdmutex.unlock();
|
|
|
return retval;
|
|
|
}
|
|
|
} else if (currentState == connectionpossible) {
|
|
@@ -469,10 +473,14 @@ CmdMan::CmdRet CmdMan::execute(string cmd, vector<string> args) {
|
|
|
root["command"] = "error";
|
|
|
root["error"] = string("Not connected. Connect using \"connect ip [port]\".");
|
|
|
retval.msg = root;
|
|
|
+ cmdmutex.unlock();
|
|
|
return retval;
|
|
|
}
|
|
|
}
|
|
|
- return (this->*(execmap[cmd]))(args);
|
|
|
+
|
|
|
+ retval = (this->*(execmap[cmd]))(args);
|
|
|
+ cmdmutex.unlock();
|
|
|
+ return retval;
|
|
|
}
|
|
|
|
|
|
CmdMan::CmdRet CmdMan::cmdDeleteme(vector<string> args) {
|
|
@@ -696,6 +704,7 @@ CmdMan::CmdRet CmdMan::handle(Json::Value root) {
|
|
|
CmdRet retval;
|
|
|
Json::Value output;
|
|
|
DEBUGPRINT(string(__PRETTY_FUNCTION__) + " begin");
|
|
|
+ cmdmutex.lock();
|
|
|
if (currentState == doversion)
|
|
|
root["command"] = "version";
|
|
|
else if (currentState == dosignup)
|
|
@@ -711,9 +720,12 @@ CmdMan::CmdRet CmdMan::handle(Json::Value root) {
|
|
|
output["command"] = "error";
|
|
|
output["error"] = string(__PRETTY_FUNCTION__) + " unknown command \"" + root["command"].asString() + "\".\nEnsure code is implemented.";
|
|
|
retval.msg = output;
|
|
|
+ cmdmutex.unlock();
|
|
|
return retval;
|
|
|
}
|
|
|
- return (this->*(handlemap[root["command"].asString()]))(root);
|
|
|
+ retval = (this->*(handlemap[root["command"].asString()]))(root);
|
|
|
+ cmdmutex.unlock();
|
|
|
+ return retval;
|
|
|
}
|
|
|
|
|
|
CmdMan::CmdRet CmdMan::handleStatus(Json::Value root) {
|