added a function to check keep/req times for consistency

This commit is contained in:
csoler 2016-12-05 23:42:44 +01:00
parent 7afb91d1db
commit 661038d9b2
5 changed files with 51 additions and 24 deletions

View file

@ -37,8 +37,8 @@ typedef std::map<RsGxsGrpMsgIdPair, std::vector<RsGxsMsgMetaData*> > MsgRelatedM
// Default values that are used throughout GXS code
static const uint32_t RS_GXS_DEFAULT_MSG_STORE_PERIOD = 86400 * 31 * 6 ; // six months. Default time for which messages are keps in the database.
static const uint32_t RS_GXS_DEFAULT_MSG_SEND_PERIOD = 86400 * 31 * 1 ; // one months. Default delay after which we don't send messages
static const uint32_t RS_GXS_DEFAULT_MSG_REQ_PERIOD = 86400 * 31 * 1 ; // one months. Default Delay after which we don't request messages
static const uint32_t RS_GXS_DEFAULT_MSG_STORE_PERIOD = 86400 * 30 * 6 ; // six months. Default time for which messages are keps in the database.
static const uint32_t RS_GXS_DEFAULT_MSG_SEND_PERIOD = 86400 * 30 * 1 ; // one month. Default delay after which we don't send messages
static const uint32_t RS_GXS_DEFAULT_MSG_REQ_PERIOD = 86400 * 30 * 1 ; // one month. Default Delay after which we don't request messages
#endif // RSGXS_H

View file

@ -1401,11 +1401,27 @@ bool RsGxsNetService::loadList(std::list<RsItem *> &load)
// Actual suppliers will come back automatically.
it->second.suppliers.ids.clear() ;
// also make sure that values stored for keep and req delays correspond to the canonical values
locked_checkDelay(it->second.msg_req_delay);
locked_checkDelay(it->second.msg_keep_delay);
}
return true;
}
void RsGxsNetService::locked_checkDelay(uint32_t& time_in_secs)
{
if(time_in_secs < 1 * 86400) { time_in_secs = 0 ; return ; }
if(time_in_secs <= 10 * 86400) { time_in_secs = 5 * 86400; return ; }
if(time_in_secs <= 20 * 86400) { time_in_secs = 15 * 86400; return ; }
if(time_in_secs <= 60 * 86400) { time_in_secs = 30 * 86400; return ; }
if(time_in_secs <= 120 * 86400) { time_in_secs = 90 * 86400; return ; }
if(time_in_secs <= 250 * 86400) { time_in_secs = 180 * 86400; return ; }
time_in_secs = 365 * 86400;
}
#include <algorithm>
template <typename UpdateMap,class ItemClass>
@ -4410,6 +4426,8 @@ void RsGxsNetService::setSyncAge(const RsGxsGroupId &grpId, uint32_t age_in_secs
{
RS_STACK_MUTEX(mNxsMutex) ;
locked_checkDelay(age_in_secs) ;
RsGxsGrpConfig& conf(mServerGrpConfigMap[grpId]) ;
if(conf.msg_req_delay != age_in_secs)
@ -4422,6 +4440,8 @@ void RsGxsNetService::setKeepAge(const RsGxsGroupId &grpId, uint32_t age_in_secs
{
RS_STACK_MUTEX(mNxsMutex) ;
locked_checkDelay(age_in_secs) ;
RsGxsGrpConfig& conf(mServerGrpConfigMap[grpId]) ;
if(conf.msg_keep_delay != age_in_secs)
@ -4438,7 +4458,7 @@ uint32_t RsGxsNetService::getSyncAge(const RsGxsGroupId& grpId)
GrpConfigMap::const_iterator it = mServerGrpConfigMap.find(grpId) ;
if(it == mServerGrpConfigMap.end())
return mSYNC_PERIOD ;
return RS_GXS_DEFAULT_MSG_REQ_PERIOD ;
else
return it->second.msg_keep_delay ;
}

View file

@ -112,7 +112,7 @@ public:
virtual uint32_t getSyncAge(const RsGxsGroupId& id);
virtual uint32_t getKeepAge(const RsGxsGroupId& id,uint32_t default_value);
virtual uint32_t getDefaultSyncAge() { return mSYNC_PERIOD ; }
virtual uint32_t getDefaultSyncAge() { return RS_GXS_DEFAULT_MSG_REQ_PERIOD ; }
/*!
* pauses synchronisation of subscribed groups and request for group id
@ -487,6 +487,7 @@ private:
private:
static void locked_checkDelay(uint32_t& time_in_secs);
/*** transactions ***/