summaryrefslogtreecommitdiff
path: root/indra/llmessage
diff options
context:
space:
mode:
authorRye Mutt <rye@alchemyviewer.org>2024-07-21 20:10:21 -0400
committerRye Mutt <rye@alchemyviewer.org>2024-07-21 20:10:21 -0400
commit3013424057d8963bb55eca4bd58a91c21e4395fc (patch)
tree4733190fe1a9c7cfafcb36beca9fe0b61ef07e43 /indra/llmessage
parent7d2cd036ead5212f724aea706346e4dbe5386c09 (diff)
Fix rare shutdown crash in gCacheName
Diffstat (limited to 'indra/llmessage')
-rw-r--r--indra/llmessage/llcachename.cpp33
-rw-r--r--indra/llmessage/llcachename.h7
2 files changed, 20 insertions, 20 deletions
diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp
index 63ac46722a..64f660d0ce 100644
--- a/indra/llmessage/llcachename.cpp
+++ b/indra/llmessage/llcachename.cpp
@@ -53,7 +53,6 @@ const U32 PENDING_TIMEOUT_SECS = 5 * 60;
// Globals
LLCacheName* gCacheName = NULL;
-std::map<std::string, std::string> LLCacheName::sCacheName;
/// ---------------------------------------------------------------------------
/// class LLCacheNameEntry
@@ -215,7 +214,7 @@ public:
Impl(LLMessageSystem* msg);
~Impl();
- bool getName(const LLUUID& id, std::string& first, std::string& last);
+ bool getName(const LLUUID& id, std::string& first, std::string& last, std::map<std::string, std::string>& default_names);
boost::signals2::connection addPending(const LLUUID& id, const LLCacheNameCallback& callback);
void addPending(const LLUUID& id, const LLHost& host);
@@ -247,9 +246,9 @@ LLCacheName::LLCacheName(LLMessageSystem* msg)
LLCacheName::LLCacheName(LLMessageSystem* msg, const LLHost& upstream_host)
: impl(* new Impl(msg))
{
- sCacheName["waiting"] = "(Loading...)";
- sCacheName["nobody"] = "(nobody)";
- sCacheName["none"] = "(none)";
+ mCacheName["waiting"] = "(Loading...)";
+ mCacheName["nobody"] = "(nobody)";
+ mCacheName["none"] = "(none)";
setUpstream(upstream_host);
}
@@ -274,7 +273,7 @@ LLCacheName::Impl::Impl(LLMessageSystem* msg)
LLCacheName::Impl::~Impl()
{
- for_each(mCache.begin(), mCache.end(), DeletePairedPointer());
+ std::for_each(mCache.begin(), mCache.end(), DeletePairedPointer());
mCache.clear();
for_each(mReplyQueue.begin(), mReplyQueue.end(), DeletePointer());
mReplyQueue.clear();
@@ -402,11 +401,11 @@ void LLCacheName::exportFile(std::ostream& ostr)
}
-bool LLCacheName::Impl::getName(const LLUUID& id, std::string& first, std::string& last)
+bool LLCacheName::Impl::getName(const LLUUID& id, std::string& first, std::string& last, std::map<std::string, std::string>& default_names)
{
if(id.isNull())
{
- first = sCacheName["nobody"];
+ first = default_names["nobody"];
last.clear();
return true;
}
@@ -420,7 +419,7 @@ bool LLCacheName::Impl::getName(const LLUUID& id, std::string& first, std::strin
}
else
{
- first = sCacheName["waiting"];
+ first = default_names["waiting"];
last.clear();
if (!isRequestPending(id))
{
@@ -434,8 +433,8 @@ bool LLCacheName::Impl::getName(const LLUUID& id, std::string& first, std::strin
// static
void LLCacheName::localizeCacheName(std::string key, std::string value)
{
- if (key!="" && value!= "" )
- sCacheName[key]=value;
+ if (!key.empty() && !value.empty())
+ mCacheName[key]=value;
else
LL_WARNS()<< " Error localizing cache key " << key << " To "<< value<<LL_ENDL;
}
@@ -443,7 +442,7 @@ void LLCacheName::localizeCacheName(std::string key, std::string value)
bool LLCacheName::getFullName(const LLUUID& id, std::string& fullname)
{
std::string first_name, last_name;
- bool res = impl.getName(id, first_name, last_name);
+ bool res = impl.getName(id, first_name, last_name, mCacheName);
fullname = buildFullName(first_name, last_name);
return res;
}
@@ -454,7 +453,7 @@ bool LLCacheName::getGroupName(const LLUUID& id, std::string& group)
{
if(id.isNull())
{
- group = sCacheName["none"];
+ group = mCacheName["none"];
return true;
}
@@ -475,7 +474,7 @@ bool LLCacheName::getGroupName(const LLUUID& id, std::string& group)
}
else
{
- group = sCacheName["waiting"];
+ group = mCacheName["waiting"];
if (!impl.isRequestPending(id))
{
impl.mAskGroupQueue.insert(id);
@@ -614,7 +613,7 @@ boost::signals2::connection LLCacheName::get(const LLUUID& id, bool is_group, co
{
LLCacheNameSignal signal;
signal.connect(callback);
- signal(id, sCacheName["nobody"], is_group);
+ signal(id, mCacheName["nobody"], is_group);
return res;
}
@@ -754,14 +753,14 @@ void LLCacheName::dumpStats()
void LLCacheName::clear()
{
- for_each(impl.mCache.begin(), impl.mCache.end(), DeletePairedPointer());
+ std::for_each(impl.mCache.begin(), impl.mCache.end(), DeletePairedPointer());
impl.mCache.clear();
}
//static
std::string LLCacheName::getDefaultName()
{
- return sCacheName["waiting"];
+ return mCacheName["waiting"];
}
//static
diff --git a/indra/llmessage/llcachename.h b/indra/llmessage/llcachename.h
index 1df713c7c7..609387b6de 100644
--- a/indra/llmessage/llcachename.h
+++ b/indra/llmessage/llcachename.h
@@ -127,15 +127,16 @@ public:
void dumpStats(); // Dumps the sizes of the cache and associated queues.
void clear(); // Deletes all entries from the cache
- static std::string getDefaultName();
+ std::string getDefaultName();
// Returns "Resident", the default last name for SLID-based accounts
// that have no last name.
static std::string getDefaultLastName();
- static void localizeCacheName(std::string key, std::string value);
- static std::map<std::string, std::string> sCacheName;
+ void localizeCacheName(std::string key, std::string value);
+
private:
+ std::map<std::string, std::string> mCacheName;
class Impl;
Impl& impl;