mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-29 01:16:20 -05:00
moved notify calls to RsGenExchange out of RsGxsNetService lock zone, to avoid deadlocks
This commit is contained in:
parent
226948cab5
commit
98b27d6a2b
@ -320,6 +320,18 @@ int RsGxsNetService::tick()
|
||||
if(receivedItems())
|
||||
recvNxsItemQueue();
|
||||
|
||||
bool should_notify = false;
|
||||
|
||||
{
|
||||
RS_STACK_MUTEX(mNxsMutex) ;
|
||||
|
||||
should_notify = should_notify || !mNewGroupsToNotify.empty() ;
|
||||
should_notify = should_notify || !mNewMessagesToNotify.empty() ;
|
||||
}
|
||||
|
||||
if(should_notify)
|
||||
processObserverNotifications() ;
|
||||
|
||||
time_t now = time(NULL);
|
||||
time_t elapsed = mSYNC_PERIOD + mSyncTs;
|
||||
|
||||
@ -346,6 +358,29 @@ int RsGxsNetService::tick()
|
||||
return 1;
|
||||
}
|
||||
|
||||
void RsGxsNetService::processObserverNotifications()
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG_0
|
||||
GXSNETDEBUG___ << "Processing observer notification." << std::endl;
|
||||
#endif
|
||||
|
||||
std::vector<RsNxsGrp*> grps_copy ;
|
||||
std::vector<RsNxsMsg*> msgs_copy ;
|
||||
|
||||
{
|
||||
RS_STACK_MUTEX(mNxsMutex) ;
|
||||
|
||||
grps_copy = mNewGroupsToNotify ;
|
||||
msgs_copy = mNewMessagesToNotify ;
|
||||
|
||||
mNewGroupsToNotify.clear() ;
|
||||
mNewMessagesToNotify.clear() ;
|
||||
}
|
||||
|
||||
mObserver->notifyNewGroups(grps_copy);
|
||||
mObserver->notifyNewMessages(msgs_copy);
|
||||
}
|
||||
|
||||
void RsGxsNetService::rejectMessage(const RsGxsMessageId& msg_id)
|
||||
{
|
||||
RS_STACK_MUTEX(mNxsMutex) ;
|
||||
@ -2170,7 +2205,8 @@ void RsGxsNetService::locked_processCompletedIncomingTrans(NxsTransaction* tr)
|
||||
GXSNETDEBUG_PG(tr->mTransaction->PeerId(),grps[i]->grpId) ;
|
||||
#endif
|
||||
// notify listener of grps
|
||||
mObserver->notifyNewGroups(grps);
|
||||
for(uint32_t i=0;i<grps.size();++i)
|
||||
mNewGroupsToNotify.push_back(grps[i]) ;
|
||||
|
||||
// now note this as the latest you've received from this peer
|
||||
RsPeerId peerFrom = tr->mTransaction->PeerId();
|
||||
@ -2250,7 +2286,8 @@ void RsGxsNetService::locked_processCompletedIncomingTrans(NxsTransaction* tr)
|
||||
GXSNETDEBUG_PG(tr->mTransaction->PeerId(),grpId) << " " << msgs[i]->msgId << std::endl ;
|
||||
#endif
|
||||
// notify listener of msgs
|
||||
mObserver->notifyNewMessages(msgs);
|
||||
for(uint32_t i=0;i<msgs.size();++i)
|
||||
mNewMessagesToNotify.push_back(msgs[i]) ;
|
||||
|
||||
// now note that this is the latest you've received from this peer
|
||||
// for the grp id
|
||||
|
@ -449,6 +449,7 @@ private:
|
||||
void locked_stampPeerGroupUpdateTime(const RsPeerId& pid,const RsGxsGroupId& grpId,time_t tm,uint32_t n_messages) ;
|
||||
|
||||
void cleanRejectedMessages();
|
||||
void processObserverNotifications();
|
||||
private:
|
||||
|
||||
|
||||
@ -526,6 +527,8 @@ private:
|
||||
RsServiceInfo mServiceInfo;
|
||||
|
||||
std::map<RsGxsMessageId,time_t> mRejectedMessages;
|
||||
std::vector<RsNxsGrp*> mNewGroupsToNotify ;
|
||||
std::vector<RsNxsMsg*> mNewMessagesToNotify ;
|
||||
|
||||
void debugDump();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user