Start up crash of LLErrorThread due to corrupt map in CheckLevelMap

Wrapped gSettings and the global objects returned by Settings::get() and
Globals::get() in AIThreadSafe, forcing thread-safe access.

This solves the problem of possible corruption of the various LevelMap's
in LLError::Settings due to thread unsafe accesses.
This commit is contained in:
Aleric Inglewood
2011-05-05 15:41:19 +02:00
parent 86a19e8e91
commit 92696623e0
15 changed files with 261 additions and 215 deletions

View File

@@ -66,7 +66,20 @@ const S32 CURRENT_VERSION = 101;
//So, a global it is!
bool gCOAEnabled = false;
LLControlVariable *LLControlVariable::getCOAActive()
LLControlVariable* LLControlVariable::getCOAActive()
{
//if no coa connection, return 'this'
//if per account is ON and this IS a parent, return child var
//if per account is ON and this IS NOT a parent, return 'this'
//if per account is OFF and this IS NOT a parent, return parent var
//if per account is OFF and this IS a parent, return 'this'
if(getCOAConnection() && gCOAEnabled == isCOAParent())
return getCOAConnection();
else
return this;
}
LLControlVariable const* LLControlVariable::getCOAActive() const
{
//if no coa connection, return 'this'
//if per account is ON and this IS a parent, return child var
@@ -282,11 +295,9 @@ LLSD LLControlVariable::getSaveValue() const
#if PROF_CTRL_CALLS
std::vector<std::pair<std::string, U32>> gSettingsCallMap;
#endif //PROF_CTRL_CALLS
LLPointer<LLControlVariable> LLControlGroup::getControl(const std::string& name)
static update_gSettingsCallMap(ctrl_name_table_t::const_iterator const& iter)
{
ctrl_name_table_t::iterator iter = mNameTable.find(name);
#if PROF_CTRL_CALLS
if(iter != mNameTable.end())
{
std::vector<std::pair<std::string, U32>>::iterator iter2 = gSettingsCallMap.begin();
@@ -302,13 +313,32 @@ LLPointer<LLControlVariable> LLControlGroup::getControl(const std::string& name)
if(iter2 == gSettingsCallMap.end())
gSettingsCallMap.push_back(std::pair<std::string, U32>(name.c_str(),1));
}
}
#endif //PROF_CTRL_CALLS
LLControlVariable* LLControlGroup::getControl(std::string const& name)
{
ctrl_name_table_t::iterator iter = mNameTable.find(name);
#if PROF_CTRL_CALLS
update_gSettingsCallMap(iter);
#endif //PROF_CTRL_CALLS
if(iter != mNameTable.end())
return iter->second->getCOAActive();
else
return LLPointer<LLControlVariable>();
return NULL;
}
LLControlVariable const* LLControlGroup::getControl(std::string const& name) const
{
ctrl_name_table_t::const_iterator iter = mNameTable.find(name);
#if PROF_CTRL_CALLS
update_gSettingsCallMap(iter);
#endif //PROF_CTRL_CALLS
if(iter != mNameTable.end())
return iter->second->getCOAActive();
else
return NULL;
}
////////////////////////////////////////////////////////////////////////////
@@ -502,9 +532,9 @@ std::string LLControlGroup::findString(const std::string& name)
return LLStringUtil::null;
}
std::string LLControlGroup::getString(const std::string& name)
std::string LLControlGroup::getString(const std::string& name) const
{
LLControlVariable* control = getControl(name);
LLControlVariable const* control = getControl(name);
if (control && control->isType(TYPE_STRING))
return control->get().asString();
@@ -649,9 +679,9 @@ LLSD LLControlGroup::getLLSD(const std::string& name)
return LLSD();
}
BOOL LLControlGroup::controlExists(const std::string& name)
BOOL LLControlGroup::controlExists(const std::string& name) const
{
ctrl_name_table_t::iterator iter = mNameTable.find(name);
ctrl_name_table_t::const_iterator iter = mNameTable.find(name);
return iter != mNameTable.end();
}

View File

@@ -122,7 +122,7 @@ public:
const std::string& getComment() const { return mComment; }
eControlType type() { return mType; }
bool isType(eControlType tp) { return tp == mType; }
bool isType(eControlType tp) const { return tp == mType; }
void resetToDefault(bool fire_signal = false);
@@ -153,7 +153,8 @@ public:
bool isCOA() const { return mIsCOA; }
bool isCOAParent() const { return mIsCOAParent; }
LLControlVariable *getCOAConnection() const { return mCOAConnectedVar; }
LLControlVariable *getCOAActive();
LLControlVariable* getCOAActive();
LLControlVariable const* getCOAActive() const;
void setIsCOA(bool IsCOA) { mIsCOA=IsCOA; }
void setCOAConnect(LLControlVariable *pConnect, bool IsParent)
{
@@ -185,7 +186,8 @@ public:
~LLControlGroup();
void cleanup();
LLPointer<LLControlVariable> getControl(const std::string& name);
LLControlVariable* getControl(std::string const& name);
LLControlVariable const* getControl(std::string const& name) const;
struct ApplyFunctor
{
@@ -210,7 +212,7 @@ public:
std::string findString(const std::string& name);
std::string getString(const std::string& name);
std::string getString(const std::string& name) const;
LLWString getWString(const std::string& name);
std::string getText(const std::string& name);
LLVector3 getVector3(const std::string& name);
@@ -245,7 +247,7 @@ public:
void setValue(const std::string& name, const LLSD& val);
BOOL controlExists(const std::string& name);
BOOL controlExists(const std::string& name) const;
// Returns number of controls loaded, 0 if failed
// If require_declaration is false, will auto-declare controls it finds

View File

@@ -46,7 +46,7 @@ public:
LLControlGroupReader() {}
virtual ~LLControlGroupReader() {}
virtual std::string getString(const std::string& name) = 0;
virtual std::string getString(const std::string& name) const = 0;
//virtual LLWString getWString(const std::string& name) = 0;
virtual std::string getText(const std::string& name) = 0;
//virtual LLVector3 getVector3(const std::string& name) = 0;