summaryrefslogtreecommitdiff
path: root/indra/newview/llmeshrepository.cpp
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2010-11-11 11:22:35 -0600
committerDave Parks <davep@lindenlab.com>2010-11-11 11:22:35 -0600
commitce667514032510ff1ae47daf0f2727933be849bc (patch)
tree1d3e304dabc6a6981165f819036af9f4a57347ef /indra/newview/llmeshrepository.cpp
parentc98e6a99f93082ae9cb5c79f72e78ece59582de3 (diff)
Fix for crash in curl.
Diffstat (limited to 'indra/newview/llmeshrepository.cpp')
-rw-r--r--indra/newview/llmeshrepository.cpp67
1 files changed, 46 insertions, 21 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);
}