diff options
| author | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2025-12-05 18:01:28 +0200 |
|---|---|---|
| committer | Andrey Kleshchev <117672381+akleshchev@users.noreply.github.com> | 2025-12-05 23:06:57 +0200 |
| commit | 4f22c12b9a2450edb83b441492d8010dfd135350 (patch) | |
| tree | a86706fe6225cf7b6dc19006e8b44b1dbfcc33ac | |
| parent | 9f82b907f2f7d57580e17cef89bbd08be90f94fb (diff) | |
#5109 LLExperienceCache crashes on a coroutine
| -rw-r--r-- | indra/llmessage/llexperiencecache.cpp | 33 | ||||
| -rw-r--r-- | indra/llmessage/llexperiencecache.h | 4 |
2 files changed, 22 insertions, 15 deletions
diff --git a/indra/llmessage/llexperiencecache.cpp b/indra/llmessage/llexperiencecache.cpp index 149741b9f9..e4c7deb1c5 100644 --- a/indra/llmessage/llexperiencecache.cpp +++ b/indra/llmessage/llexperiencecache.cpp @@ -112,9 +112,7 @@ void LLExperienceCache::initSingleton() constexpr size_t CORO_QUEUE_SIZE = 2048; LLCoprocedureManager::instance().initializePool("ExpCache", CORO_QUEUE_SIZE); - LLCoros::instance().launch("LLExperienceCache::idleCoro", - boost::bind(&LLExperienceCache::idleCoro, this)); - + LLCoros::instance().launch("LLExperienceCache::idleCoro", LLExperienceCache::idleCoro); } void LLExperienceCache::cleanup() @@ -246,6 +244,7 @@ const LLExperienceCache::cache_t& LLExperienceCache::getCached() return mCache; } +// static because used by coroutine and can outlive the instance void LLExperienceCache::requestExperiencesCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, std::string url, RequestQueue_t requests) { LLCore::HttpRequest::ptr_t httpRequest = std::make_shared<LLCore::HttpRequest>(); @@ -254,6 +253,13 @@ void LLExperienceCache::requestExperiencesCoro(LLCoreHttpUtil::HttpCoroutineAdap LLSD result = httpAdapter->getAndSuspend(httpRequest, url); + if (sShutdown) + { + return; + } + + LLExperienceCache* self = LLExperienceCache::getInstance(); + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); @@ -265,7 +271,7 @@ void LLExperienceCache::requestExperiencesCoro(LLCoreHttpUtil::HttpCoroutineAdap // build dummy entries for the failed requests for (RequestQueue_t::const_iterator it = requests.begin(); it != requests.end(); ++it) { - LLSD exp = get(*it); + LLSD exp = self->get(*it); //leave the properties alone if we already have a cache entry for this xp if (exp.isUndefined()) { @@ -278,7 +284,7 @@ void LLExperienceCache::requestExperiencesCoro(LLCoreHttpUtil::HttpCoroutineAdap exp["error"] = (LLSD::Integer)status.getType(); exp[QUOTA] = DEFAULT_QUOTA; - processExperience(*it, exp); + self->processExperience(*it, exp); } return; } @@ -294,7 +300,7 @@ void LLExperienceCache::requestExperiencesCoro(LLCoreHttpUtil::HttpCoroutineAdap LL_DEBUGS("ExperienceCache") << "Received result for " << public_key << " display '" << row[LLExperienceCache::NAME].asString() << "'" << LL_ENDL; - processExperience(public_key, row); + self->processExperience(public_key, row); } LLSD error_ids = result["error_ids"]; @@ -310,7 +316,7 @@ void LLExperienceCache::requestExperiencesCoro(LLCoreHttpUtil::HttpCoroutineAdap exp[MISSING] = true; exp[QUOTA] = DEFAULT_QUOTA; - processExperience(id, exp); + self->processExperience(id, exp); LL_WARNS("ExperienceCache") << "LLExperienceResponder::result() error result for " << id << LL_ENDL; } @@ -361,7 +367,7 @@ void LLExperienceCache::requestExperiences() if (mRequestQueue.empty() || (ostr.tellp() > EXP_URL_SEND_THRESHOLD)) { // request is placed in the coprocedure pool for the ExpCache cache. Throttling is done by the pool itself. LLCoprocedureManager::instance().enqueueCoprocedure("ExpCache", "RequestExperiences", - boost::bind(&LLExperienceCache::requestExperiencesCoro, this, _1, ostr.str(), requests) ); + boost::bind(&LLExperienceCache::requestExperiencesCoro, _1, ostr.str(), requests) ); ostr.str(std::string()); ostr << urlBase << "?page_size=" << PAGE_SIZE1; @@ -393,7 +399,7 @@ void LLExperienceCache::setCapabilityQuery(LLExperienceCache::CapabilityQuery_t mCapability = queryfn; } - +// static, because coro can outlive the instance void LLExperienceCache::idleCoro() { const F32 SECS_BETWEEN_REQUESTS = 0.5f; @@ -402,14 +408,15 @@ void LLExperienceCache::idleCoro() LL_INFOS("ExperienceCache") << "Launching Experience cache idle coro." << LL_ENDL; do { - if (mEraseExpiredTimer.checkExpirationAndReset(ERASE_EXPIRED_TIMEOUT)) + LLExperienceCache* self = LLExperienceCache::getInstance(); + if (self->mEraseExpiredTimer.checkExpirationAndReset(ERASE_EXPIRED_TIMEOUT)) { - eraseExpired(); + self->eraseExpired(); } - if (!mRequestQueue.empty()) + if (!self->mRequestQueue.empty()) { - requestExperiences(); + self->requestExperiences(); } llcoro::suspendUntilTimeout(SECS_BETWEEN_REQUESTS); diff --git a/indra/llmessage/llexperiencecache.h b/indra/llmessage/llexperiencecache.h index 4b344347d5..9ecdb9efca 100644 --- a/indra/llmessage/llexperiencecache.h +++ b/indra/llmessage/llexperiencecache.h @@ -144,9 +144,9 @@ private: std::string mCacheFileName; static bool sShutdown; // control for coroutines, they exist out of LLExperienceCache's scope, so they need a static control - void idleCoro(); + static void idleCoro(); void eraseExpired(); - void requestExperiencesCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &, std::string, RequestQueue_t); + static void requestExperiencesCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &, std::string, RequestQueue_t); void requestExperiences(); void fetchAssociatedExperienceCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &, LLUUID, LLUUID, std::string, ExperienceGetFn_t); |
