mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed deletion of groups using the proper method in RsGenExchange, and disabled debug output
This commit is contained in:
parent
bce514115d
commit
5a7f95f443
@ -263,7 +263,19 @@ void RsGenExchange::tick()
|
|||||||
|
|
||||||
if( (mNetService && (mNetService->msgAutoSync() || mNetService->grpAutoSync())) && (mLastClean + MSG_CLEANUP_PERIOD < now) )
|
if( (mNetService && (mNetService->msgAutoSync() || mNetService->grpAutoSync())) && (mLastClean + MSG_CLEANUP_PERIOD < now) )
|
||||||
{
|
{
|
||||||
RsGxsCleanUp(mDataStore,this,1).clean(mNextGroupToCheck); // no need to lock here, because all access below (RsGenExchange, RsDataStore) are properly mutexed
|
GxsMsgReq msgs_to_delete;
|
||||||
|
std::vector<RsGxsGroupId> grps_to_delete;
|
||||||
|
|
||||||
|
RsGxsCleanUp(mDataStore,this,1).clean(mNextGroupToCheck,grps_to_delete,msgs_to_delete); // no need to lock here, because all access below (RsGenExchange, RsDataStore) are properly mutexed
|
||||||
|
|
||||||
|
uint32_t token1=0;
|
||||||
|
deleteMsgs(token1,msgs_to_delete);
|
||||||
|
|
||||||
|
for(auto& grpId: grps_to_delete)
|
||||||
|
{
|
||||||
|
uint32_t token2=0;
|
||||||
|
deleteGroup(token2,grpId);
|
||||||
|
}
|
||||||
|
|
||||||
RS_STACK_MUTEX(mGenMtx) ;
|
RS_STACK_MUTEX(mGenMtx) ;
|
||||||
mLastClean = now;
|
mLastClean = now;
|
||||||
|
@ -52,13 +52,12 @@ RsGxsCleanUp::RsGxsCleanUp(RsGeneralDataService* const dataService, RsGenExchang
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RsGxsCleanUp::clean(RsGxsGroupId& next_group_to_check)
|
bool RsGxsCleanUp::clean(RsGxsGroupId& next_group_to_check,std::vector<RsGxsGroupId>& grps_to_delete,GxsMsgReq& messages_to_delete)
|
||||||
{
|
{
|
||||||
RsGxsGrpMetaTemporaryMap grpMetaMap;
|
RsGxsGrpMetaTemporaryMap grpMetaMap;
|
||||||
mDs->retrieveGxsGrpMetaData(grpMetaMap);
|
mDs->retrieveGxsGrpMetaData(grpMetaMap);
|
||||||
|
|
||||||
rstime_t now = time(NULL);
|
rstime_t now = time(NULL);
|
||||||
std::vector<RsGxsGroupId> grps_to_delete;
|
|
||||||
|
|
||||||
#ifdef DEBUG_GXSUTIL
|
#ifdef DEBUG_GXSUTIL
|
||||||
uint16_t service_type = mGenExchangeClient->serviceType() ;
|
uint16_t service_type = mGenExchangeClient->serviceType() ;
|
||||||
@ -108,8 +107,6 @@ bool RsGxsCleanUp::clean(RsGxsGroupId& next_group_to_check)
|
|||||||
#ifdef DEBUG_GXSUTIL
|
#ifdef DEBUG_GXSUTIL
|
||||||
GXSUTIL_DEBUG() << " Cleaning up group message for group ID " << grpId << std::endl;
|
GXSUTIL_DEBUG() << " Cleaning up group message for group ID " << grpId << std::endl;
|
||||||
#endif
|
#endif
|
||||||
GxsMsgReq messages_to_delete;
|
|
||||||
|
|
||||||
uint32_t store_period = mGenExchangeClient->getStoragePeriod(grpId) ;
|
uint32_t store_period = mGenExchangeClient->getStoragePeriod(grpId) ;
|
||||||
|
|
||||||
for(; mit != result.end(); ++mit)
|
for(; mit != result.end(); ++mit)
|
||||||
@ -151,7 +148,6 @@ bool RsGxsCleanUp::clean(RsGxsGroupId& next_group_to_check)
|
|||||||
if( remove )
|
if( remove )
|
||||||
{
|
{
|
||||||
messages_to_delete[grpId].insert(meta->mMsgId);
|
messages_to_delete[grpId].insert(meta->mMsgId);
|
||||||
|
|
||||||
#ifdef DEBUG_GXSUTIL
|
#ifdef DEBUG_GXSUTIL
|
||||||
std::cerr << " Scheduling for removal." << std::endl;
|
std::cerr << " Scheduling for removal." << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -163,8 +159,6 @@ bool RsGxsCleanUp::clean(RsGxsGroupId& next_group_to_check)
|
|||||||
//delete meta;
|
//delete meta;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mDs->removeMsgs(messages_to_delete);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
++it;
|
++it;
|
||||||
@ -195,8 +189,6 @@ bool RsGxsCleanUp::clean(RsGxsGroupId& next_group_to_check)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mDs->removeGroups(grps_to_delete);
|
|
||||||
|
|
||||||
return full_round;
|
return full_round;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ public:
|
|||||||
* Deletion will process by chunk size
|
* Deletion will process by chunk size
|
||||||
* @return true if no more messages to delete, false otherwise
|
* @return true if no more messages to delete, false otherwise
|
||||||
*/
|
*/
|
||||||
bool clean(RsGxsGroupId &last_checked_group);
|
bool clean(RsGxsGroupId& next_group_to_check,std::vector<RsGxsGroupId>& grps_to_delete,GxsMsgReq& messages_to_delete);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -452,7 +452,9 @@ void p3GxsChannels::service_tick()
|
|||||||
|
|
||||||
bool p3GxsChannels::service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta)
|
bool p3GxsChannels::service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta)
|
||||||
{
|
{
|
||||||
|
#ifdef GXSFORUMS_CHANNELS
|
||||||
std::cerr << "p3gxsChannels: Checking unused channel: called by GxsCleaning." << std::endl;
|
std::cerr << "p3gxsChannels: Checking unused channel: called by GxsCleaning." << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
// request all group infos at once
|
// request all group infos at once
|
||||||
|
|
||||||
@ -463,14 +465,18 @@ bool p3GxsChannels::service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta
|
|||||||
auto it = mKnownChannels.find(meta.mGroupId);
|
auto it = mKnownChannels.find(meta.mGroupId);
|
||||||
bool unknown_channel = it == mKnownChannels.end();
|
bool unknown_channel = it == mKnownChannels.end();
|
||||||
|
|
||||||
|
#ifdef GXSFORUMS_CHANNELS
|
||||||
std::cerr << " Channel " << meta.mGroupId ;
|
std::cerr << " Channel " << meta.mGroupId ;
|
||||||
|
#endif
|
||||||
|
|
||||||
if(unknown_channel)
|
if(unknown_channel)
|
||||||
{
|
{
|
||||||
// This case should normally not happen. It does because this channel was never registered since it may
|
// This case should normally not happen. It does because this channel was never registered since it may
|
||||||
// arrived before this code was here
|
// arrived before this code was here
|
||||||
|
|
||||||
|
#ifdef GXSFORUMS_CHANNELS
|
||||||
std::cerr << ". Not known yet. Adding current time as new TS." << std::endl;
|
std::cerr << ". Not known yet. Adding current time as new TS." << std::endl;
|
||||||
|
#endif
|
||||||
mKnownChannels[meta.mGroupId] = now;
|
mKnownChannels[meta.mGroupId] = now;
|
||||||
IndicateConfigChanged();
|
IndicateConfigChanged();
|
||||||
|
|
||||||
@ -481,16 +487,22 @@ bool p3GxsChannels::service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta
|
|||||||
bool used_by_friends = (now < it->second + CHANNEL_UNUSED_BY_FRIENDS_DELAY);
|
bool used_by_friends = (now < it->second + CHANNEL_UNUSED_BY_FRIENDS_DELAY);
|
||||||
bool subscribed = static_cast<bool>(meta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED);
|
bool subscribed = static_cast<bool>(meta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED);
|
||||||
|
|
||||||
|
#ifdef GXSFORUMS_CHANNELS
|
||||||
std::cerr << ". subscribed: " << subscribed << ", used_by_friends: " << used_by_friends << " last TS: " << now - it->second << " secs ago (" << (now-it->second)/86400 << " days)";
|
std::cerr << ". subscribed: " << subscribed << ", used_by_friends: " << used_by_friends << " last TS: " << now - it->second << " secs ago (" << (now-it->second)/86400 << " days)";
|
||||||
|
#endif
|
||||||
|
|
||||||
if(!subscribed && !used_by_friends)
|
if(!subscribed && !used_by_friends)
|
||||||
{
|
{
|
||||||
|
#ifdef GXSFORUMS_CHANNELS
|
||||||
std::cerr << ". Scheduling for deletion" << std::endl;
|
std::cerr << ". Scheduling for deletion" << std::endl;
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef GXSFORUMS_CHANNELS
|
||||||
std::cerr << ". Keeping!" << std::endl;
|
std::cerr << ". Keeping!" << std::endl;
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
/*static*/ const std::string RsGxsCircles::CIRCLE_URL_ID_FIELD = "circleId";
|
/*static*/ const std::string RsGxsCircles::CIRCLE_URL_ID_FIELD = "circleId";
|
||||||
/*static*/ const std::string RsGxsCircles::CIRCLE_URL_DATA_FIELD = "circleData";
|
/*static*/ const std::string RsGxsCircles::CIRCLE_URL_DATA_FIELD = "circleData";
|
||||||
|
|
||||||
static const uint32_t CIRCLES_UNUSED_BY_FRIENDS_DELAY = 7*86400 ; // 7 days ...O...
|
static const uint32_t CIRCLES_UNUSED_BY_FRIENDS_DELAY = 60*86400 ; // 60 days ...O...
|
||||||
|
|
||||||
RsGxsCircles::~RsGxsCircles() = default;
|
RsGxsCircles::~RsGxsCircles() = default;
|
||||||
RsGxsCircleMsg::~RsGxsCircleMsg() = default;
|
RsGxsCircleMsg::~RsGxsCircleMsg() = default;
|
||||||
@ -1733,7 +1733,9 @@ void p3GxsCircles::addCircleIdToList(const RsGxsCircleId &circleId, uint32_t cir
|
|||||||
|
|
||||||
bool p3GxsCircles::service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta)
|
bool p3GxsCircles::service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta)
|
||||||
{
|
{
|
||||||
|
#ifdef GXSFORUMS_CHANNELS
|
||||||
std::cerr << "p3gxsChannels: Checking unused circles: called by GxsCleaning." << std::endl;
|
std::cerr << "p3gxsChannels: Checking unused circles: called by GxsCleaning." << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
// request all group infos at once
|
// request all group infos at once
|
||||||
|
|
||||||
@ -1744,14 +1746,18 @@ bool p3GxsCircles::service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta)
|
|||||||
auto it = mKnownCircles.find(meta.mGroupId);
|
auto it = mKnownCircles.find(meta.mGroupId);
|
||||||
bool unknown_posted = (it == mKnownCircles.end());
|
bool unknown_posted = (it == mKnownCircles.end());
|
||||||
|
|
||||||
|
#ifdef GXSFORUMS_CHANNELS
|
||||||
std::cerr << " Circle " << meta.mGroupId ;
|
std::cerr << " Circle " << meta.mGroupId ;
|
||||||
|
#endif
|
||||||
|
|
||||||
if(unknown_posted)
|
if(unknown_posted)
|
||||||
{
|
{
|
||||||
// This case should normally not happen. It does because this board was never registered since it may
|
// This case should normally not happen. It does because this board was never registered since it may
|
||||||
// arrived before this code was here
|
// arrived before this code was here
|
||||||
|
|
||||||
|
#ifdef GXSFORUMS_CHANNELS
|
||||||
std::cerr << ". Not known yet. Adding current time as new TS." << std::endl;
|
std::cerr << ". Not known yet. Adding current time as new TS." << std::endl;
|
||||||
|
#endif
|
||||||
mKnownCircles[meta.mGroupId] = now;
|
mKnownCircles[meta.mGroupId] = now;
|
||||||
IndicateConfigChanged();
|
IndicateConfigChanged();
|
||||||
|
|
||||||
@ -1766,12 +1772,16 @@ bool p3GxsCircles::service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta)
|
|||||||
|
|
||||||
if(!subscribed && !used_by_friends)
|
if(!subscribed && !used_by_friends)
|
||||||
{
|
{
|
||||||
|
#ifdef GXSFORUMS_CHANNELS
|
||||||
std::cerr << ". Scheduling for deletion" << std::endl;
|
std::cerr << ". Scheduling for deletion" << std::endl;
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef GXSFORUMS_CHANNELS
|
||||||
std::cerr << ". Keeping!" << std::endl;
|
std::cerr << ". Keeping!" << std::endl;
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ RsGxsForums *rsGxsForums = NULL;
|
|||||||
|
|
||||||
#define FORUM_TESTEVENT_DUMMYDATA 0x0001
|
#define FORUM_TESTEVENT_DUMMYDATA 0x0001
|
||||||
#define DUMMYDATA_PERIOD 60 // long enough for some RsIdentities to be generated.
|
#define DUMMYDATA_PERIOD 60 // long enough for some RsIdentities to be generated.
|
||||||
#define FORUM_UNUSED_BY_FRIENDS_DELAY (2*5*86400) // unused forums are deleted after 2 months
|
#define FORUM_UNUSED_BY_FRIENDS_DELAY (2*30*86400) // unused forums are deleted after 2 months
|
||||||
|
|
||||||
/********************************************************************************/
|
/********************************************************************************/
|
||||||
/******************* Startup / Tick ******************************************/
|
/******************* Startup / Tick ******************************************/
|
||||||
@ -407,7 +407,9 @@ void p3GxsForums::service_tick()
|
|||||||
|
|
||||||
bool p3GxsForums::service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta)
|
bool p3GxsForums::service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta)
|
||||||
{
|
{
|
||||||
|
#ifdef GXSFORUMS_DEBUG
|
||||||
std::cerr << "p3gxsForums: Checking unused forums: called by GxsCleaning." << std::endl;
|
std::cerr << "p3gxsForums: Checking unused forums: called by GxsCleaning." << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
// request all group infos at once
|
// request all group infos at once
|
||||||
|
|
||||||
@ -418,14 +420,18 @@ bool p3GxsForums::service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta)
|
|||||||
auto it = mKnownForums.find(meta.mGroupId);
|
auto it = mKnownForums.find(meta.mGroupId);
|
||||||
bool unknown_forum = it == mKnownForums.end();
|
bool unknown_forum = it == mKnownForums.end();
|
||||||
|
|
||||||
|
#ifdef GXSFORUMS_DEBUG
|
||||||
std::cerr << " Forum " << meta.mGroupId ;
|
std::cerr << " Forum " << meta.mGroupId ;
|
||||||
|
#endif
|
||||||
|
|
||||||
if(unknown_forum)
|
if(unknown_forum)
|
||||||
{
|
{
|
||||||
// This case should normally not happen. It does because this forum was never registered since it may
|
// This case should normally not happen. It does because this forum was never registered since it may
|
||||||
// arrived before this code was here
|
// arrived before this code was here
|
||||||
|
|
||||||
|
#ifdef GXSFORUMS_DEBUG
|
||||||
std::cerr << ". Not known yet. Adding current time as new TS." << std::endl;
|
std::cerr << ". Not known yet. Adding current time as new TS." << std::endl;
|
||||||
|
#endif
|
||||||
mKnownForums[meta.mGroupId] = now;
|
mKnownForums[meta.mGroupId] = now;
|
||||||
IndicateConfigChanged();
|
IndicateConfigChanged();
|
||||||
|
|
||||||
@ -436,16 +442,22 @@ bool p3GxsForums::service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta)
|
|||||||
bool used_by_friends = (now < it->second + FORUM_UNUSED_BY_FRIENDS_DELAY);
|
bool used_by_friends = (now < it->second + FORUM_UNUSED_BY_FRIENDS_DELAY);
|
||||||
bool subscribed = static_cast<bool>(meta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED);
|
bool subscribed = static_cast<bool>(meta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED);
|
||||||
|
|
||||||
|
#ifdef GXSFORUMS_DEBUG
|
||||||
std::cerr << ". subscribed: " << subscribed << ", used_by_friends: " << used_by_friends << " last TS: " << now - it->second << " secs ago (" << (now-it->second)/86400 << " days)";
|
std::cerr << ". subscribed: " << subscribed << ", used_by_friends: " << used_by_friends << " last TS: " << now - it->second << " secs ago (" << (now-it->second)/86400 << " days)";
|
||||||
|
#endif
|
||||||
|
|
||||||
if(!subscribed && !used_by_friends)
|
if(!subscribed && !used_by_friends)
|
||||||
{
|
{
|
||||||
|
#ifdef GXSFORUMS_DEBUG
|
||||||
std::cerr << ". Scheduling for deletion" << std::endl;
|
std::cerr << ". Scheduling for deletion" << std::endl;
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef GXSFORUMS_DEBUG
|
||||||
std::cerr << ". Keeping!" << std::endl;
|
std::cerr << ". Keeping!" << std::endl;
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -910,7 +910,9 @@ public:
|
|||||||
|
|
||||||
bool p3PostBase::service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta)
|
bool p3PostBase::service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta)
|
||||||
{
|
{
|
||||||
|
#ifdef GXSFORUMS_CHANNELS
|
||||||
std::cerr << "p3gxsChannels: Checking unused board: called by GxsCleaning." << std::endl;
|
std::cerr << "p3gxsChannels: Checking unused board: called by GxsCleaning." << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
// request all group infos at once
|
// request all group infos at once
|
||||||
|
|
||||||
@ -921,14 +923,18 @@ bool p3PostBase::service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta)
|
|||||||
auto it = mKnownPosted.find(meta.mGroupId);
|
auto it = mKnownPosted.find(meta.mGroupId);
|
||||||
bool unknown_posted = (it == mKnownPosted.end());
|
bool unknown_posted = (it == mKnownPosted.end());
|
||||||
|
|
||||||
|
#ifdef GXSFORUMS_CHANNELS
|
||||||
std::cerr << " Board " << meta.mGroupId ;
|
std::cerr << " Board " << meta.mGroupId ;
|
||||||
|
#endif
|
||||||
|
|
||||||
if(unknown_posted)
|
if(unknown_posted)
|
||||||
{
|
{
|
||||||
// This case should normally not happen. It does because this board was never registered since it may
|
// This case should normally not happen. It does because this board was never registered since it may
|
||||||
// arrived before this code was here
|
// arrived before this code was here
|
||||||
|
|
||||||
|
#ifdef GXSFORUMS_CHANNELS
|
||||||
std::cerr << ". Not known yet. Adding current time as new TS." << std::endl;
|
std::cerr << ". Not known yet. Adding current time as new TS." << std::endl;
|
||||||
|
#endif
|
||||||
mKnownPosted[meta.mGroupId] = now;
|
mKnownPosted[meta.mGroupId] = now;
|
||||||
IndicateConfigChanged();
|
IndicateConfigChanged();
|
||||||
|
|
||||||
@ -943,12 +949,16 @@ bool p3PostBase::service_checkIfGroupIsStillUsed(const RsGxsGrpMetaData& meta)
|
|||||||
|
|
||||||
if(!subscribed && !used_by_friends)
|
if(!subscribed && !used_by_friends)
|
||||||
{
|
{
|
||||||
|
#ifdef GXSFORUMS_CHANNELS
|
||||||
std::cerr << ". Scheduling for deletion" << std::endl;
|
std::cerr << ". Scheduling for deletion" << std::endl;
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef GXSFORUMS_CHANNELS
|
||||||
std::cerr << ". Keeping!" << std::endl;
|
std::cerr << ". Keeping!" << std::endl;
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user