summaryrefslogtreecommitdiff
path: root/indra/llcommon/llerror.cpp
diff options
context:
space:
mode:
authorCallum Prentice <callum@gmail.com>2020-11-11 13:22:35 -0800
committerCallum Prentice <callum@gmail.com>2020-11-11 13:22:35 -0800
commit9b1d9150c23ac378623e6222c742753d6dc39070 (patch)
tree7b28475acf539006c3d674decd36cfeb72aba992 /indra/llcommon/llerror.cpp
parent727b89e94cc5125c62b0eaebe304ba613f38225a (diff)
parent04c473ab46041133ea6a87dbe0d43e662472adf5 (diff)
Merge branch 'master' into DRTVWR-519
Diffstat (limited to 'indra/llcommon/llerror.cpp')
-rw-r--r--indra/llcommon/llerror.cpp84
1 files changed, 38 insertions, 46 deletions
diff --git a/indra/llcommon/llerror.cpp b/indra/llcommon/llerror.cpp
index 832813ba3f..6e8b9efaf7 100644
--- a/indra/llcommon/llerror.cpp
+++ b/indra/llcommon/llerror.cpp
@@ -373,12 +373,9 @@ namespace LLError
}
// huh, that's odd, we should see one or the other prefix -- but don't
// try to log unless logging is already initialized
- if (is_available())
- {
- // in Python, " or ".join(vector) -- but in C++, a PITB
- LL_DEBUGS() << "Did not see 'class' or 'struct' prefix on '"
- << name << "'" << LL_ENDL;
- }
+ // in Python, " or ".join(vector) -- but in C++, a PITB
+ LL_DEBUGS() << "Did not see 'class' or 'struct' prefix on '"
+ << name << "'" << LL_ENDL;
return name;
#else // neither GCC nor Visual Studio
@@ -479,9 +476,12 @@ namespace
typedef std::vector<LLError::RecorderPtr> Recorders;
typedef std::vector<LLError::CallSite*> CallSiteVector;
- class Globals : public LLSingleton<Globals>
+ class Globals
{
- LLSINGLETON(Globals);
+ public:
+ static Globals* getInstance();
+ protected:
+ Globals();
public:
std::ostringstream messageStream;
bool messageStreamInUse;
@@ -501,6 +501,16 @@ namespace
{
}
+ Globals* Globals::getInstance()
+ {
+ // According to C++11 Function-Local Initialization
+ // of static variables is supposed to be thread safe
+ // without risk of deadlocks.
+ static Globals inst;
+
+ return &inst;
+ }
+
void Globals::addCallSite(LLError::CallSite& site)
{
callSites.push_back(&site);
@@ -553,14 +563,17 @@ namespace LLError
typedef LLPointer<SettingsConfig> SettingsConfigPtr;
- class Settings : public LLSingleton<Settings>
+ class Settings
{
- LLSINGLETON(Settings);
+ public:
+ static Settings* getInstance();
+ protected:
+ Settings();
public:
SettingsConfigPtr getSettingsConfig();
void reset();
- SettingsStoragePtr saveAndReset();
+ SettingsStoragePtr saveAndReset();
void restore(SettingsStoragePtr pSettingsStorage);
private:
@@ -594,6 +607,16 @@ namespace LLError
{
}
+ Settings* Settings::getInstance()
+ {
+ // According to C++11 Function-Local Initialization
+ // of static variables is supposed to be thread safe
+ // without risk of deadlocks.
+ static Settings inst;
+
+ return &inst;
+ }
+
SettingsConfigPtr Settings::getSettingsConfig()
{
return mSettingsConfig;
@@ -618,11 +641,6 @@ namespace LLError
SettingsConfigPtr newSettingsConfig(dynamic_cast<SettingsConfig *>(pSettingsStorage.get()));
mSettingsConfig = newSettingsConfig;
}
-
- bool is_available()
- {
- return Settings::instanceExists() && Globals::instanceExists();
- }
}
namespace LLError
@@ -1069,7 +1087,7 @@ namespace LLError
std::pair<boost::shared_ptr<RECORDER>, Recorders::iterator>
findRecorderPos()
{
- SettingsConfigPtr s = Settings::instance().getSettingsConfig();
+ SettingsConfigPtr s = Settings::getInstance()->getSettingsConfig();
// Since we promise to return an iterator, use a classic iterator
// loop.
auto end{s->mRecorders.end()};
@@ -1112,7 +1130,7 @@ namespace LLError
auto found = findRecorderPos<RECORDER>();
if (found.first)
{
- SettingsConfigPtr s = Settings::instance().getSettingsConfig();
+ SettingsConfigPtr s = Settings::getInstance()->getSettingsConfig();
s->mRecorders.erase(found.second);
}
return bool(found.first);
@@ -1348,14 +1366,6 @@ namespace LLError
return false;
}
- // If we hit a logging request very late during shutdown processing,
- // when either of the relevant LLSingletons has already been deleted,
- // DO NOT resurrect them.
- if (Settings::wasDeleted() || Globals::wasDeleted())
- {
- return false;
- }
-
SettingsConfigPtr s = Settings::getInstance()->getSettingsConfig();
s->mShouldLogCallCounter++;
@@ -1394,10 +1404,8 @@ namespace LLError
std::ostringstream* Log::out()
{
LLMutexTrylock lock(getMutex<LOG_MUTEX>(),5);
- // If we hit a logging request very late during shutdown processing,
- // when either of the relevant LLSingletons has already been deleted,
- // DO NOT resurrect them.
- if (lock.isLocked() && ! (Settings::wasDeleted() || Globals::wasDeleted()))
+
+ if (lock.isLocked())
{
Globals* g = Globals::getInstance();
@@ -1419,14 +1427,6 @@ namespace LLError
return;
}
- // If we hit a logging request very late during shutdown processing,
- // when either of the relevant LLSingletons has already been deleted,
- // DO NOT resurrect them.
- if (Settings::wasDeleted() || Globals::wasDeleted())
- {
- return;
- }
-
if(strlen(out->str().c_str()) < 128)
{
strcpy(message, out->str().c_str());
@@ -1459,14 +1459,6 @@ namespace LLError
return;
}
- // If we hit a logging request very late during shutdown processing,
- // when either of the relevant LLSingletons has already been deleted,
- // DO NOT resurrect them.
- if (Settings::wasDeleted() || Globals::wasDeleted())
- {
- return;
- }
-
Globals* g = Globals::getInstance();
SettingsConfigPtr s = Settings::getInstance()->getSettingsConfig();