fixed bug causing RS to eat all the memory, slow down GxsId access and ultimately make forums and other Gxs services to not load properly

This commit is contained in:
csoler 2020-03-18 22:33:58 +01:00
parent 676ddfbfb5
commit b6667a2c5a
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
2 changed files with 22 additions and 8 deletions

View File

@ -3461,7 +3461,7 @@ bool RsGenExchange::exportGroupBase64(
if(groupId.isNull()) return failure("groupId cannot be null"); if(groupId.isNull()) return failure("groupId cannot be null");
// We have no blocking API here, so we need to // We have no blocking API here, so we need to make a blocking request manually.
const std::list<RsGxsGroupId> groupIds({groupId}); const std::list<RsGxsGroupId> groupIds({groupId});
RsTokReqOptions opts; RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA; opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;

View File

@ -639,25 +639,28 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
std::cerr << "p3IdService::notifyChanges() Auto Subscribe to Incoming Groups: " << *git; std::cerr << "p3IdService::notifyChanges() Auto Subscribe to Incoming Groups: " << *git;
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
if(!rsReputations->isIdentityBanned(RsGxsId(*git))) if(!rsReputations->isIdentityBanned(RsGxsId(*git)))
{ {
uint32_t token;
RsGenExchange::subscribeToGroup(token, *git, true);
// also time_stamp the key that this group represents
timeStampKey(RsGxsId(*git),RsIdentityUsage(serviceType(),RsIdentityUsage::IDENTITY_DATA_UPDATE)) ;
// notify that a new identity is received, if needed // notify that a new identity is received, if needed
bool should_subscribe = false;
switch(groupChange->getType()) switch(groupChange->getType())
{ {
case RsGxsNotify::TYPE_PROCESSED: break ; // Happens when the group is subscribed. This is triggered by RsGenExchange::subscribeToGroup, so better not
// call it again from here!!
case RsGxsNotify::TYPE_PUBLISHED: case RsGxsNotify::TYPE_PUBLISHED:
{ {
auto ev = std::make_shared<RsGxsIdentityEvent>(); auto ev = std::make_shared<RsGxsIdentityEvent>();
ev->mIdentityId = *git; ev->mIdentityId = *git;
ev->mIdentityEventCode = RsGxsIdentityEventCode::UPDATED_IDENTITY; ev->mIdentityEventCode = RsGxsIdentityEventCode::UPDATED_IDENTITY;
rsEvents->postEvent(ev); rsEvents->postEvent(ev);
// also time_stamp the key that this group represents
timeStampKey(RsGxsId(*git),RsIdentityUsage(serviceType(),RsIdentityUsage::IDENTITY_DATA_UPDATE)) ;
should_subscribe = true;
} }
break; break;
@ -667,12 +670,23 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
ev->mIdentityId = *git; ev->mIdentityId = *git;
ev->mIdentityEventCode = RsGxsIdentityEventCode::NEW_IDENTITY; ev->mIdentityEventCode = RsGxsIdentityEventCode::NEW_IDENTITY;
rsEvents->postEvent(ev); rsEvents->postEvent(ev);
// also time_stamp the key that this group represents
timeStampKey(RsGxsId(*git),RsIdentityUsage(serviceType(),RsIdentityUsage::IDENTITY_DATA_UPDATE)) ;
should_subscribe = true;
} }
break; break;
default: default:
break; break;
} }
if(should_subscribe)
{
uint32_t token;
RsGenExchange::subscribeToGroup(token, *git, true);
}
} }
} }
} }