mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-23 08:11:24 -04:00
fixed updating of membership when loading circle cache entry
This commit is contained in:
parent
fac1fb84e8
commit
55cb15caa9
4 changed files with 50 additions and 22 deletions
|
@ -35,6 +35,7 @@ uint32_t RsGxsCircleSerialiser::size(RsItem *item)
|
||||||
{
|
{
|
||||||
RsGxsCircleGroupItem* grp_item = NULL;
|
RsGxsCircleGroupItem* grp_item = NULL;
|
||||||
RsGxsCircleMsgItem* snap_item = NULL;
|
RsGxsCircleMsgItem* snap_item = NULL;
|
||||||
|
RsGxsCircleSubscriptionRequestItem* subr_item = NULL;
|
||||||
|
|
||||||
if((grp_item = dynamic_cast<RsGxsCircleGroupItem*>(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)
|
else if((snap_item = dynamic_cast<RsGxsCircleMsgItem*>(item)) != NULL)
|
||||||
{
|
{
|
||||||
return sizeGxsCircleMsgItem(snap_item);
|
return sizeGxsCircleMsgItem(snap_item);
|
||||||
|
}
|
||||||
|
else if((subr_item = dynamic_cast<RsGxsCircleSubscriptionRequestItem*>(item)) != NULL)
|
||||||
|
{
|
||||||
|
return sizeGxsCircleSubscriptionRequestItem(subr_item);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return 0 ;
|
return 0 ;
|
||||||
|
|
|
@ -103,7 +103,8 @@ RsGxsCircles *rsGxsCircles = NULL;
|
||||||
#define GXSID_LOAD_CYCLE 10 // GXSID completes a load in this period.
|
#define GXSID_LOAD_CYCLE 10 // GXSID completes a load in this period.
|
||||||
|
|
||||||
#define MIN_CIRCLE_LOAD_GAP 5
|
#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 ******************************************/
|
/******************* Startup / Tick ******************************************/
|
||||||
|
@ -122,6 +123,7 @@ p3GxsCircles::p3GxsCircles(RsGeneralDataService *gds, RsNetworkExchangeService *
|
||||||
{
|
{
|
||||||
// Kick off Cache Testing, + Others.
|
// Kick off Cache Testing, + Others.
|
||||||
//RsTickEvent::schedule_in(CIRCLE_EVENT_CACHETEST, CACHETEST_PERIOD);
|
//RsTickEvent::schedule_in(CIRCLE_EVENT_CACHETEST, CACHETEST_PERIOD);
|
||||||
|
mLastCacheMembershipUpdateTS = 0 ;
|
||||||
|
|
||||||
RsTickEvent::schedule_now(CIRCLE_EVENT_LOADIDS);
|
RsTickEvent::schedule_now(CIRCLE_EVENT_LOADIDS);
|
||||||
|
|
||||||
|
@ -183,6 +185,13 @@ void p3GxsCircles::service_tick()
|
||||||
{
|
{
|
||||||
RsTickEvent::tick_events();
|
RsTickEvent::tick_events();
|
||||||
GxsTokenQueue::checkRequests(); // GxsTokenQueue handles all requests.
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -558,6 +567,7 @@ RsGxsCircleCache::RsGxsCircleCache()
|
||||||
mUpdateTime = 0;
|
mUpdateTime = 0;
|
||||||
mGroupStatus = 0;
|
mGroupStatus = 0;
|
||||||
mGroupSubscribeFlags = 0;
|
mGroupSubscribeFlags = 0;
|
||||||
|
mLastUpdatedMembershipTS = 0 ;
|
||||||
|
|
||||||
return;
|
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.
|
// We can check for self inclusion in the circle right away, since own ids are always loaded.
|
||||||
// that allows to subscribe/unsubscribe uncomplete circles
|
// 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.
|
// 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)
|
// if(isUnprocessedPeers)
|
||||||
|
@ -1177,32 +1188,42 @@ bool p3GxsCircles::cache_reloadids(const RsGxsCircleId &circleId)
|
||||||
return true;
|
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)
|
bool p3GxsCircles::locked_checkCircleCacheForMembershipUpdate(RsGxsCircleCache& cache)
|
||||||
{
|
{
|
||||||
// this should be called regularly
|
time_t now = time(NULL) ;
|
||||||
uint32_t token ;
|
|
||||||
RsTokReqOptions opts;
|
|
||||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
|
||||||
std::list<RsGxsGroupId> grpIds ;
|
|
||||||
|
|
||||||
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);
|
// this should be called regularly
|
||||||
GxsTokenQueue::queueRequest(token, CIRCLEREQ_MESSAGE_DATA);
|
|
||||||
}
|
uint32_t token ;
|
||||||
return true ;
|
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 */
|
/* 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
|
#ifdef DEBUG_CIRCLES
|
||||||
std::cerr << "p3GxsCircles::checkCircleCacheForAutoSubscribe() : "<< cache.mCircleId << std::endl;
|
std::cerr << "p3GxsCircles::locked_checkCircleCacheForAutoSubscribe() : "<< cache.mCircleId << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* if processed already - ignore */
|
/* if processed already - ignore */
|
||||||
|
|
|
@ -247,9 +247,11 @@ virtual RsServiceInfo getServiceInfo();
|
||||||
bool cache_load_for_token(uint32_t token);
|
bool cache_load_for_token(uint32_t token);
|
||||||
bool cache_reloadids(const RsGxsCircleId &circleId);
|
bool cache_reloadids(const RsGxsCircleId &circleId);
|
||||||
|
|
||||||
bool checkCircleCacheForAutoSubscribe(RsGxsCircleCache &cache);
|
bool checkCircleCacheForMembershipUpdate();
|
||||||
bool checkCircleCacheForMembershipUpdate(RsGxsCircleCache& cache);
|
|
||||||
|
bool locked_checkCircleCacheForAutoSubscribe(RsGxsCircleCache &cache);
|
||||||
bool locked_processLoadingCacheEntry(RsGxsCircleCache &cache);
|
bool locked_processLoadingCacheEntry(RsGxsCircleCache &cache);
|
||||||
|
bool locked_checkCircleCacheForMembershipUpdate(RsGxsCircleCache &cache);
|
||||||
|
|
||||||
p3IdService *mIdentities; // Needed for constructing Circle Info,
|
p3IdService *mIdentities; // Needed for constructing Circle Info,
|
||||||
PgpAuxUtils *mPgpUtils;
|
PgpAuxUtils *mPgpUtils;
|
||||||
|
@ -286,6 +288,7 @@ virtual RsServiceInfo getServiceInfo();
|
||||||
void checkDummyIdData();
|
void checkDummyIdData();
|
||||||
void generateDummyCircle();
|
void generateDummyCircle();
|
||||||
|
|
||||||
|
time_t mLastCacheMembershipUpdateTS ;
|
||||||
|
|
||||||
uint32_t mDummyIdToken;
|
uint32_t mDummyIdToken;
|
||||||
std::list<RsGxsId> mDummyPgpLinkedIds;
|
std::list<RsGxsId> mDummyPgpLinkedIds;
|
||||||
|
|
|
@ -50,7 +50,6 @@
|
||||||
/******
|
/******
|
||||||
* #define ID_DEBUG 1
|
* #define ID_DEBUG 1
|
||||||
*****/
|
*****/
|
||||||
#define ID_DEBUG 1
|
|
||||||
|
|
||||||
// Data Requests.
|
// Data Requests.
|
||||||
#define IDDIALOG_IDLIST 1
|
#define IDDIALOG_IDLIST 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue