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:
@@ -605,14 +605,14 @@ void LLInventoryModelBackgroundFetch::bulkFetch()
|
||||
LLViewerRegion* region = gAgent.getRegion();
|
||||
if (gDisconnected || !region) return;
|
||||
|
||||
if (!AIPerService::wantsMoreHTTPRequestsFor(mPerServicePtr))
|
||||
// AIPerService::approveHTTPRequestFor returns approvement for ONE request.
|
||||
// The code below might fire off zero, one or even more than one requests however!
|
||||
// This object keeps track of that.
|
||||
LLPointer<AIPerService::Approvement> approved = AIPerService::approveHTTPRequestFor(mPerServicePtr);
|
||||
if (!approved)
|
||||
{
|
||||
return; // Wait.
|
||||
}
|
||||
// If AIPerService::wantsMoreHTTPRequestsFor returns true, then it approved ONE request.
|
||||
// The code below might fire off zero, one or even more than one requests however!
|
||||
// This object keeps track of that.
|
||||
AIPerService::Approvement approvement(mPerServicePtr);
|
||||
|
||||
U32 item_count=0;
|
||||
U32 folder_count=0;
|
||||
@@ -707,16 +707,14 @@ void LLInventoryModelBackgroundFetch::bulkFetch()
|
||||
if (folder_request_body["folders"].size())
|
||||
{
|
||||
LLInventoryModelFetchDescendentsResponder *fetcher = new LLInventoryModelFetchDescendentsResponder(folder_request_body, recursive_cats);
|
||||
LLHTTPClient::post_nb(url, folder_request_body, fetcher);
|
||||
approvement.honored();
|
||||
LLHTTPClient::post_approved(url, folder_request_body, fetcher, approved);
|
||||
}
|
||||
if (folder_request_body_lib["folders"].size())
|
||||
{
|
||||
std::string url_lib = gAgent.getRegion()->getCapability("FetchLibDescendents2");
|
||||
|
||||
LLInventoryModelFetchDescendentsResponder *fetcher = new LLInventoryModelFetchDescendentsResponder(folder_request_body_lib, recursive_cats);
|
||||
LLHTTPClient::post_nb(url_lib, folder_request_body_lib, fetcher);
|
||||
approvement.honored();
|
||||
LLHTTPClient::post_approved(url_lib, folder_request_body_lib, fetcher, approved);
|
||||
}
|
||||
}
|
||||
if (item_count)
|
||||
@@ -734,8 +732,7 @@ void LLInventoryModelBackgroundFetch::bulkFetch()
|
||||
body["agent_id"] = gAgent.getID();
|
||||
body["items"] = item_request_body;
|
||||
|
||||
LLHTTPClient::post_nb(url, body, new LLInventoryModelFetchItemResponder(body));
|
||||
approvement.honored();
|
||||
LLHTTPClient::post_approved(url, body, new LLInventoryModelFetchItemResponder(body), approved);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -751,8 +748,7 @@ void LLInventoryModelBackgroundFetch::bulkFetch()
|
||||
body["agent_id"] = gAgent.getID();
|
||||
body["items"] = item_request_body_lib;
|
||||
|
||||
LLHTTPClient::post_nb(url, body, new LLInventoryModelFetchItemResponder(body));
|
||||
approvement.honored();
|
||||
LLHTTPClient::post_approved(url, body, new LLInventoryModelFetchItemResponder(body), approved);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user