Changed in Libresapi: Locking mutex using macro instead of RsStackMutex object creation

This commit is contained in:
Konrad 2018-01-01 23:20:26 +01:00
parent 74a56f646d
commit 6a61e0a781
7 changed files with 54 additions and 54 deletions

View File

@ -200,13 +200,13 @@ ChatHandler::~ChatHandler()
void ChatHandler::notifyChatMessage(const ChatMessage &msg) void ChatHandler::notifyChatMessage(const ChatMessage &msg)
{ {
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
mRawMsgs.push_back(msg); mRawMsgs.push_back(msg);
} }
void ChatHandler::notifyChatCleared(const ChatId &chat_id) void ChatHandler::notifyChatCleared(const ChatId &chat_id)
{ {
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
//Remove processed messages //Remove processed messages
std::list<Msg>& msgs = mMsgs[chat_id]; std::list<Msg>& msgs = mMsgs[chat_id];
msgs.clear(); msgs.clear();
@ -225,14 +225,14 @@ void ChatHandler::notifyChatCleared(const ChatId &chat_id)
void ChatHandler::notifyChatStatus(const ChatId &chat_id, const std::string &status) void ChatHandler::notifyChatStatus(const ChatId &chat_id, const std::string &status)
{ {
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
locked_storeTypingInfo(chat_id, status); locked_storeTypingInfo(chat_id, status);
} }
void ChatHandler::notifyChatLobbyEvent(uint64_t lobby_id, uint32_t event_type, void ChatHandler::notifyChatLobbyEvent(uint64_t lobby_id, uint32_t event_type,
const RsGxsId &nickname, const std::string& any_string) const RsGxsId &nickname, const std::string& any_string)
{ {
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
if(event_type == RS_CHAT_LOBBY_EVENT_PEER_STATUS) if(event_type == RS_CHAT_LOBBY_EVENT_PEER_STATUS)
{ {
locked_storeTypingInfo(ChatId(lobby_id), any_string, nickname); locked_storeTypingInfo(ChatId(lobby_id), any_string, nickname);
@ -243,14 +243,14 @@ void ChatHandler::notifyListChange(int list, int /*type*/)
{ {
if(list == NOTIFY_LIST_CHAT_LOBBY_INVITATION) if(list == NOTIFY_LIST_CHAT_LOBBY_INVITATION)
{ {
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
mStateTokenServer->replaceToken(mInvitationsStateToken); mStateTokenServer->replaceToken(mInvitationsStateToken);
} }
} }
void ChatHandler::tick() void ChatHandler::tick()
{ {
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
// first fetch lobbies // first fetch lobbies
std::vector<Lobby> lobbies; std::vector<Lobby> lobbies;
@ -868,7 +868,7 @@ void ChatHandler::locked_storeTypingInfo(const ChatId &chat_id, std::string stat
void ChatHandler::handleWildcard(Request &/*req*/, Response &resp) void ChatHandler::handleWildcard(Request &/*req*/, Response &resp)
{ {
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
resp.mDataStream.getStreamToMember(); resp.mDataStream.getStreamToMember();
for(std::map<ChatId, std::list<Msg> >::iterator mit = mMsgs.begin(); mit != mMsgs.end(); ++mit) for(std::map<ChatId, std::list<Msg> >::iterator mit = mMsgs.begin(); mit != mMsgs.end(); ++mit)
{ {
@ -882,7 +882,7 @@ void ChatHandler::handleLobbies(Request &/*req*/, Response &resp)
tick(); tick();
{ {
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
resp.mDataStream.getStreamToMember(); resp.mDataStream.getStreamToMember();
for(std::vector<Lobby>::iterator vit = mLobbies.begin(); vit != mLobbies.end(); ++vit) for(std::vector<Lobby>::iterator vit = mLobbies.begin(); vit != mLobbies.end(); ++vit)
{ {
@ -1021,7 +1021,7 @@ void ChatHandler::handleAnswerToInvitation(Request& req, Response& resp)
ResponseTask* ChatHandler::handleLobbyParticipants(Request &req, Response &resp) ResponseTask* ChatHandler::handleLobbyParticipants(Request &req, Response &resp)
{ {
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
ChatId id(req.mPath.top()); ChatId id(req.mPath.top());
if(!id.isLobbyId()) if(!id.isLobbyId())
@ -1122,7 +1122,7 @@ void ChatHandler::handleMessages(Request &req, Response &resp)
tick(); tick();
{ {
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
ChatId id(req.mPath.top()); ChatId id(req.mPath.top());
// make response a list // make response a list
@ -1204,7 +1204,7 @@ void ChatHandler::handleMarkMessageAsRead(Request &req, Response &resp)
void ChatHandler::handleMarkChatAsRead(Request &req, Response &resp) void ChatHandler::handleMarkChatAsRead(Request &req, Response &resp)
{ {
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
ChatId id(req.mPath.top()); ChatId id(req.mPath.top());
if(id.isNotSet()) if(id.isNotSet())
@ -1235,7 +1235,7 @@ void ChatHandler::handleMarkChatAsRead(Request &req, Response &resp)
void ChatHandler::handleInfo(Request &req, Response &resp) void ChatHandler::handleInfo(Request &req, Response &resp)
{ {
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
ChatId id(req.mPath.top()); ChatId id(req.mPath.top());
if(id.isNotSet()) if(id.isNotSet())
{ {
@ -1319,7 +1319,7 @@ protected:
ResponseTask* ChatHandler::handleReceiveStatus(Request &req, Response &resp) ResponseTask* ChatHandler::handleReceiveStatus(Request &req, Response &resp)
{ {
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
ChatId id(req.mPath.top()); ChatId id(req.mPath.top());
if(id.isNotSet()) if(id.isNotSet())
{ {
@ -1354,7 +1354,7 @@ void ChatHandler::handleSendStatus(Request &req, Response &resp)
void ChatHandler::handleUnreadMsgs(Request &/*req*/, Response &resp) void ChatHandler::handleUnreadMsgs(Request &/*req*/, Response &resp)
{ {
RS_STACK_MUTEX(mMtx); /********** LOCKED **********/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
resp.mDataStream.getStreamToMember(); resp.mDataStream.getStreamToMember();
for( std::map<ChatId, std::list<Msg> >::const_iterator mit = mMsgs.begin(); for( std::map<ChatId, std::list<Msg> >::const_iterator mit = mMsgs.begin();

View File

@ -31,7 +31,7 @@ FileSearchHandler::~FileSearchHandler()
void FileSearchHandler::notifyTurtleSearchResult(uint32_t search_id, const std::list<TurtleFileInfo>& files) void FileSearchHandler::notifyTurtleSearchResult(uint32_t search_id, const std::list<TurtleFileInfo>& files)
{ {
RsStackMutex stackMtx(mMtx); // ********** STACK LOCKED MTX ********** RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
std::map<uint32_t, Search>::iterator mit = mSearches.find(search_id); std::map<uint32_t, Search>::iterator mit = mSearches.find(search_id);
if(mit == mSearches.end()) if(mit == mSearches.end())
return; return;
@ -85,7 +85,7 @@ void FileSearchHandler::handleWildcard(Request &req, Response &resp)
} }
{ {
RsStackMutex stackMtx(mMtx); // ********** STACK LOCKED MTX ********** RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
std::map<uint32_t, Search>::iterator mit = mSearches.find(id); std::map<uint32_t, Search>::iterator mit = mSearches.find(id);
if(mit == mSearches.end()) if(mit == mSearches.end())
{ {
@ -115,7 +115,7 @@ void FileSearchHandler::handleWildcard(Request &req, Response &resp)
else else
{ {
// list searches // list searches
RsStackMutex stackMtx(mMtx); // ********** STACK LOCKED MTX ********** RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
resp.mDataStream.getStreamToMember(); resp.mDataStream.getStreamToMember();
for(std::map<uint32_t, Search>::iterator mit = mSearches.begin(); mit != mSearches.end(); ++mit) for(std::map<uint32_t, Search>::iterator mit = mSearches.begin(); mit != mSearches.end(); ++mit)
{ {
@ -221,7 +221,7 @@ void FileSearchHandler::handleCreateSearch(Request &req, Response &resp)
} }
{ {
RsStackMutex stackMtx(mMtx); // ********** STACK LOCKED MTX ********** RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
Search& search = mSearches[search_id]; Search& search = mSearches[search_id];
search.mStateToken = mStateTokenServer->getNewToken(); search.mStateToken = mStateTokenServer->getNewToken();
@ -262,7 +262,7 @@ void FileSearchHandler::handleGetSearchResult(Request& req, Response& resp)
} }
{ {
RsStackMutex stackMtx(mMtx); // ********** STACK LOCKED MTX ********** RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
std::map<uint32_t, Search>::iterator mit = mSearches.find(id); std::map<uint32_t, Search>::iterator mit = mSearches.find(id);
if(mit == mSearches.end()) if(mit == mSearches.end())
{ {

View File

@ -56,13 +56,13 @@ void FileSharingHandler::notifyListChange(int list, int /* type */)
{ {
if(list == NOTIFY_LIST_DIRLIST_LOCAL) if(list == NOTIFY_LIST_DIRLIST_LOCAL)
{ {
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/ RS_STACK_MUTEX(mMtx);
mStateTokenServer->discardToken(mLocalDirStateToken); mStateTokenServer->discardToken(mLocalDirStateToken);
mLocalDirStateToken = mStateTokenServer->getNewToken(); mLocalDirStateToken = mStateTokenServer->getNewToken();
} }
else if(list == NOTIFY_LIST_DIRLIST_FRIENDS) else if(list == NOTIFY_LIST_DIRLIST_FRIENDS)
{ {
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/ RS_STACK_MUTEX(mMtx);
mStateTokenServer->discardToken(mRemoteDirStateToken); mStateTokenServer->discardToken(mRemoteDirStateToken);
mRemoteDirStateToken = mStateTokenServer->getNewToken(); mRemoteDirStateToken = mStateTokenServer->getNewToken();
} }

View File

@ -374,7 +374,7 @@ void IdentityHandler::handleAddContact(Request& req, Response& resp)
mRsIdentity->setAsRegularContact(RsGxsId(gxs_id), true); mRsIdentity->setAsRegularContact(RsGxsId(gxs_id), true);
{ {
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
mStateTokenServer->replaceToken(mStateToken); mStateTokenServer->replaceToken(mStateToken);
} }
@ -389,7 +389,7 @@ void IdentityHandler::handleRemoveContact(Request& req, Response& resp)
mRsIdentity->setAsRegularContact(RsGxsId(gxs_id), false); mRsIdentity->setAsRegularContact(RsGxsId(gxs_id), false);
{ {
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
mStateTokenServer->replaceToken(mStateToken); mStateTokenServer->replaceToken(mStateToken);
} }

View File

@ -267,9 +267,9 @@ PeersHandler::~PeersHandler()
void PeersHandler::notifyListChange(int list, int /* type */) void PeersHandler::notifyListChange(int list, int /* type */)
{ {
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/
if(list == NOTIFY_LIST_FRIENDS) if(list == NOTIFY_LIST_FRIENDS)
{ {
RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
mStateTokenServer->discardToken(mStateToken); mStateTokenServer->discardToken(mStateToken);
mStateToken = mStateTokenServer->getNewToken(); mStateToken = mStateTokenServer->getNewToken();
} }
@ -277,13 +277,13 @@ void PeersHandler::notifyListChange(int list, int /* type */)
void PeersHandler::notifyPeerStatusChanged(const std::string& /*peer_id*/, uint32_t /*state*/) void PeersHandler::notifyPeerStatusChanged(const std::string& /*peer_id*/, uint32_t /*state*/)
{ {
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
mStateTokenServer->replaceToken(mStateToken); mStateTokenServer->replaceToken(mStateToken);
} }
void PeersHandler::notifyPeerHasNewAvatar(std::string /*peer_id*/) void PeersHandler::notifyPeerHasNewAvatar(std::string /*peer_id*/)
{ {
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
mStateTokenServer->replaceToken(mStateToken); mStateTokenServer->replaceToken(mStateToken);
} }
@ -295,7 +295,7 @@ void PeersHandler::tick()
{ {
mOnlinePeers = online; mOnlinePeers = online;
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
mStateTokenServer->discardToken(mStateToken); mStateTokenServer->discardToken(mStateToken);
mStateToken = mStateTokenServer->getNewToken(); mStateToken = mStateTokenServer->getNewToken();
} }
@ -306,7 +306,7 @@ void PeersHandler::tick()
{ {
status = statusInfo.status; status = statusInfo.status;
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
mStateTokenServer->discardToken(mStringStateToken); mStateTokenServer->discardToken(mStringStateToken);
mStringStateToken = mStateTokenServer->getNewToken(); mStringStateToken = mStateTokenServer->getNewToken();
} }
@ -316,7 +316,7 @@ void PeersHandler::tick()
{ {
custom_state_string = custom_state; custom_state_string = custom_state;
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
mStateTokenServer->discardToken(mCustomStateToken); mStateTokenServer->discardToken(mCustomStateToken);
mCustomStateToken = mStateTokenServer->getNewToken(); mCustomStateToken = mStateTokenServer->getNewToken();
} }
@ -324,7 +324,7 @@ void PeersHandler::tick()
void PeersHandler::notifyUnreadMsgCountChanged(const RsPeerId &peer, uint32_t count) void PeersHandler::notifyUnreadMsgCountChanged(const RsPeerId &peer, uint32_t count)
{ {
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
mUnreadMsgsCounts[peer] = count; mUnreadMsgsCounts[peer] = count;
mStateTokenServer->replaceToken(mStateToken); mStateTokenServer->replaceToken(mStateToken);
} }
@ -460,7 +460,7 @@ void PeersHandler::handleWildcard(Request &req, Response &resp)
{ {
std::map<RsPeerId, uint32_t> unread_msgs; std::map<RsPeerId, uint32_t> unread_msgs;
{ {
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
unread_msgs = mUnreadMsgsCounts; unread_msgs = mUnreadMsgsCounts;
} }
std::list<StatusInfo> statusInfo; std::list<StatusInfo> statusInfo;
@ -1281,7 +1281,7 @@ void PeersHandler::handleSetNodeOptions(Request& req, Response& resp)
StateToken PeersHandler::getCurrentStateToken() StateToken PeersHandler::getCurrentStateToken()
{ {
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
if(mStateToken.isNull()) if(mStateToken.isNull())
mStateToken = mStateTokenServer->getNewToken(); mStateToken = mStateTokenServer->getNewToken();
return mStateToken; return mStateToken;

View File

@ -57,7 +57,7 @@ RsControlModule::~RsControlModule()
bool RsControlModule::processShouldExit() bool RsControlModule::processShouldExit()
{ {
RsStackMutex stack(mExitFlagMtx); RS_STACK_MUTEX(mExitFlagMtx); // ********** LOCKED **********
return mProcessShouldExit; return mProcessShouldExit;
} }
@ -158,7 +158,7 @@ void RsControlModule::run()
std::cerr << "RsControlModule::run() reseting passwd." << std::endl; std::cerr << "RsControlModule::run() reseting passwd." << std::endl;
#endif #endif
{ {
RsStackMutex stack(mDataMtx); // ********** LOCKED ********** RS_STACK_MUTEX(mDataMtx); // ********** LOCKED **********
mPassword = ""; mPassword = "";
} }
@ -182,7 +182,7 @@ void RsControlModule::run()
std::cerr << "RsControlModule::run() while(wait_for_account_select) mLoadPeerId=" << mLoadPeerId << std::endl; std::cerr << "RsControlModule::run() while(wait_for_account_select) mLoadPeerId=" << mLoadPeerId << std::endl;
#endif #endif
usleep(500*1000); usleep(500*1000);
RsStackMutex stack(mDataMtx); // ********** LOCKED ********** RS_STACK_MUTEX(mDataMtx); // ********** LOCKED **********
if(!mLoadPeerId.isNull()) if(!mLoadPeerId.isNull())
{ {
@ -238,7 +238,7 @@ void RsControlModule::run()
#endif #endif
{ {
RsStackMutex stack(mDataMtx); // ********** LOCKED ********** RS_STACK_MUTEX(mDataMtx); // ********** LOCKED **********
mLoadPeerId.clear(); mLoadPeerId.clear();
} }
} }
@ -247,7 +247,7 @@ void RsControlModule::run()
#endif #endif
{ {
RsStackMutex stack(mDataMtx); // ********** LOCKED ********** RS_STACK_MUTEX(mDataMtx); // ********** LOCKED **********
mFixedPassword = mPassword; mFixedPassword = mPassword;
std::cerr << "***Reseting mPasswd " << std::endl; std::cerr << "***Reseting mPasswd " << std::endl;
@ -279,7 +279,7 @@ void RsControlModule::run()
void RsControlModule::handleRunState(Request &, Response &resp) void RsControlModule::handleRunState(Request &, Response &resp)
{ {
RsStackMutex stack(mDataMtx); // ********** LOCKED ********** RS_STACK_MUTEX(mDataMtx); // ********** LOCKED **********
std::string state; std::string state;
switch(mRunState) switch(mRunState)
{ {
@ -311,7 +311,7 @@ void RsControlModule::handleRunState(Request &, Response &resp)
void RsControlModule::handleIdentities(Request &, Response &resp) void RsControlModule::handleIdentities(Request &, Response &resp)
{ {
RsStackMutex stack(mDataMtx); // ********** LOCKED ********** RS_STACK_MUTEX(mDataMtx); // ********** LOCKED **********
if(mRunState == WAITING_INIT || mRunState == FATAL_ERROR) if(mRunState == WAITING_INIT || mRunState == FATAL_ERROR)
{ {
resp.setFail("Retroshare is not initialised. Operation not possible."); resp.setFail("Retroshare is not initialised. Operation not possible.");
@ -337,7 +337,7 @@ void RsControlModule::handleIdentities(Request &, Response &resp)
void RsControlModule::handleLocations(Request &, Response &resp) void RsControlModule::handleLocations(Request &, Response &resp)
{ {
RsStackMutex stack(mDataMtx); // ********** LOCKED ********** RS_STACK_MUTEX(mDataMtx); // ********** LOCKED **********
if(mRunState == WAITING_INIT || mRunState == FATAL_ERROR) if(mRunState == WAITING_INIT || mRunState == FATAL_ERROR)
{ {
resp.setFail("Retroshare is not initialised. Operation not possible."); resp.setFail("Retroshare is not initialised. Operation not possible.");
@ -370,7 +370,7 @@ void RsControlModule::handleLocations(Request &, Response &resp)
void RsControlModule::handlePassword(Request &req, Response &resp) void RsControlModule::handlePassword(Request &req, Response &resp)
{ {
RsStackMutex stack(mDataMtx); // ********** LOCKED ********** RS_STACK_MUTEX(mDataMtx); // ********** LOCKED **********
std::string passwd; std::string passwd;
req.mStream << makeKeyValueReference("password", passwd); req.mStream << makeKeyValueReference("password", passwd);
if(passwd != "")// && mWantPassword) if(passwd != "")// && mWantPassword)
@ -398,7 +398,7 @@ void RsControlModule::handlePassword(Request &req, Response &resp)
void RsControlModule::handleLogin(Request &req, Response &resp) void RsControlModule::handleLogin(Request &req, Response &resp)
{ {
RsStackMutex stack(mDataMtx); // ********** LOCKED ********** RS_STACK_MUTEX(mDataMtx); // ********** LOCKED **********
if(mRunState != WAITING_ACCOUNT_SELECT) if(mRunState != WAITING_ACCOUNT_SELECT)
{ {
resp.setFail("Operation not allowed in this runstate. Login is only allowed rigth after initialisation."); resp.setFail("Operation not allowed in this runstate. Login is only allowed rigth after initialisation.");
@ -411,7 +411,7 @@ void RsControlModule::handleLogin(Request &req, Response &resp)
void RsControlModule::handleShutdown(Request &, Response &resp) void RsControlModule::handleShutdown(Request &, Response &resp)
{ {
RsStackMutex stack(mExitFlagMtx); // ********** LOCKED ********** RS_STACK_MUTEX(mExitFlagMtx); // ********** LOCKED **********
mProcessShouldExit = true; mProcessShouldExit = true;
resp.setOk(); resp.setOk();
} }
@ -514,7 +514,7 @@ void RsControlModule::handleCreateLocation(Request &req, Response &resp)
std::string err_string; std::string err_string;
// give the password to the password callback // give the password to the password callback
{ {
RsStackMutex stack(mDataMtx); // ********** LOCKED ********** RS_STACK_MUTEX(mDataMtx); // ********** LOCKED **********
mPassword = pgp_password; mPassword = pgp_password;
mFixedPassword = pgp_password; mFixedPassword = pgp_password;
} }
@ -522,7 +522,7 @@ void RsControlModule::handleCreateLocation(Request &req, Response &resp)
// clear fixed password to restore normal password operation // clear fixed password to restore normal password operation
// { // {
// RsStackMutex stack(mDataMtx); // ********** LOCKED ********** // RS_STACK_MUTEX(mDataMtx); // ********** LOCKED **********
// mFixedPassword = ""; // mFixedPassword = "";
// } // }
@ -532,7 +532,7 @@ void RsControlModule::handleCreateLocation(Request &req, Response &resp)
RsInit::LoadPassword(ssl_password); RsInit::LoadPassword(ssl_password);
// trigger login in init thread // trigger login in init thread
{ {
RsStackMutex stack(mDataMtx); // ********** LOCKED ********** RS_STACK_MUTEX(mDataMtx); // ********** LOCKED **********
mLoadPeerId = ssl_id; mLoadPeerId = ssl_id;
} }
resp.mDataStream << makeKeyValueReference("pgp_id", pgp_id) resp.mDataStream << makeKeyValueReference("pgp_id", pgp_id)
@ -561,7 +561,7 @@ bool RsControlModule::askForDeferredSelfSignature(const void *data, const uint32
void RsControlModule::setRunState(RunState s, std::string errstr) void RsControlModule::setRunState(RunState s, std::string errstr)
{ {
RsStackMutex stack(mDataMtx); // ********** LOCKED ********** RS_STACK_MUTEX(mDataMtx); // ********** LOCKED **********
mRunState = s; mRunState = s;
mLastErrorString = errstr; mLastErrorString = errstr;
mStateTokenServer->replaceToken(mStateToken); mStateTokenServer->replaceToken(mStateToken);

View File

@ -64,19 +64,19 @@ StateTokenServer::StateTokenServer():
StateToken StateTokenServer::getNewToken() StateToken StateTokenServer::getNewToken()
{ {
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
return locked_getNewToken(); return locked_getNewToken();
} }
void StateTokenServer::discardToken(StateToken token) void StateTokenServer::discardToken(StateToken token)
{ {
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
locked_discardToken(token); locked_discardToken(token);
} }
void StateTokenServer::replaceToken(StateToken &token) void StateTokenServer::replaceToken(StateToken &token)
{ {
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
locked_discardToken(token); locked_discardToken(token);
token = locked_getNewToken(); token = locked_getNewToken();
} }
@ -89,13 +89,13 @@ void StateTokenServer::registerTickClient(Tickable *c)
// avoid double registration // avoid double registration
unregisterTickClient(c); unregisterTickClient(c);
RsStackMutex stack(mClientsMtx); /********** STACK LOCKED MTX ***********/ RS_STACK_MUTEX(mClientsMtx); // ********** LOCKED **********
mTickClients.push_back(c); mTickClients.push_back(c);
} }
void StateTokenServer::unregisterTickClient(Tickable *c) void StateTokenServer::unregisterTickClient(Tickable *c)
{ {
RsStackMutex stack(mClientsMtx); /********** STACK LOCKED MTX ***********/ RS_STACK_MUTEX(mClientsMtx); // ********** LOCKED **********
std::vector<Tickable*>::iterator vit = std::find(mTickClients.begin(), mTickClients.end(), c); std::vector<Tickable*>::iterator vit = std::find(mTickClients.begin(), mTickClients.end(), c);
if(vit != mTickClients.end()) if(vit != mTickClients.end())
mTickClients.erase(vit); mTickClients.erase(vit);
@ -104,14 +104,14 @@ void StateTokenServer::unregisterTickClient(Tickable *c)
void StateTokenServer::handleWildcard(Request &req, Response &resp) void StateTokenServer::handleWildcard(Request &req, Response &resp)
{ {
{ {
RsStackMutex stack(mClientsMtx); /********** STACK LOCKED MTX ***********/ RS_STACK_MUTEX(mClientsMtx); // ********** LOCKED **********
for(std::vector<Tickable*>::iterator vit = mTickClients.begin(); vit != mTickClients.end(); ++vit) for(std::vector<Tickable*>::iterator vit = mTickClients.begin(); vit != mTickClients.end(); ++vit)
{ {
(*vit)->tick(); (*vit)->tick();
} }
} }
RsStackMutex stack(mMtx); /********** STACK LOCKED MTX ******/ RS_STACK_MUTEX(mMtx); // ********** LOCKED **********
// want to lookpup many tokens at once, return a list of invalid tokens // want to lookpup many tokens at once, return a list of invalid tokens
// TODO: make generic list serialiser/deserialiser // TODO: make generic list serialiser/deserialiser
resp.mDataStream.getStreamToMember(); resp.mDataStream.getStreamToMember();