summaryrefslogtreecommitdiff
path: root/indra/llmessage
diff options
context:
space:
mode:
authorXiaohong Bao <bao@lindenlab.com>2012-05-25 14:08:33 -0600
committerXiaohong Bao <bao@lindenlab.com>2012-05-25 14:08:33 -0600
commitcbb14e223c4db312191d0fe0b12362298fbf9fbd (patch)
tree2548cbbf01d090de3236aa97e021f780abc9fc7b /indra/llmessage
parentbda06182c45f09afe411103b497c8172fc240676 (diff)
fix for SH-3137: delay to issue new http fetching requests if http connection failure happens
Diffstat (limited to 'indra/llmessage')
-rw-r--r--indra/llmessage/llcurl.cpp76
-rw-r--r--indra/llmessage/llcurl.h8
2 files changed, 63 insertions, 21 deletions
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<request_t*, request_compare> req_queue_t;
req_queue_t mCachedRequests;
std::map<S32, request_t*> mRequestMap;
+
+ LLFrameTimer mGlobalTimer;
};
class LLCurlEasyRequest