From b6667a2c5a4d111c04a94c181c1381ef86ccb6d6 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 18 Mar 2020 22:33:58 +0100 Subject: [PATCH] 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 --- libretroshare/src/gxs/rsgenexchange.cc | 2 +- libretroshare/src/services/p3idservice.cc | 28 +++++++++++++++++------ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index a6d995c26..c7c274fa4 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -3461,7 +3461,7 @@ bool RsGenExchange::exportGroupBase64( 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 groupIds({groupId}); RsTokReqOptions opts; opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA; diff --git a/libretroshare/src/services/p3idservice.cc b/libretroshare/src/services/p3idservice.cc index 4d4d5ac5e..fe0cba89f 100644 --- a/libretroshare/src/services/p3idservice.cc +++ b/libretroshare/src/services/p3idservice.cc @@ -639,25 +639,28 @@ void p3IdService::notifyChanges(std::vector &changes) std::cerr << "p3IdService::notifyChanges() Auto Subscribe to Incoming Groups: " << *git; std::cerr << std::endl; #endif + 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 + bool should_subscribe = false; + 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: { auto ev = std::make_shared(); ev->mIdentityId = *git; ev->mIdentityEventCode = RsGxsIdentityEventCode::UPDATED_IDENTITY; 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; @@ -667,12 +670,23 @@ void p3IdService::notifyChanges(std::vector &changes) ev->mIdentityId = *git; ev->mIdentityEventCode = RsGxsIdentityEventCode::NEW_IDENTITY; 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; default: break; } + + if(should_subscribe) + { + uint32_t token; + RsGenExchange::subscribeToGroup(token, *git, true); + } + } } }