mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Fix list overwrite in RsGxsNetService::requestGrp
When requestGrp was called with different groups for same peer multiple times between ticks the list was overridden and groups from previous call overridden by the new, as a result some requested groups may be never really requested. Fix the bug by using a set instead of a list so the newly requested groups are uniquely added to the set without removing the previously added.
This commit is contained in:
parent
51dbbfb222
commit
74dc476282
@ -256,10 +256,8 @@
|
||||
#include "util/rstime.h"
|
||||
#include "util/rsmemory.h"
|
||||
#include "util/stacktrace.h"
|
||||
|
||||
#ifdef RS_DEEP_CHANNEL_INDEX
|
||||
# include "deep_search/channelsindex.hpp"
|
||||
#endif
|
||||
#include "util/rsdebug.h"
|
||||
#include "util/cxx17retrocompat.h"
|
||||
|
||||
/***
|
||||
* Use the following defines to debug:
|
||||
@ -4806,16 +4804,16 @@ uint32_t RsGxsNetService::getKeepAge(const RsGxsGroupId& grpId)
|
||||
return locked_getGrpConfig(grpId).msg_keep_delay ;
|
||||
}
|
||||
|
||||
int RsGxsNetService::requestGrp(const std::list<RsGxsGroupId>& grpId, const RsPeerId& peerId)
|
||||
int RsGxsNetService::requestGrp(
|
||||
const std::list<RsGxsGroupId>& grpIds, const RsPeerId& peerId )
|
||||
{
|
||||
RS_STACK_MUTEX(mNxsMutex) ;
|
||||
#ifdef NXS_NET_DEBUG_0
|
||||
GXSNETDEBUG_P_(peerId) << "RsGxsNetService::requestGrp(): adding explicit group requests to peer " << peerId << std::endl;
|
||||
|
||||
for(std::list<RsGxsGroupId>::const_iterator it(grpId.begin());it!=grpId.end();++it)
|
||||
GXSNETDEBUG_PG(peerId,*it) << " Group ID: " << *it << std::endl;
|
||||
RS_DBG("Adding explicit groups requests to peer: ", peerId);
|
||||
for(auto& grpId: std::as_const(grpIds)) RS_DBG("\t Group ID: ", grpId);
|
||||
#endif
|
||||
mExplicitRequest[peerId].assign(grpId.begin(), grpId.end());
|
||||
|
||||
RS_STACK_MUTEX(mNxsMutex);
|
||||
mExplicitRequest[peerId].insert(grpIds.begin(), grpIds.end());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -4823,26 +4821,23 @@ void RsGxsNetService::processExplicitGroupRequests()
|
||||
{
|
||||
RS_STACK_MUTEX(mNxsMutex);
|
||||
|
||||
std::map<RsPeerId, std::list<RsGxsGroupId> >::const_iterator cit = mExplicitRequest.begin();
|
||||
|
||||
for(; cit != mExplicitRequest.end(); ++cit)
|
||||
for(auto& cit: std::as_const(mExplicitRequest))
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG_0
|
||||
GXSNETDEBUG_P_(cit->first) << "RsGxsNetService::sending pending explicit group requests to peer " << cit->first << std::endl;
|
||||
RS_DBG("sending pending explicit group requests to peer ", cit.first);
|
||||
#endif
|
||||
const RsPeerId& peerId = cit->first;
|
||||
const std::list<RsGxsGroupId>& groupIdList = cit->second;
|
||||
const RsPeerId& peerId = cit.first;
|
||||
const std::set<RsGxsGroupId>& groupIdList = cit.second;
|
||||
|
||||
std::list<RsNxsItem*> grpSyncItems;
|
||||
std::list<RsGxsGroupId>::const_iterator git = groupIdList.begin();
|
||||
uint32_t transN = locked_getTransactionId();
|
||||
for(; git != groupIdList.end(); ++git)
|
||||
for(auto& grpId: std::as_const(groupIdList))
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG_0
|
||||
GXSNETDEBUG_P_(peerId) << " group request for grp ID " << *git << " to peer " << peerId << std::endl;
|
||||
RS_DBG("\t group request for group ID: ", grpId);
|
||||
#endif
|
||||
RsNxsSyncGrpItem* item = new RsNxsSyncGrpItem(mServType);
|
||||
item->grpId = *git;
|
||||
item->grpId = grpId;
|
||||
item->PeerId(peerId);
|
||||
item->flag = RsNxsSyncGrpItem::FLAG_REQUEST;
|
||||
item->transactionNumber = transN;
|
||||
|
@ -584,7 +584,7 @@ private:
|
||||
std::vector<AuthorPending*> mPendingResp;
|
||||
std::vector<GrpCircleVetting*> mPendingCircleVets;
|
||||
std::map<RsGxsGroupId,std::set<RsPeerId> > mPendingPublishKeyRecipients ;
|
||||
std::map<RsPeerId, std::list<RsGxsGroupId> > mExplicitRequest;
|
||||
std::map<RsPeerId, std::set<RsGxsGroupId> > mExplicitRequest;
|
||||
std::map<RsPeerId, std::set<RsGxsGroupId> > mPartialMsgUpdates ;
|
||||
|
||||
// nxs sync optimisation
|
||||
|
Loading…
Reference in New Issue
Block a user