mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-21 04:44:25 -04:00
added proper use of storage time parameter in group msg cleanup
This commit is contained in:
parent
b03fe3d4c5
commit
d9416d3e3d
3 changed files with 12 additions and 7 deletions
|
@ -181,9 +181,10 @@ void RsGenExchange::tick()
|
||||||
mLastClean = time(NULL);
|
mLastClean = time(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
}else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
mMsgCleanUp = new RsGxsMessageCleanUp(mDataStore, MESSAGE_STORE_PERIOD, 1);
|
mMsgCleanUp = new RsGxsMessageCleanUp(mDataStore, this, 1);
|
||||||
mCleaning = true;
|
mCleaning = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,8 @@ static const uint32_t MAX_GXS_IDS_REQUESTS_NET = 10 ; // max number of reques
|
||||||
|
|
||||||
//#define GXSUTIL_DEBUG 1
|
//#define GXSUTIL_DEBUG 1
|
||||||
|
|
||||||
RsGxsMessageCleanUp::RsGxsMessageCleanUp(RsGeneralDataService* const dataService, uint32_t messageStorePeriod, uint32_t chunkSize)
|
RsGxsMessageCleanUp::RsGxsMessageCleanUp(RsGeneralDataService* const dataService, RsGenExchange *genex, uint32_t chunkSize)
|
||||||
: mDs(dataService), MESSAGE_STORE_PERIOD(messageStorePeriod), CHUNK_SIZE(chunkSize)
|
: mDs(dataService), mGenExchangeClient(genex), CHUNK_SIZE(chunkSize)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::map<RsGxsGroupId, RsGxsGrpMetaData*> grpMeta;
|
std::map<RsGxsGroupId, RsGxsGrpMetaData*> grpMeta;
|
||||||
|
@ -72,6 +72,8 @@ bool RsGxsMessageCleanUp::clean()
|
||||||
|
|
||||||
req.clear();
|
req.clear();
|
||||||
|
|
||||||
|
uint32_t store_period = mGenExchangeClient->getStoragePeriod(grpId) ;
|
||||||
|
|
||||||
for(; mit != result.end(); ++mit)
|
for(; mit != result.end(); ++mit)
|
||||||
{
|
{
|
||||||
std::vector<RsGxsMsgMetaData*>& metaV = mit->second;
|
std::vector<RsGxsMsgMetaData*>& metaV = mit->second;
|
||||||
|
@ -82,7 +84,7 @@ bool RsGxsMessageCleanUp::clean()
|
||||||
RsGxsMsgMetaData* meta = *vit;
|
RsGxsMsgMetaData* meta = *vit;
|
||||||
|
|
||||||
// check if expired
|
// check if expired
|
||||||
bool remove = (meta->mPublishTs + MESSAGE_STORE_PERIOD) < now;
|
bool remove = (meta->mPublishTs + store_period) < now;
|
||||||
|
|
||||||
// check client does not want the message kept regardless of age
|
// check client does not want the message kept regardless of age
|
||||||
remove &= !(meta->mMsgStatus & GXS_SERV::GXS_MSG_STATUS_KEEP);
|
remove &= !(meta->mMsgStatus & GXS_SERV::GXS_MSG_STATUS_KEEP);
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "rsgds.h"
|
#include "rsgds.h"
|
||||||
|
|
||||||
class RsGixs ;
|
class RsGixs ;
|
||||||
|
class RsGenExchange ;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Handy function for cleaning out meta result containers
|
* Handy function for cleaning out meta result containers
|
||||||
|
@ -73,7 +74,7 @@ public:
|
||||||
* @param chunkSize
|
* @param chunkSize
|
||||||
* @param sleepPeriod
|
* @param sleepPeriod
|
||||||
*/
|
*/
|
||||||
RsGxsMessageCleanUp(RsGeneralDataService* const dataService, uint32_t messageStorePeriod, uint32_t chunkSize);
|
RsGxsMessageCleanUp(RsGeneralDataService* const dataService, RsGenExchange *genex, uint32_t chunkSize);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* On construction this should be called to progress deletions
|
* On construction this should be called to progress deletions
|
||||||
|
@ -90,7 +91,8 @@ public:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
RsGeneralDataService* const mDs;
|
RsGeneralDataService* const mDs;
|
||||||
const uint32_t MESSAGE_STORE_PERIOD, CHUNK_SIZE;
|
RsGenExchange *mGenExchangeClient;
|
||||||
|
uint32_t CHUNK_SIZE;
|
||||||
std::vector<RsGxsGrpMetaData*> mGrpMeta;
|
std::vector<RsGxsGrpMetaData*> mGrpMeta;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue