From bbf24b4994e209f07f2f9a013a82527df2bb23b1 Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Wed, 27 Mar 2013 21:45:09 +0100 Subject: [PATCH 1/3] Indentation fix. --- indra/newview/lltexturefetch.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 1d3634573..86f86409c 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -1334,17 +1334,17 @@ bool LLTextureFetchWorker::doWork(S32 param) mRequestedOffset--; } - // Will call callbackHttpGet when curl request completes - AIHTTPHeaders headers("Accept", "image/x-j2c"); - // Call LLHTTPClient::request directly instead of LLHTTPClient::getByteRange, because we want to pass a NULL AIEngine. - if (mRequestedOffset > 0 || mRequestedSize > 0) - { - headers.addHeader("Range", llformat("bytes=%d-%d", mRequestedOffset, mRequestedOffset + mRequestedSize - 1)); - } - LLHTTPClient::request(mUrl, LLHTTPClient::HTTP_GET, NULL, - new HTTPGetResponder(mFetcher, mID, LLTimer::getTotalTime(), mRequestedSize, mRequestedOffset, true), - headers/*,*/ DEBUG_CURLIO_PARAM(false), keep_alive, no_does_authentication, allow_compressed_reply, NULL, 0, NULL); - res = true; + // Will call callbackHttpGet when curl request completes + AIHTTPHeaders headers("Accept", "image/x-j2c"); + // Call LLHTTPClient::request directly instead of LLHTTPClient::getByteRange, because we want to pass a NULL AIEngine. + if (mRequestedOffset > 0 || mRequestedSize > 0) + { + headers.addHeader("Range", llformat("bytes=%d-%d", mRequestedOffset, mRequestedOffset + mRequestedSize - 1)); + } + LLHTTPClient::request(mUrl, LLHTTPClient::HTTP_GET, NULL, + new HTTPGetResponder(mFetcher, mID, LLTimer::getTotalTime(), mRequestedSize, mRequestedOffset, true), + headers/*,*/ DEBUG_CURLIO_PARAM(false), keep_alive, no_does_authentication, allow_compressed_reply, NULL, 0, NULL); + res = true; } if (!res) { From ac84e020180111aa678bd51eefc24dd6e8f0275d Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Wed, 27 Mar 2013 21:49:25 +0100 Subject: [PATCH 2/3] Do not use a timer for HTTP get in LLTextureFetchWorker::doWork All HTTP timing is done by AIHTTPTimeoutPolicy. Inside LLTextureFetchWorker::doWork when mState == SEND_HTTP_REQ, mCanUseHTTP is true, throttling is not in effect and mURL is not empty, mLoaded is set to FALSE, mState is set to WAIT_HTTP_REQ and LLHTTPClient::request is called that starts the download by curl. A call back to LLTextureFetchWorker::callbackHttpGet is guaranteed, which causes mLoaded to be set to TRUE (HTTPGetResponder::completedRaw calls LLTextureFetchWorker::callbackHttpGet which sets mRequestedSize to -1 (if there was an error) and mLoaded to TRUE). Being in state WAIT_HTTP_REQ, once mLoaded == TRUE (and mRequestedSize is -1), the different timeout errors are handled. --- indra/llmessage/aihttptimeoutpolicy.cpp | 9 ++++++++- indra/newview/lltexturefetch.cpp | 11 ----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/indra/llmessage/aihttptimeoutpolicy.cpp b/indra/llmessage/aihttptimeoutpolicy.cpp index d5e0dd3b6..840532e43 100644 --- a/indra/llmessage/aihttptimeoutpolicy.cpp +++ b/indra/llmessage/aihttptimeoutpolicy.cpp @@ -707,6 +707,13 @@ AIHTTPTimeoutPolicyBase connect_40s(AIHTTPTimeoutPolicyBase::getDebugSettingsCur connectOp40s ); +// This used to be FETCHING_TIMEOUT (for HTTP textures), being a 15 second timeout from start of request till finishing receiving all data. +// That seems way to demanding however; lets use a 15 second reply delay demand instead. +Reply replyOp15s(15); +AIHTTPTimeoutPolicyBase reply_15s(AIHTTPTimeoutPolicyBase::getDebugSettingsCurlTimeout(), + replyOp15s + ); + // End of policy definitions. //======================================================================================================= @@ -899,7 +906,7 @@ P2(gamingDataReceived, transfer_18s); P2(groupMemberDataResponder, transfer_300s); P2(groupProposalBallotResponder, transfer_300s); P(homeLocationResponder); -P(HTTPGetResponder); +P2(HTTPGetResponder, reply_15s); P(iamHereLogin); P(iamHere); P(iamHereVoice); diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 86f86409c..5efd486e0 100644 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -972,8 +972,6 @@ void LLTextureFetchWorker::startWork(S32 param) // Called from LLWorkerThread::processRequest() bool LLTextureFetchWorker::doWork(S32 param) { - static const F32 FETCHING_TIMEOUT = 15.f;//seconds - LLMutexLock lock(&mWorkMutex); if ((mFetcher->isQuitting() || getFlags(LLWorkerClass::WCF_DELETE_REQUESTED))) @@ -1304,8 +1302,6 @@ bool LLTextureFetchWorker::doWork(S32 param) bool res = false; if (!mUrl.empty()) { - mRequestedTimer.reset(); - mLoaded = FALSE; mGetStatus = 0; mGetReason.clear(); @@ -1533,13 +1529,6 @@ bool LLTextureFetchWorker::doWork(S32 param) } else { - if(FETCHING_TIMEOUT < mRequestedTimer.getElapsedTimeF32()) - { - //timeout, abort. - mState = DONE; - return true; - } - setPriority(LLWorkerThread::PRIORITY_LOW | mWorkPriority); return false; } From c14601f7c210a60af20fbd1e1f7dff6587e114cf Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Thu, 28 Mar 2013 03:01:27 +0100 Subject: [PATCH 3/3] Avoid assertion in ~AIStateMachine upon viewer exit. Force the state to bs_killed before clearing the list of statemachines in AIEngine::flush(). --- indra/aistatemachine/aistatemachine.cpp | 13 ++++++++++++- indra/aistatemachine/aistatemachine.h | 3 ++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/indra/aistatemachine/aistatemachine.cpp b/indra/aistatemachine/aistatemachine.cpp index dedec3bd7..8784a84c4 100644 --- a/indra/aistatemachine/aistatemachine.cpp +++ b/indra/aistatemachine/aistatemachine.cpp @@ -352,8 +352,13 @@ void AIEngine::mainloop(void) void AIEngine::flush(void) { - DoutEntering(dc::statemachine, "AIEngine::flush [" << mName << "]"); engine_state_type_wat engine_state_w(mEngineState); + DoutEntering(dc::statemachine, "AIEngine::flush [" << mName << "]: calling force_killed() on " << engine_state_w->list.size() << " state machines."); + for (queued_type::iterator iter = engine_state_w->list.begin(); iter != engine_state_w->list.end(); ++iter) + { + // To avoid an assertion in ~AIStateMachine. + iter->statemachine().force_killed(); + } engine_state_w->list.clear(); } @@ -906,6 +911,12 @@ void AIStateMachine::callback(void) } } +void AIStateMachine::force_killed(void) +{ + multiplex_state_type_wat state_w(mState); + state_w->base_state = bs_killed; +} + void AIStateMachine::kill(void) { DoutEntering(dc::statemachine, "AIStateMachine::kill() [" << (void*)this << "]"); diff --git a/indra/aistatemachine/aistatemachine.h b/indra/aistatemachine/aistatemachine.h index 10031a834..979205e02 100644 --- a/indra/aistatemachine/aistatemachine.h +++ b/indra/aistatemachine/aistatemachine.h @@ -300,8 +300,9 @@ class AIStateMachine : public LLThreadSafeRefCount mSleep = 0; return mSleep != 0; } + void force_killed(void); // Called from AIEngine::flush(). - friend class AIEngine; // Calls multiplex(). + friend class AIEngine; // Calls multiplex() and force_killed(). }; bool AIEngine::QueueElementComp::operator()(QueueElement const& e1, QueueElement const& e2) const