limited storage of DEAD items in grouter cache to 1 hour to favor re-explore dead routes and limit cache size

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7644 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2014-10-26 16:54:32 +00:00
parent d45a935b3c
commit 59ab1bdc52
2 changed files with 4 additions and 2 deletions

View File

@ -51,7 +51,8 @@ static const time_t RS_GROUTER_MEAN_EXPECTED_RTT = 30 ; // refer
static const uint32_t GROUTER_ITEM_DISTANCE_UNIT = 256 ; // One unit of distance between two peers
static const uint32_t GROUTER_ITEM_MAX_TRAVEL_DISTANCE = 6*256 ; // 6 distance units. That is a lot.
static const uint32_t GROUTER_ITEM_MAX_CACHE_KEEP_TIME = 30*86400 ; // Items are kept in cache for 1 month, to allow sending to peers while not online.
static const uint32_t GROUTER_ITEM_MAX_CACHE_KEEP_TIME = 30*86400 ; // ACKN Items are kept in cache for 1 month, to allow sending acknowledgements to peers while not online.
static const uint32_t GROUTER_ITEM_MAX_CACHE_KEEP_TIME_DEAD= 3600 ; // DEAD Items are kept in cache for only 1 hour to favor re-exploring dead routes.
static const uint32_t RS_GROUTER_ROUTING_STATE_UNKN = 0x0000 ; // unknown. Unused.
static const uint32_t RS_GROUTER_ROUTING_STATE_PEND = 0x0001 ; // item is pending. Should be sent asap.

View File

@ -306,7 +306,8 @@ void p3GRouter::autoWash()
time_t now = time(NULL) ;
for(std::map<GRouterMsgPropagationId,GRouterRoutingInfo>::iterator it(_pending_messages.begin());it!=_pending_messages.end();)
if(it->second.received_time + GROUTER_ITEM_MAX_CACHE_KEEP_TIME < now) // is the item too old for cache
if( (it->second.status_flags == RS_GROUTER_ROUTING_STATE_DEAD && it->second.received_time + GROUTER_ITEM_MAX_CACHE_KEEP_TIME_DEAD < now) // is the item too old for cache
|| (it->second.received_time + GROUTER_ITEM_MAX_CACHE_KEEP_TIME < now)) // is the item too old for cache
{
#ifdef GROUTER_DEBUG
grouter_debug() << " Removing cache item " << std::hex << it->first << std::dec << std::endl;