Merge pull request #2369 from G10h4ck/fix_RsGxsNetService_requestGrp

Fix list overwrite in RsGxsNetService::requestGrp
This commit is contained in:
csoler 2021-03-08 22:50:03 +01:00 committed by GitHub
commit 89b6d95197
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 24 deletions

View File

@ -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,43 +4804,40 @@ 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;
}
void RsGxsNetService::processExplicitGroupRequests()
{
RS_STACK_MUTEX(mNxsMutex) ;
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;
RsNxsSyncGrpItem* item = new RsNxsSyncGrpItem(mServType);
item->grpId = grpId;
item->PeerId(peerId);
item->flag = RsNxsSyncGrpItem::FLAG_REQUEST;
item->transactionNumber = transN;

View File

@ -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