@@ -114,9 +114,7 @@ void LLExperienceCache::initSingleton()
114114 constexpr size_t CORO_QUEUE_SIZE = 2048 ;
115115 LLCoprocedureManager::instance ().initializePool (" ExpCache" , CORO_QUEUE_SIZE);
116116
117- LLCoros::instance ().launch (" LLExperienceCache::idleCoro" ,
118- boost::bind (&LLExperienceCache::idleCoro, this ));
119-
117+ LLCoros::instance ().launch (" LLExperienceCache::idleCoro" , LLExperienceCache::idleCoro);
120118}
121119
122120void LLExperienceCache::cleanup ()
@@ -248,6 +246,7 @@ const LLExperienceCache::cache_t& LLExperienceCache::getCached()
248246 return mCache ;
249247}
250248
249+ // static because used by coroutine and can outlive the instance
251250void LLExperienceCache::requestExperiencesCoro (LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, std::string url, RequestQueue_t requests)
252251{
253252 LLCore::HttpRequest::ptr_t httpRequest = std::make_shared<LLCore::HttpRequest>();
@@ -256,6 +255,13 @@ void LLExperienceCache::requestExperiencesCoro(LLCoreHttpUtil::HttpCoroutineAdap
256255
257256 LLSD result = httpAdapter->getAndSuspend (httpRequest, url);
258257
258+ if (sShutdown )
259+ {
260+ return ;
261+ }
262+
263+ LLExperienceCache* self = LLExperienceCache::getInstance ();
264+
259265 LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
260266 LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD (httpResults);
261267
@@ -267,7 +273,7 @@ void LLExperienceCache::requestExperiencesCoro(LLCoreHttpUtil::HttpCoroutineAdap
267273 // build dummy entries for the failed requests
268274 for (RequestQueue_t::const_iterator it = requests.begin (); it != requests.end (); ++it)
269275 {
270- LLSD exp = get (*it);
276+ LLSD exp = self-> get (*it);
271277 // leave the properties alone if we already have a cache entry for this xp
272278 if (exp.isUndefined ())
273279 {
@@ -280,7 +286,7 @@ void LLExperienceCache::requestExperiencesCoro(LLCoreHttpUtil::HttpCoroutineAdap
280286 exp[" error" ] = (LLSD::Integer)status.getType ();
281287 exp[QUOTA] = DEFAULT_QUOTA;
282288
283- processExperience (*it, exp);
289+ self-> processExperience (*it, exp);
284290 }
285291 return ;
286292 }
@@ -296,7 +302,7 @@ void LLExperienceCache::requestExperiencesCoro(LLCoreHttpUtil::HttpCoroutineAdap
296302 LL_DEBUGS (" ExperienceCache" ) << " Received result for " << public_key
297303 << " display '" << row[LLExperienceCache::NAME].asString () << " '" << LL_ENDL;
298304
299- processExperience (public_key, row);
305+ self-> processExperience (public_key, row);
300306 }
301307
302308 LLSD error_ids = result[" error_ids" ];
@@ -312,7 +318,7 @@ void LLExperienceCache::requestExperiencesCoro(LLCoreHttpUtil::HttpCoroutineAdap
312318 exp[MISSING] = true ;
313319 exp[QUOTA] = DEFAULT_QUOTA;
314320
315- processExperience (id, exp);
321+ self-> processExperience (id, exp);
316322 LL_WARNS (" ExperienceCache" ) << " LLExperienceResponder::result() error result for " << id << LL_ENDL;
317323 }
318324
@@ -363,7 +369,7 @@ void LLExperienceCache::requestExperiences()
363369 if (mRequestQueue .empty () || (ostr.tellp () > EXP_URL_SEND_THRESHOLD))
364370 { // request is placed in the coprocedure pool for the ExpCache cache. Throttling is done by the pool itself.
365371 LLCoprocedureManager::instance ().enqueueCoprocedure (" ExpCache" , " RequestExperiences" ,
366- boost::bind (&LLExperienceCache::requestExperiencesCoro, this , _1, ostr.str (), requests) );
372+ boost::bind (&LLExperienceCache::requestExperiencesCoro, _1, ostr.str (), requests) );
367373
368374 ostr.str (std::string ());
369375 ostr << urlBase << " ?page_size=" << PAGE_SIZE1;
@@ -395,7 +401,7 @@ void LLExperienceCache::setCapabilityQuery(LLExperienceCache::CapabilityQuery_t
395401 mCapability = queryfn;
396402}
397403
398-
404+ // static, because coro can outlive the instance
399405void LLExperienceCache::idleCoro ()
400406{
401407 const F32 SECS_BETWEEN_REQUESTS = 0 .5f ;
@@ -404,14 +410,15 @@ void LLExperienceCache::idleCoro()
404410 LL_INFOS (" ExperienceCache" ) << " Launching Experience cache idle coro." << LL_ENDL;
405411 do
406412 {
407- if (mEraseExpiredTimer .checkExpirationAndReset (ERASE_EXPIRED_TIMEOUT))
413+ LLExperienceCache* self = LLExperienceCache::getInstance ();
414+ if (self->mEraseExpiredTimer .checkExpirationAndReset (ERASE_EXPIRED_TIMEOUT))
408415 {
409- eraseExpired ();
416+ self-> eraseExpired ();
410417 }
411418
412- if (!mRequestQueue .empty ())
419+ if (!self-> mRequestQueue .empty ())
413420 {
414- requestExperiences ();
421+ self-> requestExperiences ();
415422 }
416423
417424 llcoro::suspendUntilTimeout (SECS_BETWEEN_REQUESTS);
0 commit comments