Add improved timeout handling for HTTP transactions.
Introduces AIHTTPTimeoutPolicy objects which do not just specify a single "timeout" in seconds, but a plethora of timings related to the life cycle of the average HTTP transaction. This knowledge is that moved to the Responder being used instead of floating constants hardcoded in the callers of http requests. This assumes that the same timeout policy is wanted for each transaction that uses the same Responder, which can be enforced is needed. I added a AIHTTPTimeoutPolicy for EVERY responder, only to make it easier later to tune timeout values and/or to get feedback about which responder runs into HTTP errors in debug output (especially time outs), so that they can be tuned later. If we already understood exactly what we were doing then most responders could have been left alone and just return the default timeout policy: by far most timeout policies are just a copy of the default policy, currently. This commit is not finished... It's a work in progress (viewer runs fine with it though).
This commit is contained in:
@@ -38,6 +38,10 @@
|
||||
#include "llviewerregion.h"
|
||||
#include "llviewerwindow.h"
|
||||
|
||||
class AIHTTPTimeoutPolicy;
|
||||
extern AIHTTPTimeoutPolicy inventoryModelFetchDescendentsResponder_timeout;
|
||||
extern AIHTTPTimeoutPolicy inventoryModelFetchItemResponder_timeout;
|
||||
|
||||
const F32 MAX_TIME_FOR_SINGLE_FETCH = 10.f;
|
||||
const S32 MAX_FETCH_RETRIES = 10;
|
||||
|
||||
@@ -374,6 +378,7 @@ public:
|
||||
LLInventoryModelFetchItemResponder(const LLSD& request_sd) : LLInventoryModel::fetchInventoryResponder(request_sd) {};
|
||||
void result(const LLSD& content);
|
||||
void error(U32 status, const std::string& reason);
|
||||
AIHTTPTimeoutPolicy const& getHTTPTimeoutPolicy(void) const { return inventoryModelFetchItemResponder_timeout; }
|
||||
};
|
||||
|
||||
void LLInventoryModelFetchItemResponder::result( const LLSD& content )
|
||||
@@ -388,7 +393,6 @@ void LLInventoryModelFetchItemResponder::error( U32 status, const std::string& r
|
||||
LLInventoryModelBackgroundFetch::instance().incrFetchCount(-1);
|
||||
}
|
||||
|
||||
|
||||
class LLInventoryModelFetchDescendentsResponder: public LLHTTPClient::Responder
|
||||
{
|
||||
public:
|
||||
@@ -399,6 +403,8 @@ class LLInventoryModelFetchDescendentsResponder: public LLHTTPClient::Responder
|
||||
//LLInventoryModelFetchDescendentsResponder() {};
|
||||
void result(const LLSD& content);
|
||||
void error(U32 status, const std::string& reason);
|
||||
virtual AIHTTPTimeoutPolicy const& getHTTPTimeoutPolicy(void) const { return inventoryModelFetchDescendentsResponder_timeout; }
|
||||
|
||||
protected:
|
||||
BOOL getIsRecursive(const LLUUID& cat_id) const;
|
||||
private:
|
||||
@@ -699,14 +705,14 @@ void LLInventoryModelBackgroundFetch::bulkFetch()
|
||||
if (folder_request_body["folders"].size())
|
||||
{
|
||||
LLInventoryModelFetchDescendentsResponder *fetcher = new LLInventoryModelFetchDescendentsResponder(folder_request_body, recursive_cats);
|
||||
LLHTTPClient::post4(url, folder_request_body, fetcher, 300.0);
|
||||
LLHTTPClient::post4(url, folder_request_body, fetcher);
|
||||
}
|
||||
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::post4(url_lib, folder_request_body_lib, fetcher, 300.0);
|
||||
LLHTTPClient::post4(url_lib, folder_request_body_lib, fetcher);
|
||||
}
|
||||
}
|
||||
if (item_count)
|
||||
|
||||
Reference in New Issue
Block a user