summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorXiaohong Bao <bao@lindenlab.com>2012-05-10 11:04:51 -0600
committerXiaohong Bao <bao@lindenlab.com>2012-05-10 11:04:51 -0600
commitb73527420b4e664978f8d5587b7801435a7b56ca (patch)
tree50dd561ade23a3605129a5737985e88857d8bd9c /indra
parent7059abb466f36fabd67b44a30de1d90501827070 (diff)
fix for SH-3132: Many "HTTP GET failed errors" with Drano merge candidate 255539
Diffstat (limited to 'indra')
-rwxr-xr-xindra/newview/lltexturefetch.cpp54
-rw-r--r--indra/newview/lltexturefetch.h7
2 files changed, 56 insertions, 5 deletions
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index eac6abc1ca..e96bcd2ad0 100755
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -1162,8 +1162,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
//1, not openning too many file descriptors at the same time;
//2, control the traffic of http so udp gets bandwidth.
//
- static const S32 MAX_NUM_OF_HTTP_REQUESTS_IN_QUEUE = 24 ;
- if(mFetcher->getNumHTTPRequests() > MAX_NUM_OF_HTTP_REQUESTS_IN_QUEUE)
+ if(!mFetcher->canIssueHTTPRequest())
{
return false ; //wait.
}
@@ -1275,6 +1274,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
// requests instead of returning 503... we already limit the number pending.
++mHTTPFailCount;
max_attempts = mHTTPFailCount+1; // Keep retrying
+ mFetcher->adjustHTTPConcurrency(false);
LL_INFOS_ONCE("Texture") << "Texture server busy (503): " << mUrl << LL_ENDL;
}
else
@@ -1282,6 +1282,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
const S32 HTTP_MAX_RETRY_COUNT = 3;
max_attempts = HTTP_MAX_RETRY_COUNT + 1;
++mHTTPFailCount;
+ mFetcher->adjustHTTPConcurrency(false);
llinfos << "HTTP GET failed for: " << mUrl
<< " Status: " << mGetStatus << " Reason: '" << mGetReason << "'"
<< " Attempt:" << mHTTPFailCount+1 << "/" << max_attempts << llendl;
@@ -1869,7 +1870,8 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image
mQAMode(qa_mode),
mFetchDebugger(NULL),
mFetchSource(LLTextureFetch::FROM_ALL),
- mOriginFetchSource(LLTextureFetch::FROM_ALL)
+ mOriginFetchSource(LLTextureFetch::FROM_ALL),
+ mHTTPConcurrency(24)
{
mCurlPOSTRequestCount = 0;
mMaxBandwidth = gSavedSettings.getF32("ThrottleBandwidthKBPS");
@@ -2094,6 +2096,42 @@ S32 LLTextureFetch::getNumRequests()
return size ;
}
+bool LLTextureFetch::canIssueHTTPRequest()
+{
+ LLMutexLock lock(&mNetworkQueueMutex);
+
+ return (S32)mHTTPTextureQueue.size() < mHTTPConcurrency ;
+}
+
+void LLTextureFetch::adjustHTTPConcurrency(bool success)
+{
+ static LLTimer timer;
+
+ LLMutexLock lock(&mNetworkQueueMutex);
+ if(success)
+ {
+ if(mHTTPConcurrency < 21 && timer.getElapsedTimeF32() > 15.f) //seconds
+ {
+ mHTTPConcurrency += 4; //max is 24
+ timer.reset();
+ }
+ }
+ else
+ {
+ if(mHTTPConcurrency > 11 && timer.getElapsedTimeF32() > 2.0f)
+ {
+ mHTTPConcurrency -= 8; //min is 4
+ timer.reset();
+ }
+ }
+}
+
+S32 LLTextureFetch::getHTTPConcurrency()
+{
+ LLMutexLock lock(&mNetworkQueueMutex);
+ return mHTTPConcurrency;
+}
+
S32 LLTextureFetch::getNumHTTPRequests()
{
mNetworkQueueMutex.lock() ;
@@ -2311,6 +2349,9 @@ S32 LLTextureFetch::update(F32 max_time_ms)
{
mFetchDebugger->tryToStopDebug(); //check if need to stop debugger.
}
+
+ adjustHTTPConcurrency(true);
+
return res;
}
@@ -3608,7 +3649,8 @@ S32 LLTextureFetchDebugger::fillCurlQueue()
return 0;
}
- if (mNbCurlRequests == 24)
+ S32 max_concurrency = mFetcher->getHTTPConcurrency();
+ if (mNbCurlRequests == max_concurrency)
return mNbCurlRequests;
S32 size = mFetchingHistory.size();
@@ -3630,7 +3672,7 @@ S32 LLTextureFetchDebugger::fillCurlQueue()
mFetchingHistory[i].mCurlState = FetchEntry::CURL_IN_PROGRESS;
mNbCurlRequests++;
// Hack
- if (mNbCurlRequests == 24)
+ if (mNbCurlRequests == max_concurrency)
break;
}
else
@@ -4007,6 +4049,8 @@ void LLTextureFetchDebugger::callbackHTTP(S32 id, const LLChannelDescriptors& ch
mFetchingHistory[id].mCurlState = FetchEntry::CURL_DONE;
mNbCurlCompleted++;
}
+
+ mFetcher->adjustHTTPConcurrency(false);
}
}
diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h
index d7677295c0..3ac08ecbc2 100644
--- a/indra/newview/lltexturefetch.h
+++ b/indra/newview/lltexturefetch.h
@@ -109,6 +109,10 @@ public:
inline void incrCurlPOSTCount() { mCurlPOSTRequestCount++; }
inline void decrCurlPOSTCount() { mCurlPOSTRequestCount--; }
+ bool canIssueHTTPRequest();
+ void adjustHTTPConcurrency(bool success);
+ S32 getHTTPConcurrency();
+
protected:
void addToNetworkQueue(LLTextureFetchWorker* worker);
void removeFromNetworkQueue(LLTextureFetchWorker* worker, bool cancel);
@@ -209,6 +213,9 @@ private:
// use the LLCurl module's request counter as it isn't thread compatible.
// *NOTE: Don't mix Atomic and static, apr_initialize must be called first.
LLAtomic32<S32> mCurlPOSTRequestCount;
+
+ //control http concurrency for texture fetching
+ S32 mHTTPConcurrency; //which is adaptive to the network situation at an instant
public:
// A probabilistically-correct indicator that the current