From 384131a231eebcd340a10fca29a213f541b2197f Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 15 Mar 2016 22:41:59 -0400 Subject: [PATCH] added force reload of cache for circles that are modified --- libretroshare/src/services/p3gxscircles.cc | 29 +++++++++++++++++++++- libretroshare/src/services/p3gxscircles.h | 1 + 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/libretroshare/src/services/p3gxscircles.cc b/libretroshare/src/services/p3gxscircles.cc index ccdae9186..fafe04c1a 100644 --- a/libretroshare/src/services/p3gxscircles.cc +++ b/libretroshare/src/services/p3gxscircles.cc @@ -239,7 +239,7 @@ void p3GxsCircles::notifyChanges(std::vector &changes) #ifdef DEBUG_CIRCLES std::cerr << " forcing cache loading for circle " << *git << " in order to trigger subscribe update." << std::endl; #endif - cache_request_load(RsGxsCircleId(*git)) ; + force_cache_reload(RsGxsCircleId(*git)) ; } } RsGxsIfaceHelper::receiveChanges(changes); // this clear up the vector and delete its elements @@ -780,6 +780,33 @@ bool p3GxsCircles::cachetest_handlerequest(uint32_t token) /************************************************************************************/ // Complicated deal of loading Circles. +bool p3GxsCircles::force_cache_reload(const RsGxsCircleId& id) +{ +#ifdef DEBUG_CIRCLES + std::cerr << "p3GxsCircles::force_cache_reload(): Forcing cache reload of Circle ID " << id << std::endl; +#endif + + { + RsStackMutex stack(mCircleMtx); /********** STACK LOCKED MTX ******/ + +#ifdef DEBUG_CIRCLES + std::cerr << " clearing from existing cache entries..." << std::endl; +#endif + + std::map::iterator it = mLoadingCache.find(id); + if (it != mLoadingCache.end()) + { + mLoadingCache.erase(it) ; +#ifdef DEBUG_CIRCLES + std::cerr << " removed item from currently loading cache entries..." << std::endl; +#endif + } + mCircleCache.erase(id) ; + } + cache_request_load(id) ; + + return true ; +} bool p3GxsCircles::cache_request_load(const RsGxsCircleId &id) { diff --git a/libretroshare/src/services/p3gxscircles.h b/libretroshare/src/services/p3gxscircles.h index 9387421f9..4084b72cf 100644 --- a/libretroshare/src/services/p3gxscircles.h +++ b/libretroshare/src/services/p3gxscircles.h @@ -223,6 +223,7 @@ virtual RsServiceInfo getServiceInfo(); bool cache_request_load(const RsGxsCircleId &id); bool cache_start_load(); + bool force_cache_reload(const RsGxsCircleId& id); bool cache_load_for_token(uint32_t token); bool cache_reloadids(const RsGxsCircleId &circleId);