summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2019-11-22 11:58:27 -0500
committerNat Goodspeed <nat@lindenlab.com>2020-03-25 19:24:25 -0400
commit2a56ab44360aa49bd0df9281efc8a8a97a510013 (patch)
tree4653d4a08e7043a9b90eb26ce7370cf6f7a6a300 /indra
parent95cf6dddae371c8f53a2495a12e188bb2ca02799 (diff)
DRTVWR-476, SL-12197: Don't throw Stopping from main coroutine.
The new LLCoros::Stop exception is intended to terminate long-lived coroutines -- not interrupt mainstream shutdown processing. Only throw it on an explicitly-launched coroutine. Make LLCoros::getName() (used by the above test) static. As with other LLCoros methods, it might be called after the LLCoros LLSingleton instance has been deleted. Requiring the caller to call instance() implies a possible need to also call wasDeleted(). Encapsulate that nuance into a static method instead.
Diffstat (limited to 'indra')
-rw-r--r--indra/llcommon/llcoros.cpp12
-rw-r--r--indra/llcommon/llcoros.h4
-rw-r--r--indra/llcommon/lleventcoro.cpp2
-rw-r--r--indra/llmessage/llavatarnamecache.cpp4
-rw-r--r--indra/newview/llaccountingcostmanager.cpp4
-rw-r--r--indra/viewer_components/login/lllogin.cpp4
6 files changed, 20 insertions, 10 deletions
diff --git a/indra/llcommon/llcoros.cpp b/indra/llcommon/llcoros.cpp
index febe74b559..5f940de52b 100644
--- a/indra/llcommon/llcoros.cpp
+++ b/indra/llcommon/llcoros.cpp
@@ -192,7 +192,8 @@ bool LLCoros::kill(const std::string& name)
}
|*==========================================================================*/
-std::string LLCoros::getName() const
+//static
+std::string LLCoros::getName()
{
return get_CoroData("getName()").mName;
}
@@ -320,12 +321,21 @@ void LLCoros::toplevel(std::string name, callable_t callable)
}
}
+//static
void LLCoros::checkStop()
{
if (wasDeleted())
{
LLTHROW(Shutdown("LLCoros was deleted"));
}
+ // do this AFTER the check above, because getName() depends on
+ // get_CoroData(), which depends on the local_ptr in our instance().
+ if (getName().empty())
+ {
+ // Our Stop exception and its subclasses are intended to stop loitering
+ // coroutines. Don't throw it from the main coroutine.
+ return;
+ }
if (LLApp::isStopped())
{
LLTHROW(Stopped("viewer is stopped"));
diff --git a/indra/llcommon/llcoros.h b/indra/llcommon/llcoros.h
index 7b3420cc8f..2e4cd8ccad 100644
--- a/indra/llcommon/llcoros.h
+++ b/indra/llcommon/llcoros.h
@@ -140,7 +140,7 @@ public:
* (e.g. if the coroutine was launched by hand rather than using
* LLCoros::launch()).
*/
- std::string getName() const;
+ static std::string getName();
/**
* For delayed initialization. To be clear, this will only affect
@@ -295,7 +295,7 @@ inline
std::string logname()
{
static std::string main("main");
- std::string name(LLCoros::instance().getName());
+ std::string name(LLCoros::getName());
return name.empty()? main : name;
}
diff --git a/indra/llcommon/lleventcoro.cpp b/indra/llcommon/lleventcoro.cpp
index 967c4d74d8..11b6e5bb2f 100644
--- a/indra/llcommon/lleventcoro.cpp
+++ b/indra/llcommon/lleventcoro.cpp
@@ -62,7 +62,7 @@ namespace
std::string listenerNameForCoro()
{
// If this coroutine was launched by LLCoros::launch(), find that name.
- std::string name(LLCoros::instance().getName());
+ std::string name(LLCoros::getName());
if (! name.empty())
{
return name;
diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp
index 6a287f0cc5..fbd65cc67b 100644
--- a/indra/llmessage/llavatarnamecache.cpp
+++ b/indra/llmessage/llavatarnamecache.cpp
@@ -134,7 +134,7 @@ LLAvatarNameCache::~LLAvatarNameCache()
void LLAvatarNameCache::requestAvatarNameCache_(std::string url, std::vector<LLUUID> agentIds)
{
- LL_DEBUGS("AvNameCache") << "Entering coroutine " << LLCoros::instance().getName()
+ LL_DEBUGS("AvNameCache") << "Entering coroutine " << LLCoros::getName()
<< " with url '" << url << "', requesting " << agentIds.size() << " Agent Ids" << LL_ENDL;
// Check pointer that can be cleaned up by cleanupClass()
@@ -188,7 +188,7 @@ void LLAvatarNameCache::requestAvatarNameCache_(std::string url, std::vector<LLU
}
catch (...)
{
- LOG_UNHANDLED_EXCEPTION(STRINGIZE("coroutine " << LLCoros::instance().getName()
+ LOG_UNHANDLED_EXCEPTION(STRINGIZE("coroutine " << LLCoros::getName()
<< "('" << url << "', " << agentIds.size()
<< " http result: " << httpResults.asString()
<< " Agent Ids)"));
diff --git a/indra/newview/llaccountingcostmanager.cpp b/indra/newview/llaccountingcostmanager.cpp
index 1dddf52961..e09527a34b 100644
--- a/indra/newview/llaccountingcostmanager.cpp
+++ b/indra/newview/llaccountingcostmanager.cpp
@@ -48,7 +48,7 @@ LLAccountingCostManager::LLAccountingCostManager()
void LLAccountingCostManager::accountingCostCoro(std::string url,
eSelectionType selectionType, const LLHandle<LLAccountingCostObserver> observerHandle)
{
- LL_DEBUGS("LLAccountingCostManager") << "Entering coroutine " << LLCoros::instance().getName()
+ LL_DEBUGS("LLAccountingCostManager") << "Entering coroutine " << LLCoros::getName()
<< " with url '" << url << LL_ENDL;
LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
@@ -158,7 +158,7 @@ void LLAccountingCostManager::accountingCostCoro(std::string url,
}
catch (...)
{
- LOG_UNHANDLED_EXCEPTION(STRINGIZE("coroutine " << LLCoros::instance().getName()
+ LOG_UNHANDLED_EXCEPTION(STRINGIZE("coroutine " << LLCoros::getName()
<< "('" << url << "')"));
throw;
}
diff --git a/indra/viewer_components/login/lllogin.cpp b/indra/viewer_components/login/lllogin.cpp
index 1a06459318..57a7c03525 100644
--- a/indra/viewer_components/login/lllogin.cpp
+++ b/indra/viewer_components/login/lllogin.cpp
@@ -148,7 +148,7 @@ void LLLogin::Impl::loginCoro(std::string uri, LLSD login_params)
}
try
{
- LL_DEBUGS("LLLogin") << "Entering coroutine " << LLCoros::instance().getName()
+ LL_DEBUGS("LLLogin") << "Entering coroutine " << LLCoros::getName()
<< " with uri '" << uri << "', parameters " << printable_params << LL_ENDL;
LLEventPump& xmlrpcPump(LLEventPumps::instance().obtain("LLXMLRPCTransaction"));
@@ -307,7 +307,7 @@ void LLLogin::Impl::loginCoro(std::string uri, LLSD login_params)
sendProgressEvent("offline", "fail.login", error_response);
}
catch (...) {
- CRASH_ON_UNHANDLED_EXCEPTION(STRINGIZE("coroutine " << LLCoros::instance().getName()
+ CRASH_ON_UNHANDLED_EXCEPTION(STRINGIZE("coroutine " << LLCoros::getName()
<< "('" << uri << "', " << printable_params << ")"));
}
}