Fixed deadlock when receiving a chat message with open history browser.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5042 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-03-20 21:25:39 +00:00
parent d765721e83
commit 9f627783aa

View file

@ -52,6 +52,9 @@ p3HistoryMgr::~p3HistoryMgr()
/***** p3HistoryMgr *****/
void p3HistoryMgr::addMessage(bool incoming, const std::string &chatPeerId, const std::string &peerId, const RsChatMsgItem *chatItem)
{
uint32_t addMsgId = 0;
{
RsStackMutex stack(mHistoryMtx); /********** STACK LOCKED MTX ******/
@ -86,6 +89,7 @@ void p3HistoryMgr::addMessage(bool incoming, const std::string &chatPeerId, cons
if (mit != mMessages.end()) {
item->msgId = nextMsgId++;
mit->second.insert(std::make_pair(item->msgId, item));
addMsgId = item->msgId;
// check the limit
uint32_t limit;
@ -106,13 +110,17 @@ void p3HistoryMgr::addMessage(bool incoming, const std::string &chatPeerId, cons
item->msgId = nextMsgId++;
msgs.insert(std::make_pair(item->msgId, item));
mMessages.insert(std::make_pair(item->chatPeerId, msgs));
addMsgId = item->msgId;
// no need to check the limit
}
IndicateConfigChanged();
}
rsicontrol->getNotify().notifyHistoryChanged(item->msgId, NOTIFY_TYPE_ADD);
if (addMsgId) {
rsicontrol->getNotify().notifyHistoryChanged(addMsgId, NOTIFY_TYPE_ADD);
}
}
/***** p3Config *****/
@ -319,6 +327,7 @@ bool p3HistoryMgr::getMessage(uint32_t msgId, HistoryMsg &msg)
}
void p3HistoryMgr::clear(const std::string &chatPeerId)
{
{
RsStackMutex stack(mHistoryMtx); /********** STACK LOCKED MTX ******/
@ -335,6 +344,7 @@ void p3HistoryMgr::clear(const std::string &chatPeerId)
mMessages.erase(mit);
IndicateConfigChanged();
}
rsicontrol->getNotify().notifyHistoryChanged(0, NOTIFY_TYPE_MOD);
}