From efd19dddd93117688afe7de24c890c5a4b30bada Mon Sep 17 00:00:00 2001 From: Merov Linden Date: Wed, 2 May 2012 10:37:51 -0700 Subject: SH-3126 : Improve curl byte range call, test implementation in lltexturefetch (not final) --- indra/llmessage/llcurl.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp index 4d92cfd32f..095d8cd28b 100644 --- a/indra/llmessage/llcurl.cpp +++ b/indra/llmessage/llcurl.cpp @@ -1074,7 +1074,9 @@ void LLCurlRequest::get(const std::string& url, LLCurl::ResponderPtr responder) { getByteRange(url, headers_t(), 0, -1, responder); } - + +// Note: (length==0) is interpreted as "the rest of the file", i.e. the whole file if (offset==0) or +// the remainder of the file if not. bool LLCurlRequest::getByteRange(const std::string& url, const headers_t& headers, S32 offset, S32 length, @@ -1092,6 +1094,11 @@ bool LLCurlRequest::getByteRange(const std::string& url, std::string range = llformat("Range: bytes=%d-%d", offset,offset+length-1); easy->slist_append(range.c_str()); } + else if (offset > 0) + { + std::string range = llformat("Range: bytes=%d-", offset); + easy->slist_append(range.c_str()); + } easy->setHeaders(); bool res = addEasy(easy); return res; -- cgit v1.2.3 From 30140f66be90b78006b29b7f3740ddc473a0ac96 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Thu, 3 May 2012 17:25:02 -0400 Subject: SH-3079 FIX - minimize retries and avoid log spam when people API is missing --- indra/llmessage/llavatarnamecache.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 97f2792686..fbc3cc6de2 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -87,6 +87,9 @@ namespace LLAvatarNameCache /// Time when unrefreshed cached names were checked last static F64 sLastExpireCheck; + /// Time-to-live for a temp cache entry. + const F64 TEMP_CACHE_ENTRY_LIFETIME = 60.0; + //----------------------------------------------------------------------- // Internal methods //----------------------------------------------------------------------- @@ -274,7 +277,7 @@ void LLAvatarNameCache::handleAgentError(const LLUUID& agent_id) { // there is no existing cache entry, so make a temporary name from legacy LL_WARNS("AvNameCache") << "LLAvatarNameCache get legacy for agent " - << agent_id << LL_ENDL; + << agent_id << LL_ENDL; gCacheName->get(agent_id, false, // legacy compatibility boost::bind(&LLAvatarNameCache::legacyNameCallback, _1, _2, _3)); @@ -287,13 +290,14 @@ void LLAvatarNameCache::handleAgentError(const LLUUID& agent_id) // Clear this agent from the pending list LLAvatarNameCache::sPendingQueue.erase(agent_id); - const LLAvatarName& av_name = existing->second; + LLAvatarName& av_name = existing->second; LL_DEBUGS("AvNameCache") << "LLAvatarNameCache use cache for agent " << agent_id << "user '" << av_name.mUsername << "' " << "display '" << av_name.mDisplayName << "' " << "expires in " << av_name.mExpires - LLFrameTimer::getTotalSeconds() << " seconds" << LL_ENDL; + av_name.mExpires = LLFrameTimer::getTotalSeconds() + TEMP_CACHE_ENTRY_LIFETIME; // reset expiry time so we don't constantly rerequest. } } @@ -402,10 +406,12 @@ void LLAvatarNameCache::legacyNameCallback(const LLUUID& agent_id, << LL_ENDL; buildLegacyName(full_name, &av_name); - // Don't add to cache, the data already exists in the legacy name system - // cache and we don't want or need duplicate storage, because keeping the - // two copies in sync is complex. - processName(agent_id, av_name, false); + // Add to cache, because if we don't we'll keep rerequesting the + // same record forever. buildLegacyName should always guarantee + // that these records expire reasonably soon + // (in TEMP_CACHE_ENTRY_LIFETIME seconds), so if the failure was due + // to something temporary we will eventually request and get the right data. + processName(agent_id, av_name, true); } void LLAvatarNameCache::requestNamesViaLegacy() @@ -583,7 +589,7 @@ void LLAvatarNameCache::buildLegacyName(const std::string& full_name, av_name->mDisplayName = full_name; av_name->mIsDisplayNameDefault = true; av_name->mIsTemporaryName = true; - av_name->mExpires = F64_MAX; // not used because these are not cached + av_name->mExpires = LLFrameTimer::getTotalSeconds() + TEMP_CACHE_ENTRY_LIFETIME; LL_DEBUGS("AvNameCache") << "LLAvatarNameCache::buildLegacyName " << full_name << LL_ENDL; -- cgit v1.2.3 From e37917b66856d8737eae378c2017c3525f756b4d Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Thu, 24 May 2012 14:32:14 -0600 Subject: fix for VWR-28996: Texture stalls and threading models --- indra/llmessage/llcurl.cpp | 168 ++++++++++++++++++++++++++++++++++++++++++++- indra/llmessage/llcurl.h | 61 ++++++++++++++++ 2 files changed, 227 insertions(+), 2 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp index f153c94911..c06cf2489d 100644 --- a/indra/llmessage/llcurl.cpp +++ b/indra/llmessage/llcurl.cpp @@ -911,8 +911,8 @@ bool LLCurlThread::CurlRequest::processRequest() if(!completed) { - setPriority(LLQueuedThread::PRIORITY_LOW) ; - } + setPriority(LLQueuedThread::PRIORITY_LOW) ; + } } return completed ; @@ -1224,6 +1224,170 @@ S32 LLCurlRequest::getQueued() return queued; } +LLCurlTextureRequest::LLCurlTextureRequest(S32 concurrency) : + LLCurlRequest(), + mConcurrency(concurrency), + mInQueue(0), + mMutex(NULL), + mHandleCounter(1), + mTotalIssuedRequests(0), + mTotalReceivedBits(0) +{ +} + +LLCurlTextureRequest::~LLCurlTextureRequest() +{ + mRequestMap.clear(); + + for(req_queue_t::iterator iter = mCachedRequests.begin(); iter != mCachedRequests.end(); ++iter) + { + delete *iter; + } + mCachedRequests.clear(); +} + +//return 0: success +// > 0: cached handle +U32 LLCurlTextureRequest::getByteRange(const std::string& url, + const headers_t& headers, + S32 offset, S32 length, U32 pri, + LLCurl::ResponderPtr responder) +{ + U32 ret_val = 0; + bool success = false; + + if(mInQueue < mConcurrency) + { + success = LLCurlRequest::getByteRange(url, headers, offset, length, responder); + } + + LLMutexLock lock(&mMutex); + + if(success) + { + mInQueue++; + mTotalIssuedRequests++; + } + else + { + request_t* request = new request_t(mHandleCounter, url, headers, offset, length, pri, responder); + mCachedRequests.insert(request); + mRequestMap[mHandleCounter] = request; + ret_val = mHandleCounter; + mHandleCounter++; + + if(!mHandleCounter) + { + mHandleCounter = 1; + } + } + + return ret_val; +} + +void LLCurlTextureRequest::completeRequest(S32 received_bytes) +{ + LLMutexLock lock(&mMutex); + + llassert_always(mInQueue > 0); + + mInQueue--; + mTotalReceivedBits += received_bytes * 8; +} + +void LLCurlTextureRequest::nextRequests() +{ + while(!mCachedRequests.empty() && mInQueue < mConcurrency) + { + request_t* request; + + { + LLMutexLock lock(&mMutex); + req_queue_t::iterator iter = mCachedRequests.begin(); + request = *iter; + } + + if(!LLCurlRequest::getByteRange(request->mUrl, request->mHeaders, request->mOffset, request->mLength, request->mResponder)) + { + break; + } + + { + LLMutexLock lock(&mMutex); + mInQueue++; + mTotalIssuedRequests++; + llassert_always(1 == mCachedRequests.erase(request)); + mRequestMap.erase(request->mHandle); + } + delete request; + } + + return; +} + +void LLCurlTextureRequest::updatePriority(U32 handle, U32 pri) +{ + if(!handle) + { + return; + } + + LLMutexLock lock(&mMutex); + + std::map::iterator iter = mRequestMap.find(handle); + if(iter != mRequestMap.end()) + { + request_t* req = iter->second; + + if(req->mPriority != pri) + { + mCachedRequests.erase(req); + req->mPriority = pri; + mCachedRequests.insert(req); + } + } +} + +void LLCurlTextureRequest::removeRequest(U32 handle) +{ + if(!handle) + { + return; + } + + LLMutexLock lock(&mMutex); + + std::map::iterator iter = mRequestMap.find(handle); + if(iter != mRequestMap.end()) + { + request_t* req = iter->second; + mRequestMap.erase(iter); + mCachedRequests.erase(req); + delete req; + } +} + +U32 LLCurlTextureRequest::getTotalReceivedBits() +{ + LLMutexLock lock(&mMutex); + + U32 bits = mTotalReceivedBits; + mTotalReceivedBits = 0; + return bits; +} + +U32 LLCurlTextureRequest::getTotalIssuedRequests() +{ + LLMutexLock lock(&mMutex); + return mTotalIssuedRequests; +} + +S32 LLCurlTextureRequest::getNumRequests() +{ + LLMutexLock lock(&mMutex); + return mInQueue; +} + //////////////////////////////////////////////////////////////////////////// // For generating one easy request // associated with a single multi request diff --git a/indra/llmessage/llcurl.h b/indra/llmessage/llcurl.h index fd664c0fa1..04a2bd4287 100644 --- a/indra/llmessage/llcurl.h +++ b/indra/llmessage/llcurl.h @@ -413,6 +413,67 @@ private: BOOL mProcessing; }; +//for texture fetch only +class LLCurlTextureRequest : public LLCurlRequest +{ +public: + LLCurlTextureRequest(S32 concurrency); + ~LLCurlTextureRequest(); + + U32 getByteRange(const std::string& url, const headers_t& headers, S32 offset, S32 length, U32 pri, LLCurl::ResponderPtr responder); + void nextRequests(); + void completeRequest(S32 received_bytes); + + void updatePriority(U32 handle, U32 pri); + void removeRequest(U32 handle); + + U32 getTotalReceivedBits(); + U32 getTotalIssuedRequests(); + S32 getNumRequests(); + +private: + LLMutex mMutex; + S32 mConcurrency; + S32 mInQueue; //request currently in queue. + U32 mHandleCounter; + U32 mTotalIssuedRequests; + U32 mTotalReceivedBits; + + typedef struct _request_t + { + _request_t(U32 handle, const std::string& url, const headers_t& headers, S32 offset, S32 length, U32 pri, LLCurl::ResponderPtr responder) : + mHandle(handle), mUrl(url), mHeaders(headers), mOffset(offset), mLength(length), mPriority(pri), mResponder(responder) + {} + + U32 mHandle; + std::string mUrl; + LLCurlRequest::headers_t mHeaders; + S32 mOffset; + S32 mLength; + LLCurl::ResponderPtr mResponder; + U32 mPriority; + } request_t; + + struct request_compare + { + bool operator()(const request_t* lhs, const request_t* rhs) const + { + if(lhs->mPriority != rhs->mPriority) + { + return lhs->mPriority > rhs->mPriority; // higher priority in front of queue (set) + } + else + { + return (U32)lhs < (U32)rhs; + } + } + }; + + typedef std::set req_queue_t; + req_queue_t mCachedRequests; + std::map mRequestMap; +}; + class LLCurlEasyRequest { public: -- cgit v1.2.3 From cbb14e223c4db312191d0fe0b12362298fbf9fbd Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Fri, 25 May 2012 14:08:33 -0600 Subject: fix for SH-3137: delay to issue new http fetching requests if http connection failure happens --- indra/llmessage/llcurl.cpp | 76 ++++++++++++++++++++++++++++++++++------------ indra/llmessage/llcurl.h | 8 +++-- 2 files changed, 63 insertions(+), 21 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp index c06cf2489d..4cfa48cbd9 100644 --- a/indra/llmessage/llcurl.cpp +++ b/indra/llmessage/llcurl.cpp @@ -922,7 +922,7 @@ void LLCurlThread::CurlRequest::finishRequest(bool completed) { if(mMulti->isDead()) { - mCurlThread->deleteMulti(mMulti) ; + mCurlThread->deleteMulti(mMulti) ; } else { @@ -968,8 +968,8 @@ void LLCurlThread::killMulti(LLCurl::Multi* multi) if(multi->isValid()) { - multi->markDead() ; -} + multi->markDead() ; + } else { deleteMulti(multi) ; @@ -1233,6 +1233,7 @@ LLCurlTextureRequest::LLCurlTextureRequest(S32 concurrency) : mTotalIssuedRequests(0), mTotalReceivedBits(0) { + mGlobalTimer.reset(); } LLCurlTextureRequest::~LLCurlTextureRequest() @@ -1251,12 +1252,12 @@ LLCurlTextureRequest::~LLCurlTextureRequest() U32 LLCurlTextureRequest::getByteRange(const std::string& url, const headers_t& headers, S32 offset, S32 length, U32 pri, - LLCurl::ResponderPtr responder) + LLCurl::ResponderPtr responder, F32 delay_time) { U32 ret_val = 0; bool success = false; - if(mInQueue < mConcurrency) + if(mInQueue < mConcurrency && delay_time < 0.f) { success = LLCurlRequest::getByteRange(url, headers, offset, length, responder); } @@ -1271,6 +1272,11 @@ U32 LLCurlTextureRequest::getByteRange(const std::string& url, else { request_t* request = new request_t(mHandleCounter, url, headers, offset, length, pri, responder); + if(delay_time > 0.f) + { + request->mStartTime = mGlobalTimer.getElapsedTimeF32() + delay_time; + } + mCachedRequests.insert(request); mRequestMap[mHandleCounter] = request; ret_val = mHandleCounter; @@ -1297,29 +1303,50 @@ void LLCurlTextureRequest::completeRequest(S32 received_bytes) void LLCurlTextureRequest::nextRequests() { - while(!mCachedRequests.empty() && mInQueue < mConcurrency) + if(mCachedRequests.empty() || mInQueue >= mConcurrency) { - request_t* request; - - { - LLMutexLock lock(&mMutex); - req_queue_t::iterator iter = mCachedRequests.begin(); - request = *iter; - } + return; + } - if(!LLCurlRequest::getByteRange(request->mUrl, request->mHeaders, request->mOffset, request->mLength, request->mResponder)) - { - break; - } + F32 cur_time = mGlobalTimer.getElapsedTimeF32(); + req_queue_t::iterator iter; + { + LLMutexLock lock(&mMutex); + iter = mCachedRequests.begin(); + } + while(1) + { + request_t* request = *iter; + if(request->mStartTime < cur_time) { + if(!LLCurlRequest::getByteRange(request->mUrl, request->mHeaders, request->mOffset, request->mLength, request->mResponder)) + { + break; + } + LLMutexLock lock(&mMutex); + ++iter; mInQueue++; mTotalIssuedRequests++; - llassert_always(1 == mCachedRequests.erase(request)); + mCachedRequests.erase(request); mRequestMap.erase(request->mHandle); + delete request; + + if(iter == mCachedRequests.end() || mInQueue >= mConcurrency) + { + break; + } + } + else + { + LLMutexLock lock(&mMutex); + ++iter; + if(iter == mCachedRequests.end() || mInQueue >= mConcurrency) + { + break; + } } - delete request; } return; @@ -1367,6 +1394,17 @@ void LLCurlTextureRequest::removeRequest(U32 handle) } } +bool LLCurlTextureRequest::isWaiting(U32 handle) +{ + if(!handle) + { + return false; + } + + LLMutexLock lock(&mMutex); + return mRequestMap.find(handle) != mRequestMap.end(); +} + U32 LLCurlTextureRequest::getTotalReceivedBits() { LLMutexLock lock(&mMutex); diff --git a/indra/llmessage/llcurl.h b/indra/llmessage/llcurl.h index 04a2bd4287..87cb192141 100644 --- a/indra/llmessage/llcurl.h +++ b/indra/llmessage/llcurl.h @@ -420,7 +420,7 @@ public: LLCurlTextureRequest(S32 concurrency); ~LLCurlTextureRequest(); - U32 getByteRange(const std::string& url, const headers_t& headers, S32 offset, S32 length, U32 pri, LLCurl::ResponderPtr responder); + U32 getByteRange(const std::string& url, const headers_t& headers, S32 offset, S32 length, U32 pri, LLCurl::ResponderPtr responder, F32 delay_time = -1.f); void nextRequests(); void completeRequest(S32 received_bytes); @@ -430,6 +430,7 @@ public: U32 getTotalReceivedBits(); U32 getTotalIssuedRequests(); S32 getNumRequests(); + bool isWaiting(U32 handle); private: LLMutex mMutex; @@ -442,7 +443,7 @@ private: typedef struct _request_t { _request_t(U32 handle, const std::string& url, const headers_t& headers, S32 offset, S32 length, U32 pri, LLCurl::ResponderPtr responder) : - mHandle(handle), mUrl(url), mHeaders(headers), mOffset(offset), mLength(length), mPriority(pri), mResponder(responder) + mHandle(handle), mUrl(url), mHeaders(headers), mOffset(offset), mLength(length), mPriority(pri), mResponder(responder), mStartTime(0.f) {} U32 mHandle; @@ -452,6 +453,7 @@ private: S32 mLength; LLCurl::ResponderPtr mResponder; U32 mPriority; + F32 mStartTime; //start time to issue this request } request_t; struct request_compare @@ -472,6 +474,8 @@ private: typedef std::set req_queue_t; req_queue_t mCachedRequests; std::map mRequestMap; + + LLFrameTimer mGlobalTimer; }; class LLCurlEasyRequest -- cgit v1.2.3 From 0730b24d7cb0a0ce0d6d08bc4e98387124bf03d0 Mon Sep 17 00:00:00 2001 From: Xiaohong Bao Date: Tue, 26 Jun 2012 22:27:24 -0600 Subject: fix merge conflicts: v-r to drano --- indra/llmessage/llcurl.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp index 1b0f9437c9..b4ac984d57 100644 --- a/indra/llmessage/llcurl.cpp +++ b/indra/llmessage/llcurl.cpp @@ -990,18 +990,8 @@ void LLCurlThread::killMulti(LLCurl::Multi* multi) return ; } -<<<<<<< local - if(multi->isValid()) - { - multi->markDead() ; - } - else - { - deleteMulti(multi) ; - } -======= + multi->markDead() ; ->>>>>>> other } //private -- cgit v1.2.3 From 7cbbdbd896d1e54d2d54cb4ec1ed5bd14491a629 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 13 Aug 2012 16:55:51 -0700 Subject: PATH-849: CRASHFIX This should fix the crash caused by LLPathfindingObject::handleAvatarNameFetch being called after the corresponding LLPathfindingObject has been deleted. --- indra/llmessage/llavatarnamecache.cpp | 14 +++++++++----- indra/llmessage/llavatarnamecache.h | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'indra/llmessage') diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp index 97f2792686..ff31f7665e 100644 --- a/indra/llmessage/llavatarnamecache.cpp +++ b/indra/llmessage/llavatarnamecache.cpp @@ -651,8 +651,10 @@ void LLAvatarNameCache::fireSignal(const LLUUID& agent_id, signal(agent_id, av_name); } -void LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot) +LLAvatarNameCache::callback_connection_t LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot) { + callback_connection_t connection; + if (sRunning) { // ...only do immediate lookups when cache is running @@ -668,7 +670,7 @@ void LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot) { // ...name already exists in cache, fire callback now fireSignal(agent_id, slot, av_name); - return; + return connection; } } } @@ -681,7 +683,7 @@ void LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot) LLAvatarName av_name; buildLegacyName(full_name, &av_name); fireSignal(agent_id, slot, av_name); - return; + return connection; } } } @@ -698,15 +700,17 @@ void LLAvatarNameCache::get(const LLUUID& agent_id, callback_slot_t slot) { // ...new callback for this id callback_signal_t* signal = new callback_signal_t(); - signal->connect(slot); + connection = signal->connect(slot); sSignalMap[agent_id] = signal; } else { // ...existing callback, bind additional slot callback_signal_t* signal = sig_it->second; - signal->connect(slot); + connection = signal->connect(slot); } + + return connection; } diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h index 59c1329ffa..064942fe53 100644 --- a/indra/llmessage/llavatarnamecache.h +++ b/indra/llmessage/llavatarnamecache.h @@ -71,10 +71,11 @@ namespace LLAvatarNameCache void (const LLUUID& agent_id, const LLAvatarName& av_name)> callback_signal_t; typedef callback_signal_t::slot_type callback_slot_t; + typedef boost::signals2::connection callback_connection_t; // Fetches name information and calls callback. // If name information is in cache, callback will be called immediately. - void get(const LLUUID& agent_id, callback_slot_t slot); + callback_connection_t get(const LLUUID& agent_id, callback_slot_t slot); // Allow display names to be explicitly disabled for testing. void setUseDisplayNames(bool use); -- cgit v1.2.3