mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed updating of membership when loading circle cache entry
This commit is contained in:
parent
fac1fb84e8
commit
55cb15caa9
@ -35,6 +35,7 @@ uint32_t RsGxsCircleSerialiser::size(RsItem *item)
|
||||
{
|
||||
RsGxsCircleGroupItem* grp_item = NULL;
|
||||
RsGxsCircleMsgItem* snap_item = NULL;
|
||||
RsGxsCircleSubscriptionRequestItem* subr_item = NULL;
|
||||
|
||||
if((grp_item = dynamic_cast<RsGxsCircleGroupItem*>(item)) != NULL)
|
||||
{
|
||||
@ -43,6 +44,10 @@ uint32_t RsGxsCircleSerialiser::size(RsItem *item)
|
||||
else if((snap_item = dynamic_cast<RsGxsCircleMsgItem*>(item)) != NULL)
|
||||
{
|
||||
return sizeGxsCircleMsgItem(snap_item);
|
||||
}
|
||||
else if((subr_item = dynamic_cast<RsGxsCircleSubscriptionRequestItem*>(item)) != NULL)
|
||||
{
|
||||
return sizeGxsCircleSubscriptionRequestItem(subr_item);
|
||||
}
|
||||
else
|
||||
return 0 ;
|
||||
|
@ -103,7 +103,8 @@ RsGxsCircles *rsGxsCircles = NULL;
|
||||
#define GXSID_LOAD_CYCLE 10 // GXSID completes a load in this period.
|
||||
|
||||
#define MIN_CIRCLE_LOAD_GAP 5
|
||||
#define GXS_CIRCLE_DELAY_TO_FORCE_MEMBERSHIP_UPDATE 1200 // re-check every 20 mins. Normally this shouldn't be necessary since notifications inform abotu new messages.
|
||||
#define GXS_CIRCLE_DELAY_TO_FORCE_MEMBERSHIP_UPDATE 60 // re-check every 1 mins. Normally this shouldn't be necessary since notifications inform abotu new messages.
|
||||
#define GXS_CIRCLE_DELAY_TO_CHECK_MEMBERSHIP_UPDATE 60 // re-check every 1 mins. Normally this shouldn't be necessary since notifications inform abotu new messages.
|
||||
|
||||
/********************************************************************************/
|
||||
/******************* Startup / Tick ******************************************/
|
||||
@ -122,7 +123,8 @@ p3GxsCircles::p3GxsCircles(RsGeneralDataService *gds, RsNetworkExchangeService *
|
||||
{
|
||||
// Kick off Cache Testing, + Others.
|
||||
//RsTickEvent::schedule_in(CIRCLE_EVENT_CACHETEST, CACHETEST_PERIOD);
|
||||
|
||||
mLastCacheMembershipUpdateTS = 0 ;
|
||||
|
||||
RsTickEvent::schedule_now(CIRCLE_EVENT_LOADIDS);
|
||||
|
||||
// Dummy Circles.
|
||||
@ -183,6 +185,13 @@ void p3GxsCircles::service_tick()
|
||||
{
|
||||
RsTickEvent::tick_events();
|
||||
GxsTokenQueue::checkRequests(); // GxsTokenQueue handles all requests.
|
||||
|
||||
time_t now = time(NULL);
|
||||
if(now > mLastCacheMembershipUpdateTS + GXS_CIRCLE_DELAY_TO_CHECK_MEMBERSHIP_UPDATE)
|
||||
{
|
||||
p3GxsCircles::checkCircleCacheForMembershipUpdate();
|
||||
mLastCacheMembershipUpdateTS = now ;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -558,6 +567,7 @@ RsGxsCircleCache::RsGxsCircleCache()
|
||||
mUpdateTime = 0;
|
||||
mGroupStatus = 0;
|
||||
mGroupSubscribeFlags = 0;
|
||||
mLastUpdatedMembershipTS = 0 ;
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1124,7 +1134,8 @@ bool p3GxsCircles::locked_processLoadingCacheEntry(RsGxsCircleCache& cache)
|
||||
// We can check for self inclusion in the circle right away, since own ids are always loaded.
|
||||
// that allows to subscribe/unsubscribe uncomplete circles
|
||||
|
||||
checkCircleCacheForAutoSubscribe(cache);
|
||||
locked_checkCircleCacheForAutoSubscribe(cache);
|
||||
locked_checkCircleCacheForMembershipUpdate(cache);
|
||||
|
||||
// always store in cache even if uncomplete. But do not remove the loading items so that they can be kept in loading state.
|
||||
// if(isUnprocessedPeers)
|
||||
@ -1177,32 +1188,42 @@ bool p3GxsCircles::cache_reloadids(const RsGxsCircleId &circleId)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3GxsCircles::checkCircleCacheForMembershipUpdate(RsGxsCircleCache& cache)
|
||||
bool p3GxsCircles::checkCircleCacheForMembershipUpdate()
|
||||
{
|
||||
time_t now = time(NULL) ;
|
||||
#warning TODO. Should go over existing cache entries and update/process the membership requests
|
||||
std::cerr << __PRETTY_FUNCTION__ << ": not implemented!" << std::endl;
|
||||
return false ;
|
||||
}
|
||||
|
||||
if(cache.mLastUpdatedMembershipTS + GXS_CIRCLE_DELAY_TO_FORCE_MEMBERSHIP_UPDATE < now)
|
||||
{
|
||||
// this should be called regularly
|
||||
uint32_t token ;
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
std::list<RsGxsGroupId> grpIds ;
|
||||
bool p3GxsCircles::locked_checkCircleCacheForMembershipUpdate(RsGxsCircleCache& cache)
|
||||
{
|
||||
time_t now = time(NULL) ;
|
||||
|
||||
grpIds.push_back(RsGxsGroupId(cache.mCircleId)) ;
|
||||
if(cache.mLastUpdatedMembershipTS + GXS_CIRCLE_DELAY_TO_FORCE_MEMBERSHIP_UPDATE < now)
|
||||
{
|
||||
std::cerr << "Cache entry for circle " << cache.mCircleId << " needs a swab over membership requests. Re-scheduling it." << std::endl;
|
||||
|
||||
RsGenExchange::getTokenService()->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, grpIds);
|
||||
GxsTokenQueue::queueRequest(token, CIRCLEREQ_MESSAGE_DATA);
|
||||
}
|
||||
return true ;
|
||||
// this should be called regularly
|
||||
|
||||
uint32_t token ;
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
std::list<RsGxsGroupId> grpIds ;
|
||||
|
||||
grpIds.push_back(RsGxsGroupId(cache.mCircleId)) ;
|
||||
|
||||
RsGenExchange::getTokenService()->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, grpIds);
|
||||
GxsTokenQueue::queueRequest(token, CIRCLEREQ_MESSAGE_DATA);
|
||||
}
|
||||
return true ;
|
||||
}
|
||||
|
||||
/* We need to AutoSubscribe if the Circle is relevent to us */
|
||||
|
||||
bool p3GxsCircles::checkCircleCacheForAutoSubscribe(RsGxsCircleCache &cache)
|
||||
bool p3GxsCircles::locked_checkCircleCacheForAutoSubscribe(RsGxsCircleCache &cache)
|
||||
{
|
||||
#ifdef DEBUG_CIRCLES
|
||||
std::cerr << "p3GxsCircles::checkCircleCacheForAutoSubscribe() : "<< cache.mCircleId << std::endl;
|
||||
std::cerr << "p3GxsCircles::locked_checkCircleCacheForAutoSubscribe() : "<< cache.mCircleId << std::endl;
|
||||
#endif
|
||||
|
||||
/* if processed already - ignore */
|
||||
|
@ -247,9 +247,11 @@ virtual RsServiceInfo getServiceInfo();
|
||||
bool cache_load_for_token(uint32_t token);
|
||||
bool cache_reloadids(const RsGxsCircleId &circleId);
|
||||
|
||||
bool checkCircleCacheForAutoSubscribe(RsGxsCircleCache &cache);
|
||||
bool checkCircleCacheForMembershipUpdate(RsGxsCircleCache& cache);
|
||||
bool checkCircleCacheForMembershipUpdate();
|
||||
|
||||
bool locked_checkCircleCacheForAutoSubscribe(RsGxsCircleCache &cache);
|
||||
bool locked_processLoadingCacheEntry(RsGxsCircleCache &cache);
|
||||
bool locked_checkCircleCacheForMembershipUpdate(RsGxsCircleCache &cache);
|
||||
|
||||
p3IdService *mIdentities; // Needed for constructing Circle Info,
|
||||
PgpAuxUtils *mPgpUtils;
|
||||
@ -286,6 +288,7 @@ virtual RsServiceInfo getServiceInfo();
|
||||
void checkDummyIdData();
|
||||
void generateDummyCircle();
|
||||
|
||||
time_t mLastCacheMembershipUpdateTS ;
|
||||
|
||||
uint32_t mDummyIdToken;
|
||||
std::list<RsGxsId> mDummyPgpLinkedIds;
|
||||
|
@ -50,7 +50,6 @@
|
||||
/******
|
||||
* #define ID_DEBUG 1
|
||||
*****/
|
||||
#define ID_DEBUG 1
|
||||
|
||||
// Data Requests.
|
||||
#define IDDIALOG_IDLIST 1
|
||||
|
Loading…
Reference in New Issue
Block a user