From 62527e6f18f0a035a234cf584e31f7eea93fd4a7 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed <nat@lindenlab.com> Date: Tue, 18 Aug 2015 17:05:29 -0400 Subject: [PATCH] MAINT-5506: Fix ugly timing bug in llurlentry static initialization. The problem was that class-static LLUrlEntryParcel::sRegionHost was being initialized by copying class-static LLHost::invalid. Naturally, these two statics are initialized in different source files. Since C++ makes no promises about the relative order in which objects in different object files are initialized, it seems we hit a case in which we were trying to initialize sRegionHost by copying a completely uninitialized LLHost::invalid. In general we might attempt to address such cross-translation-unit issues by introducing an LLSingleton. But in this particular case, the punch line is that LLHost::invalid is explicitly constructed identically to a default-constructed LLHost! In other words, LLHost::invalid provides nothing we couldn't get from LLHost(). All it gives us is an opportunity for glitches such as the above. Remove LLHost::invalid and all references, replacing with LLHost(). --- indra/llmessage/llassetstorage.cpp | 2 +- indra/llmessage/llcachename.cpp | 2 +- indra/llmessage/llhost.cpp | 2 -- indra/llmessage/llhost.h | 2 -- indra/llmessage/message.cpp | 2 +- indra/llui/llurlentry.cpp | 4 ++-- indra/llui/tests/llurlentry_stub.cpp | 2 -- indra/newview/llagent.cpp | 2 +- indra/newview/llfloatergodtools.cpp | 6 +++--- indra/newview/llpreviewnotecard.cpp | 2 +- indra/newview/llpreviewscript.cpp | 2 +- indra/newview/lltexturefetch.cpp | 8 ++++---- indra/newview/llviewerobject.cpp | 6 +++--- indra/newview/llviewertexture.h | 6 +++--- indra/newview/llviewertexturelist.cpp | 2 +- indra/newview/llvoavatar.cpp | 2 +- 16 files changed, 23 insertions(+), 29 deletions(-) diff --git a/indra/llmessage/llassetstorage.cpp b/indra/llmessage/llassetstorage.cpp index 8ba2535531e..a6edafecf8e 100755 --- a/indra/llmessage/llassetstorage.cpp +++ b/indra/llmessage/llassetstorage.cpp @@ -290,7 +290,7 @@ LLAssetStorage::LLAssetStorage(LLMessageSystem *msg, LLXferManager *xfer, LLVFS LLAssetStorage::LLAssetStorage(LLMessageSystem *msg, LLXferManager *xfer, LLVFS *vfs, LLVFS *static_vfs) { - _init(msg, xfer, vfs, static_vfs, LLHost::invalid); + _init(msg, xfer, vfs, static_vfs, LLHost()); } diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp index daf3e0b4ded..66bd85f4e6a 100755 --- a/indra/llmessage/llcachename.cpp +++ b/indra/llmessage/llcachename.cpp @@ -259,7 +259,7 @@ LLCacheName::~LLCacheName() } LLCacheName::Impl::Impl(LLMessageSystem* msg) - : mMsg(msg), mUpstreamHost(LLHost::invalid) + : mMsg(msg), mUpstreamHost(LLHost()) { mMsg->setHandlerFuncFast( _PREHASH_UUIDNameRequest, handleUUIDNameRequest, (void**)this); diff --git a/indra/llmessage/llhost.cpp b/indra/llmessage/llhost.cpp index 63c15f0d5ee..ae5c2ecf698 100755 --- a/indra/llmessage/llhost.cpp +++ b/indra/llmessage/llhost.cpp @@ -41,8 +41,6 @@ #include <arpa/inet.h> #endif -LLHost LLHost::invalid(INVALID_PORT,INVALID_HOST_IP_ADDRESS); - LLHost::LLHost(const std::string& ip_and_port) { std::string::size_type colon_index = ip_and_port.find(":"); diff --git a/indra/llmessage/llhost.h b/indra/llmessage/llhost.h index 9a221e2a6e2..376371cffd4 100755 --- a/indra/llmessage/llhost.h +++ b/indra/llmessage/llhost.h @@ -42,8 +42,6 @@ class LLHost { U32 mIP; std::string mUntrustedSimCap; public: - - static LLHost invalid; // CREATORS LLHost() diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp index feb756a0c7c..67121714181 100755 --- a/indra/llmessage/message.cpp +++ b/indra/llmessage/message.cpp @@ -1675,7 +1675,7 @@ LLHost LLMessageSystem::findHost(const U32 circuit_code) } else { - return LLHost::invalid; + return LLHost(); } } diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp index 6db0d88998f..adefae6e2d6 100755 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -957,7 +957,7 @@ std::string LLUrlEntryObjectIM::getLocation(const std::string &url) const // LLUrlEntryParcel statics. LLUUID LLUrlEntryParcel::sAgentID(LLUUID::null); LLUUID LLUrlEntryParcel::sSessionID(LLUUID::null); -LLHost LLUrlEntryParcel::sRegionHost(LLHost::invalid); +LLHost LLUrlEntryParcel::sRegionHost; bool LLUrlEntryParcel::sDisconnected(false); std::set<LLUrlEntryParcel*> LLUrlEntryParcel::sParcelInfoObservers; @@ -1006,7 +1006,7 @@ std::string LLUrlEntryParcel::getLabel(const std::string &url, const LLUrlLabelC void LLUrlEntryParcel::sendParcelInfoRequest(const LLUUID& parcel_id) { - if (sRegionHost == LLHost::invalid || sDisconnected) return; + if (sRegionHost == LLHost() || sDisconnected) return; LLMessageSystem *msg = gMessageSystem; msg->newMessage("ParcelInfoRequest"); diff --git a/indra/llui/tests/llurlentry_stub.cpp b/indra/llui/tests/llurlentry_stub.cpp index 5d3f9ac327b..f01178c374c 100755 --- a/indra/llui/tests/llurlentry_stub.cpp +++ b/indra/llui/tests/llurlentry_stub.cpp @@ -165,8 +165,6 @@ LLFontGL* LLFontGL::getFontDefault() char const* const _PREHASH_AgentData = (char *)"AgentData"; char const* const _PREHASH_AgentID = (char *)"AgentID"; -LLHost LLHost::invalid(INVALID_PORT,INVALID_HOST_IP_ADDRESS); - LLMessageSystem* gMessageSystem = NULL; // diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 7147769c43c..e7dd378edd0 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -930,7 +930,7 @@ LLHost LLAgent::getRegionHost() const } else { - return LLHost::invalid; + return LLHost(); } } diff --git a/indra/newview/llfloatergodtools.cpp b/indra/newview/llfloatergodtools.cpp index 37774fbc5c7..adc7f715866 100755 --- a/indra/newview/llfloatergodtools.cpp +++ b/indra/newview/llfloatergodtools.cpp @@ -115,7 +115,7 @@ void LLFloaterGodTools::refreshAll() LLFloaterGodTools::LLFloaterGodTools(const LLSD& key) : LLFloater(key), - mCurrentHost(LLHost::invalid), + mCurrentHost(LLHost()), mUpdateTimer() { mFactoryMap["grid"] = LLCallbackMap(createPanelGrid, this); @@ -180,7 +180,7 @@ void LLFloaterGodTools::updatePopup(LLCoordGL center, MASK mask) // virtual void LLFloaterGodTools::draw() { - if (mCurrentHost == LLHost::invalid) + if (mCurrentHost == LLHost()) { if (mUpdateTimer.getElapsedTimeF32() > SECONDS_BETWEEN_UPDATE_REQUESTS) { @@ -325,7 +325,7 @@ void LLFloaterGodTools::sendRegionInfoRequest() { if (mPanelRegionTools) mPanelRegionTools->clearAllWidgets(); if (mPanelObjectTools) mPanelObjectTools->clearAllWidgets(); - mCurrentHost = LLHost::invalid; + mCurrentHost = LLHost(); mUpdateTimer.reset(); LLMessageSystem* msg = gMessageSystem; diff --git a/indra/newview/llpreviewnotecard.cpp b/indra/newview/llpreviewnotecard.cpp index 2c609d902c4..308b6ee9226 100755 --- a/indra/newview/llpreviewnotecard.cpp +++ b/indra/newview/llpreviewnotecard.cpp @@ -232,7 +232,7 @@ void LLPreviewNotecard::loadAsset() } else { - LLHost source_sim = LLHost::invalid; + LLHost source_sim = LLHost(); if (mObjectUUID.notNull()) { LLViewerObject *objectp = gObjectList.findObject(mObjectUUID); diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 11a503e71fa..b6210bdc6b3 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -1571,7 +1571,7 @@ void LLPreviewLSL::loadAsset() if (gAgent.isGodlike() || (is_copyable && (is_modifiable || is_library))) { LLUUID* new_uuid = new LLUUID(mItemUUID); - gAssetStorage->getInvItemAsset(LLHost::invalid, + gAssetStorage->getInvItemAsset(LLHost(), gAgent.getID(), gAgent.getSessionID(), item->getPermissions().getOwner(), diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index e61eeb2f4e2..6674532efae 100755 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -1328,11 +1328,11 @@ bool LLTextureFetchWorker::doWork(S32 param) static LLCachedControl<bool> use_http(gSavedSettings, "ImagePipelineUseHTTP", true); -// if (mHost != LLHost::invalid) get_url = false; +// if (mHost != LLHost()) get_url = false; if ( use_http && mCanUseHTTP && mUrl.empty())//get http url. { LLViewerRegion* region = NULL; - if (mHost == LLHost::invalid) + if (mHost == LLHost()) region = gAgent.getRegion(); else region = LLWorld::getInstance()->getRegion(mHost); @@ -3224,7 +3224,7 @@ void LLTextureFetch::sendRequestListToSimulators() { LLHost host = iter1->first; // invalid host = use agent host - if (host == LLHost::invalid) + if (host == LLHost()) { host = gAgent.getRegionHost(); } @@ -3304,7 +3304,7 @@ void LLTextureFetch::sendRequestListToSimulators() iter1 != mCancelQueue.end(); ++iter1) { LLHost host = iter1->first; - if (host == LLHost::invalid) + if (host == LLHost()) { host = gAgent.getRegionHost(); } diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp index ac3f07fcd8a..190102ff0fb 100755 --- a/indra/newview/llviewerobject.cpp +++ b/indra/newview/llviewerobject.cpp @@ -4437,21 +4437,21 @@ S32 LLViewerObject::setTETexture(const U8 te, const LLUUID& uuid) { // Invalid host == get from the agent's sim LLViewerFetchedTexture *image = LLViewerTextureManager::getFetchedTexture( - uuid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE, 0, 0, LLHost::invalid); + uuid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE, 0, 0, LLHost()); return setTETextureCore(te,image); } S32 LLViewerObject::setTENormalMap(const U8 te, const LLUUID& uuid) { LLViewerFetchedTexture *image = (uuid == LLUUID::null) ? NULL : LLViewerTextureManager::getFetchedTexture( - uuid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE, 0, 0, LLHost::invalid); + uuid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE, 0, 0, LLHost()); return setTENormalMapCore(te, image); } S32 LLViewerObject::setTESpecularMap(const U8 te, const LLUUID& uuid) { LLViewerFetchedTexture *image = (uuid == LLUUID::null) ? NULL : LLViewerTextureManager::getFetchedTexture( - uuid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE, 0, 0, LLHost::invalid); + uuid, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE, 0, 0, LLHost()); return setTESpecularMapCore(te, image); } diff --git a/indra/newview/llviewertexture.h b/indra/newview/llviewertexture.h index aed7e949453..e496cb9f786 100755 --- a/indra/newview/llviewertexture.h +++ b/indra/newview/llviewertexture.h @@ -266,7 +266,7 @@ class LLViewerFetchedTexture : public LLViewerTexture protected: /*virtual*/ ~LLViewerFetchedTexture(); public: - LLViewerFetchedTexture(const LLUUID& id, FTType f_type, const LLHost& host = LLHost::invalid, BOOL usemipmaps = TRUE); + LLViewerFetchedTexture(const LLUUID& id, FTType f_type, const LLHost& host = LLHost(), BOOL usemipmaps = TRUE); LLViewerFetchedTexture(const LLImageRaw* raw, FTType f_type, BOOL usemipmaps); LLViewerFetchedTexture(const std::string& url, FTType f_type, const LLUUID& id, BOOL usemipmaps = TRUE); @@ -498,7 +498,7 @@ class LLViewerFetchedTexture : public LLViewerTexture S32 mCachedRawDiscardLevel; BOOL mCachedRawImageReady; //the rez of the mCachedRawImage reaches the upper limit. - LLHost mTargetHost; // if LLHost::invalid, just request from agent's simulator + LLHost mTargetHost; // if invalid, just request from agent's simulator // Timers LLFrameTimer mLastPacketTimer; // Time since last packet. @@ -528,7 +528,7 @@ class LLViewerLODTexture : public LLViewerFetchedTexture /*virtual*/ ~LLViewerLODTexture(){} public: - LLViewerLODTexture(const LLUUID& id, FTType f_type, const LLHost& host = LLHost::invalid, BOOL usemipmaps = TRUE); + LLViewerLODTexture(const LLUUID& id, FTType f_type, const LLHost& host = LLHost(), BOOL usemipmaps = TRUE); LLViewerLODTexture(const std::string& url, FTType f_type, const LLUUID& id, BOOL usemipmaps = TRUE); /*virtual*/ S8 getType() const; diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp index 926c40307b3..0232dcfa15f 100755 --- a/indra/newview/llviewertexturelist.cpp +++ b/indra/newview/llviewertexturelist.cpp @@ -236,7 +236,7 @@ void LLViewerTextureList::shutdown() if (!image->hasGLTexture() || !image->getUseDiscard() || image->needsAux() || - image->getTargetHost() != LLHost::invalid || + image->getTargetHost() != LLHost() || !image->getUrl().empty() ) { diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index f7534487701..db949437a72 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -8095,7 +8095,7 @@ LLHost LLVOAvatar::getObjectHost() const } else { - return LLHost::invalid; + return LLHost(); } } -- GitLab