Let statemachine honor approvements.
The inventory bulk fetch is not thread-safe, so the it doesn't start right away, causing the approvement not to be honored upon return from post_approved (formerly post_nb). This patch renames wantsMoreHTTPReqestsFor to approveHTTPRequestFor, and has it return NULL or a AIPerService::Approvement object. The latter is now passed to the CurlEasyHandle object instead of just a boolean mQueueIfTooMuchBandwidthUsage, and then the Approvement is honored by the state machine right after the request is actually added to the command queue. This should avoid a flood of inventory requests in the case approveHTTPRequestFor is called multiple times before the main thread adds the requests to the command queue. I don't think that actually ever happens, but I added debug code (to find some problem) that is so damn strictly checking everything that I need to be this precise in order to do that testing.
This commit is contained in:
@@ -1272,13 +1272,14 @@ bool LLTextureFetchWorker::doWork(S32 param)
|
||||
}
|
||||
|
||||
// Let AICurl decide if we can process more HTTP requests at the moment or not.
|
||||
if (!AIPerService::wantsMoreHTTPRequestsFor(mPerServicePtr))
|
||||
|
||||
// AIPerService::approveHTTPRequestFor returns approvement for ONE request.
|
||||
// This object keeps track of whether or not that is honored.
|
||||
LLPointer<AIPerService::Approvement> approved = AIPerService::approveHTTPRequestFor(mPerServicePtr);
|
||||
if (!approved)
|
||||
{
|
||||
return false ; //wait.
|
||||
}
|
||||
// If AIPerService::wantsMoreHTTPRequestsFor returns true then it approved ONE request.
|
||||
// This object keeps track of whether or not that is honored.
|
||||
AIPerService::Approvement approvement(mPerServicePtr);
|
||||
|
||||
mFetcher->removeFromNetworkQueue(this, false);
|
||||
|
||||
@@ -1324,9 +1325,7 @@ bool LLTextureFetchWorker::doWork(S32 param)
|
||||
}
|
||||
LLHTTPClient::request(mUrl, LLHTTPClient::HTTP_GET, NULL,
|
||||
new HTTPGetResponder(mFetcher, mID, LLTimer::getTotalTime(), mRequestedSize, mRequestedOffset, true),
|
||||
headers/*,*/ DEBUG_CURLIO_PARAM(debug_off), keep_alive, no_does_authentication, allow_compressed_reply, NULL, 0, NULL, false);
|
||||
// Now the request was added to the command queue.
|
||||
approvement.honored();
|
||||
headers, approved/*,*/ DEBUG_CURLIO_PARAM(debug_off), keep_alive, no_does_authentication, allow_compressed_reply, NULL, 0, NULL);
|
||||
res = true;
|
||||
}
|
||||
if (!res)
|
||||
|
||||
Reference in New Issue
Block a user