summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorRye Mutt <rye@alchemyviewer.org>2024-07-21 20:10:21 -0400
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2024-08-09 22:55:08 +0300
commit9e4185bf75edbbf313735be56b1aaefcf0d31299 (patch)
tree0a2da1e123f4e4c4c8d03b72a0511c1b1201b875 /indra
parentfe76026a3fea79522083864019026e6bf01777df (diff)
Fix rare shutdown crash in gCacheName
Diffstat (limited to 'indra')
-rw-r--r--indra/llmessage/llcachename.cpp33
-rw-r--r--indra/llmessage/llcachename.h7
-rw-r--r--indra/newview/llfloateravatarpicker.cpp2
-rw-r--r--indra/newview/llinventorybridge.cpp2
4 files changed, 22 insertions, 22 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;
diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp
index 6087e6c0ee..08a54b7369 100644
--- a/indra/newview/llfloateravatarpicker.cpp
+++ b/indra/newview/llfloateravatarpicker.cpp
@@ -300,7 +300,7 @@ void LLFloaterAvatarPicker::populateNearMe()
if (!LLAvatarNameCache::get(av, &av_name))
{
element["columns"][0]["column"] = "name";
- element["columns"][0]["value"] = LLCacheName::getDefaultName();
+ element["columns"][0]["value"] = gCacheName->getDefaultName();
all_loaded = false;
}
else
diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 33d0ac891d..bfa8e39b70 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -6289,7 +6289,7 @@ void LLCallingCardBridge::performAction(LLInventoryModel* model, std::string act
if (item && (item->getCreatorUUID() != gAgent.getID()) &&
(!item->getCreatorUUID().isNull()))
{
- std::string callingcard_name = LLCacheName::getDefaultName();
+ std::string callingcard_name = gCacheName->getDefaultName();
LLAvatarName av_name;
if (LLAvatarNameCache::get(item->getCreatorUUID(), &av_name))
{