From 7aff5c6ff9f951a9a15c035845d57801889442fa Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 2 Nov 2010 16:28:56 -0500 Subject: Fix for crash when clicking "about land" and land has no owner or something. Reviewed by Nyx. --- indra/llui/lltextbase.cpp | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'indra') diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index d58e4808df..0f34cb927f 100644 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -2892,11 +2892,18 @@ bool LLImageTextSegment::getDimensions(S32 first_char, S32 num_chars, S32& width S32 LLImageTextSegment::getNumChars(S32 num_pixels, S32 segment_offset, S32 line_offset, S32 max_chars) const { LLUIImagePtr image = mStyle->getImage(); + + if (image.isNull()) + { + return 1; + } + S32 image_width = image->getWidth(); if(line_offset == 0 || num_pixels>image_width + IMAGE_HPAD) { return 1; } + return 0; } @@ -2906,18 +2913,21 @@ F32 LLImageTextSegment::draw(S32 start, S32 end, S32 selection_start, S32 select { LLColor4 color = LLColor4::white % mEditor.getDrawContext().mAlpha; LLUIImagePtr image = mStyle->getImage(); - S32 style_image_height = image->getHeight(); - S32 style_image_width = image->getWidth(); - // Text is drawn from the top of the draw_rect downward - - S32 text_center = draw_rect.mTop - (draw_rect.getHeight() / 2); - // Align image to center of draw rect - S32 image_bottom = text_center - (style_image_height / 2); - image->draw(draw_rect.mLeft, image_bottom, - style_image_width, style_image_height, color); - - const S32 IMAGE_HPAD = 3; - return draw_rect.mLeft + style_image_width + IMAGE_HPAD; + if (image.notNull()) + { + S32 style_image_height = image->getHeight(); + S32 style_image_width = image->getWidth(); + // Text is drawn from the top of the draw_rect downward + + S32 text_center = draw_rect.mTop - (draw_rect.getHeight() / 2); + // Align image to center of draw rect + S32 image_bottom = text_center - (style_image_height / 2); + image->draw(draw_rect.mLeft, image_bottom, + style_image_width, style_image_height, color); + + const S32 IMAGE_HPAD = 3; + return draw_rect.mLeft + style_image_width + IMAGE_HPAD; + } } return 0.0; } -- cgit v1.2.3 From 126c8e371c4c90f23e5f28475cb9e57871e7e7be Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 2 Nov 2010 16:30:46 -0500 Subject: Make sure mutex is locked before waiting on a signal. Reviewed by Nyx. --- indra/llcommon/llthread.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'indra') diff --git a/indra/llcommon/llthread.cpp b/indra/llcommon/llthread.cpp index 9a33324129..59e28948f5 100644 --- a/indra/llcommon/llthread.cpp +++ b/indra/llcommon/llthread.cpp @@ -406,6 +406,10 @@ LLCondition::~LLCondition() void LLCondition::wait() { + if (!isLocked()) + { //mAPRMutexp MUST be locked before calling apr_thread_cond_wait + apr_thread_mutex_lock(mAPRMutexp); + } apr_thread_cond_wait(mAPRCondp, mAPRMutexp); } -- cgit v1.2.3 From c98e6a99f93082ae9cb5c79f72e78ece59582de3 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Tue, 2 Nov 2010 16:32:29 -0500 Subject: Better locking of queues when displaying download queue status. Reviewed by Nyx. --- indra/newview/llviewerwindow.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'indra') diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index d7291c3688..bf712dea11 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -636,12 +636,15 @@ public: } } - S32 pending = (S32) gMeshRepo.mPendingRequests.size(); - S32 header = (S32) gMeshRepo.mThread->mHeaderReqQ.size(); - S32 lod = (S32) gMeshRepo.mThread->mLODReqQ.size(); - - if (pending + header + lod + LLMeshRepoThread::sActiveHeaderRequests + LLMeshRepoThread::sActiveLODRequests != 0) + if (!gMeshRepo.mPendingRequests.empty() || + !gMeshRepo.mThread->mHeaderReqQ.empty() || + !gMeshRepo.mThread->mLODReqQ.empty()) { + LLMutexLock lock(gMeshRepo.mThread->mMutex); + S32 pending = (S32) gMeshRepo.mPendingRequests.size(); + S32 header = (S32) gMeshRepo.mThread->mHeaderReqQ.size(); + S32 lod = (S32) gMeshRepo.mThread->mLODReqQ.size(); + addText(xpos, ypos, llformat ("Mesh Queue - %d pending (%d:%d header | %d:%d LOD)", pending, LLMeshRepoThread::sActiveHeaderRequests, header, -- cgit v1.2.3 From ce667514032510ff1ae47daf0f2727933be849bc Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Thu, 11 Nov 2010 11:22:35 -0600 Subject: Fix for crash in curl. --- indra/newview/llmeshrepository.cpp | 67 ++++++++++++++++++++++++++------------ indra/newview/lltexturefetch.cpp | 4 ++- 2 files changed, 49 insertions(+), 22 deletions(-) (limited to 'indra') 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 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) -- cgit v1.2.3 From ace36d042e0cd2443ddd07e0bd43d1086a81adcd Mon Sep 17 00:00:00 2001 From: "Nyx (Neal Orman)" Date: Fri, 12 Nov 2010 17:42:33 -0500 Subject: BUILDFIX allow curl host name scrub to work on non-windows platforms Needed an include for gethostbyname to be called properly. --- indra/newview/llmeshrepository.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra') diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 94ed2697c5..f00a8565f7 100644 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -59,6 +59,9 @@ #include "material_codes.h" #include "pipeline.h" +#ifndef LL_WINDOWS +#include "netdb.h" +#endif #include -- cgit v1.2.3