mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-13 16:39:43 -05:00
fixed possible data race in mNotifications
This commit is contained in:
parent
3d7ae59df7
commit
93cd6a5df1
@ -163,10 +163,25 @@ void RsGenExchange::tick()
|
||||
|
||||
processRoutingClues() ;
|
||||
|
||||
if(!mNotifications.empty())
|
||||
{
|
||||
notifyChanges(mNotifications);
|
||||
mNotifications.clear();
|
||||
std::vector<RsGxsNotify*> mNotifications_copy;
|
||||
|
||||
// make a non-deep copy of mNotifications so that it can be passed off-mutex to notifyChanged()
|
||||
// that will delete it. The potential high cost of notifyChanges() makes it preferable to call off-mutex.
|
||||
{
|
||||
RS_STACK_MUTEX(mGenMtx);
|
||||
if(!mNotifications.empty())
|
||||
{
|
||||
mNotifications_copy = mNotifications;
|
||||
mNotifications.clear();
|
||||
}
|
||||
}
|
||||
|
||||
// Calling notifyChanges() calls back RsGxsIfaceHelper::receiveChanges() that deletes the pointers in the array
|
||||
// and the array itself. This is pretty bad and we should normally delete the changes here.
|
||||
|
||||
if(!mNotifications_copy.empty())
|
||||
notifyChanges(mNotifications_copy);
|
||||
}
|
||||
|
||||
// implemented service tick function
|
||||
|
@ -377,6 +377,7 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
|
||||
if(!unprocessedGroups.empty())
|
||||
request_SpecificSubscribedGroups(unprocessedGroups);
|
||||
|
||||
// the call below deletes changes and its content.
|
||||
RsGxsIfaceHelper::receiveChanges(changes);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user