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:
@@ -53,9 +53,14 @@ LLPumpIO* gServicePump;
|
||||
BOOL gBreak = false;
|
||||
BOOL gSent = false;
|
||||
|
||||
class AIHTTPTimeoutPolicy;
|
||||
extern AIHTTPTimeoutPolicy crashLoggerResponder_timeout;
|
||||
|
||||
class LLCrashLoggerResponder : public LLHTTPClient::Responder
|
||||
{
|
||||
public:
|
||||
virtual AIHTTPTimeoutPolicy const& getHTTPTimeoutPolicy(void) const { return crashLoggerResponder_timeout; }
|
||||
|
||||
LLCrashLoggerResponder()
|
||||
{
|
||||
}
|
||||
@@ -308,14 +313,14 @@ bool LLCrashLogger::saveCrashBehaviorSetting(S32 crash_behavior)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LLCrashLogger::runCrashLogPost(std::string host, LLSD data, std::string msg, int retries, int timeout)
|
||||
bool LLCrashLogger::runCrashLogPost(std::string host, LLSD data, std::string msg, int retries)
|
||||
{
|
||||
gBreak = false;
|
||||
std::string status_message;
|
||||
for(int i = 0; i < retries; ++i)
|
||||
{
|
||||
status_message = llformat("%s, try %d...", msg.c_str(), i+1);
|
||||
LLHTTPClient::post4(host, data, new LLCrashLoggerResponder(), timeout);
|
||||
LLHTTPClient::post4(host, data, new LLCrashLoggerResponder);
|
||||
while(!gBreak)
|
||||
{
|
||||
updateApplication(status_message);
|
||||
@@ -350,12 +355,12 @@ bool LLCrashLogger::sendCrashLogs()
|
||||
// *TODO: Translate
|
||||
if(mCrashHost != "")
|
||||
{
|
||||
sent = runCrashLogPost(mCrashHost, post_data, std::string("Sending to server"), 3, 5);
|
||||
sent = runCrashLogPost(mCrashHost, post_data, std::string("Sending to server"), 3);
|
||||
}
|
||||
|
||||
if(!sent)
|
||||
{
|
||||
sent = runCrashLogPost(mAltCrashHost, post_data, std::string("Sending to alternate server"), 3, 5);
|
||||
sent = runCrashLogPost(mAltCrashHost, post_data, std::string("Sending to alternate server"), 3);
|
||||
}
|
||||
|
||||
mSentCrashLogs = sent;
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
#include "llsd.h"
|
||||
#include "llcontrol.h"
|
||||
|
||||
class AIHTTPTimeoutPolicy;
|
||||
|
||||
class LLCrashLogger : public LLApp
|
||||
{
|
||||
public:
|
||||
@@ -57,7 +59,7 @@ public:
|
||||
virtual bool cleanup() { return true; }
|
||||
void setUserText(const std::string& text) { mCrashInfo["UserNotes"] = text; }
|
||||
S32 getCrashBehavior() { return mCrashBehavior; }
|
||||
bool runCrashLogPost(std::string host, LLSD data, std::string msg, int retries, int timeout);
|
||||
bool runCrashLogPost(std::string host, LLSD data, std::string msg, int retries);
|
||||
protected:
|
||||
S32 mCrashBehavior;
|
||||
BOOL mCrashInPreviousExec;
|
||||
|
||||
Reference in New Issue
Block a user