diff options
-rw-r--r-- | indra/newview/llmeshrepository.cpp | 67 | ||||
-rw-r--r-- | indra/newview/lltexturefetch.cpp | 4 |
2 files changed, 49 insertions, 22 deletions
diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 1885b48812..94ed2697c5 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -103,16 +103,36 @@ U32 get_volume_memory_size(const LLVolume* volume) return indices*2+vertices*11+sizeof(LLVolume)+sizeof(LLVolumeFace)*volume->getNumVolumeFaces(); } -std::string scrub_host_name(std::string http_url, const LLHost& host) +std::string scrub_host_name(std::string http_url) { //curl loves to abuse the DNS cache, so scrub host names out of urls where trivial to prevent DNS timeouts - std::string ip_string = host.getIPString(); - std::string host_string = host.getHostName(); + + if (!http_url.empty()) + { + std::string::size_type begin_host = http_url.find("://")+3; + std::string host_string = http_url.substr(begin_host); - std::string::size_type idx = http_url.find(host_string); + std::string::size_type end_host = host_string.find(":"); + if (end_host == std::string::npos) + { + end_host = host_string.find("/"); + } - if (!ip_string.empty() && !host_string.empty() && idx != std::string::npos) - { - http_url.replace(idx, host_string.length(), ip_string); + host_string = host_string.substr(0, end_host); + + std::string::size_type idx = http_url.find(host_string); + + hostent* ent = gethostbyname(host_string.c_str()); + + if (ent && ent->h_length > 0) + { + U8* addr = (U8*) ent->h_addr_list[0]; + + std::string ip_string = llformat("%d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3]); + if (!ip_string.empty() && !host_string.empty() && idx != std::string::npos) + { + http_url.replace(idx, host_string.length(), ip_string); + } + } } return http_url; @@ -571,10 +591,8 @@ void LLMeshRepoThread::run() mPhysicsShapeRequests = incomplete; } - + mCurlRequest->process(); } - - mCurlRequest->process(); } res = LLConvexDecomposition::quitThread(); @@ -646,7 +664,6 @@ std::string LLMeshRepoThread::constructUrl(LLUUID mesh_id) if (gAgent.getRegion()) { http_url = gMeshRepo.mGetMeshCapability; - scrub_host_name(http_url, gAgent.getRegionHost()); } if (!http_url.empty()) @@ -1385,13 +1402,14 @@ LLMeshUploadThread::LLMeshUploadThread(LLMeshUploadThread::instance_list& data, mFinished = false; mOrigin = gAgent.getPositionAgent(); mHost = gAgent.getRegionHost(); + mUploadObjectAssetCapability = gAgent.getRegion()->getCapability("UploadObjectAsset"); mNewInventoryCapability = gAgent.getRegion()->getCapability("NewFileAgentInventoryVariablePrice"); + mUploadObjectAssetCapability = scrub_host_name(mUploadObjectAssetCapability); + mNewInventoryCapability = scrub_host_name(mNewInventoryCapability); + mOrigin += gAgent.getAtAxis() * scale.magVec(); - - scrub_host_name(mUploadObjectAssetCapability, mHost); - scrub_host_name(mNewInventoryCapability, mHost); } LLMeshUploadThread::~LLMeshUploadThread() @@ -1986,9 +2004,9 @@ void LLMeshHeaderResponder::completedRaw(U32 status, const std::string& reason, LLMeshRepoThread::sActiveHeaderRequests--; if (status < 200 || status > 400) { - llwarns - << "Header responder failed with status: " - << status << ": " << reason << llendl; + //llwarns + // << "Header responder failed with status: " + // << status << ": " << reason << llendl; // 503 (service unavailable) or 499 (timeout) // can be due to server load and can be retried @@ -2275,10 +2293,17 @@ void LLMeshRepository::notifyLoadedMeshes() return; } + static std::string region_name("never name a region this"); + if (gAgent.getRegion()) { //update capability url - //TODO: only do this when region changes - mGetMeshCapability = gAgent.getRegion()->getCapability("GetMesh"); + if (gAgent.getRegion()->getName() != region_name) + { + region_name = gAgent.getRegion()->getName(); + + mGetMeshCapability = gAgent.getRegion()->getCapability("GetMesh"); + mGetMeshCapability = scrub_host_name(mGetMeshCapability); + } } LLFastTimer t(FTM_MESH_UPDATE); @@ -2977,7 +3002,7 @@ void LLMeshUploadThread::priceResult(LLMeshUploadData& data, const LLSD& content { mPendingCost += content["upload_price"].asInteger(); data.mRSVP = content["rsvp"].asString(); - data.mRSVP = scrub_host_name(data.mRSVP, mHost); + data.mRSVP = scrub_host_name(data.mRSVP); mConfirmedQ.push(data); } @@ -2986,7 +3011,7 @@ void LLMeshUploadThread::priceResult(LLTextureUploadData& data, const LLSD& cont { mPendingCost += content["upload_price"].asInteger(); data.mRSVP = content["rsvp"].asString(); - data.mRSVP = scrub_host_name(data.mRSVP, mHost); + data.mRSVP = scrub_host_name(data.mRSVP); mConfirmedTextureQ.push(data); } diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index fafef84aa2..01ea6d9e15 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -51,6 +51,8 @@ #include "llviewerstats.h" #include "llworld.h" +std::string scrub_host_name(std::string http_url); + ////////////////////////////////////////////////////////////////////////////// class LLTextureFetchWorker : public LLWorkerClass { @@ -901,7 +903,7 @@ bool LLTextureFetchWorker::doWork(S32 param) // Will call callbackHttpGet when curl request completes std::vector<std::string> headers; headers.push_back("Accept: image/x-j2c"); - res = mFetcher->mCurlGetRequest->getByteRange(mUrl, headers, offset, mRequestedSize, + res = mFetcher->mCurlGetRequest->getByteRange(scrub_host_name(mUrl), headers, offset, mRequestedSize, new HTTPGetResponder(mFetcher, mID, LLTimer::getTotalTime(), mRequestedSize, offset, true)); } if (!res) |