Bring aisapi handling closer to LL (code 499 retry, match timeout values, etc)
This commit is contained in:
@@ -961,3 +961,4 @@ P(wholeModelFeeResponder);
|
|||||||
P(wholeModelUploadResponder);
|
P(wholeModelUploadResponder);
|
||||||
P2(XMLRPCResponder, connect_40s);
|
P2(XMLRPCResponder, connect_40s);
|
||||||
P(getUpdateInfoResponder);
|
P(getUpdateInfoResponder);
|
||||||
|
P2(AISAPIResponder, connect_60s);
|
||||||
@@ -40,6 +40,8 @@
|
|||||||
/// Classes for AISv3 support.
|
/// Classes for AISv3 support.
|
||||||
///----------------------------------------------------------------------------
|
///----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
extern AIHTTPTimeoutPolicy AISAPIResponder_timeout;
|
||||||
|
|
||||||
class AISCommand final : public LLHTTPClient::ResponderWithCompleted
|
class AISCommand final : public LLHTTPClient::ResponderWithCompleted
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -54,8 +56,11 @@ public:
|
|||||||
mType(type)
|
mType(type)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
virtual AIHTTPTimeoutPolicy const& getHTTPTimeoutPolicy(void) const { return AISAPIResponder_timeout; }
|
||||||
|
|
||||||
void run( command_func_type func )
|
void run( command_func_type func )
|
||||||
{
|
{
|
||||||
|
LL_WARNS("Inventory") << "Sending request for " << getName() <<": " << mURL << LL_ENDL;
|
||||||
(mCommandFunc = func)();
|
(mCommandFunc = func)();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,6 +69,7 @@ public:
|
|||||||
return mName;
|
return mName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
void markComplete()
|
void markComplete()
|
||||||
{
|
{
|
||||||
// Command func holds a reference to self, need to release it
|
// Command func holds a reference to self, need to release it
|
||||||
@@ -72,34 +78,39 @@ public:
|
|||||||
mRetryPolicy->onSuccess();
|
mRetryPolicy->onSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
void malformedResponse() { mStatus = HTTP_INTERNAL_ERROR_OTHER; mReason = llformat("Malformed response contents (original code: %d)", mStatus); }
|
|
||||||
|
|
||||||
bool onFailure()
|
bool onFailure()
|
||||||
{
|
{
|
||||||
bool retry = mStatus != HTTP_INTERNAL_ERROR_OTHER && mStatus != 410; // We handle these and stop
|
mRetryPolicy->onFailure(mStatus, getResponseHeaders());
|
||||||
LL_WARNS("Inventory") << "Inventory error: " << dumpResponse() << LL_ENDL;
|
|
||||||
if (retry) mRetryPolicy->onFailure(mStatus, getResponseHeaders());
|
|
||||||
F32 seconds_to_wait;
|
F32 seconds_to_wait;
|
||||||
if (retry && mRetryPolicy->shouldRetry(seconds_to_wait))
|
if (mRetryPolicy->shouldRetry(seconds_to_wait))
|
||||||
{
|
{
|
||||||
|
LL_WARNS("Inventory") << "Retrying in " << seconds_to_wait << "seconds due to inventory error for " << getName() <<": " << dumpResponse() << LL_ENDL;
|
||||||
doAfterInterval(mCommandFunc,seconds_to_wait);
|
doAfterInterval(mCommandFunc,seconds_to_wait);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Command func holds a reference to self, need to release it
|
// Command func holds a reference to self, need to release it
|
||||||
// after a success or final failure.
|
// after a success or final failure.
|
||||||
// *TODO: Notify user? This seems bad.
|
// *TODO: Notify user? This seems bad.
|
||||||
|
LL_WARNS("Inventory") << "Abort due to inventory error for " << getName() <<": " << dumpResponse() << LL_ENDL;
|
||||||
mCommandFunc = no_op;
|
mCommandFunc = no_op;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return retry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void httpCompleted() override
|
void httpCompleted() override
|
||||||
{
|
{
|
||||||
|
// Continue through if successful or longer retrying,
|
||||||
|
if (isGoodStatus(mStatus) || !onFailure())
|
||||||
|
{
|
||||||
|
markComplete();
|
||||||
AISAPI::InvokeAISCommandCoro(this, getURL(), mTargetId, getContent(), mCompletionFunc, (AISAPI::COMMAND_TYPE)mType);
|
AISAPI::InvokeAISCommandCoro(this, getURL(), mTargetId, getContent(), mCompletionFunc, (AISAPI::COMMAND_TYPE)mType);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
command_func_type mCommandFunc;
|
command_func_type mCommandFunc;
|
||||||
LLPointer<LLHTTPRetryPolicy> mRetryPolicy;
|
LLPointer<LLHTTPRetryPolicy> mRetryPolicy;
|
||||||
AISAPI::completion_t mCompletionFunc;
|
AISAPI::completion_t mCompletionFunc;
|
||||||
@@ -312,7 +323,7 @@ void AISAPI::UpdateItem(const LLUUID &itemId, const LLSD &updates, completion_t
|
|||||||
boost::intrusive_ptr< AISCommand > responder = new AISCommand(UPDATEITEM, "UpdateItem",itemId, callback);
|
boost::intrusive_ptr< AISCommand > responder = new AISCommand(UPDATEITEM, "UpdateItem",itemId, callback);
|
||||||
responder->run(boost::bind(&LLHTTPClient::patch, url, updates, responder/*,*/ DEBUG_CURLIO_PARAM(debug_off), keep_alive, (AIStateMachine*)NULL, 0));
|
responder->run(boost::bind(&LLHTTPClient::patch, url, updates, responder/*,*/ DEBUG_CURLIO_PARAM(debug_off), keep_alive, (AIStateMachine*)NULL, 0));
|
||||||
}
|
}
|
||||||
void AISAPI::InvokeAISCommandCoro(AISCommand* responder,
|
void AISAPI::InvokeAISCommandCoro(LLHTTPClient::ResponderWithCompleted* responder,
|
||||||
std::string url,
|
std::string url,
|
||||||
LLUUID targetId, LLSD result, completion_t callback, COMMAND_TYPE type)
|
LLUUID targetId, LLSD result, completion_t callback, COMMAND_TYPE type)
|
||||||
{
|
{
|
||||||
@@ -324,7 +335,7 @@ void AISAPI::InvokeAISCommandCoro(AISCommand* responder,
|
|||||||
{
|
{
|
||||||
if (!result.isMap())
|
if (!result.isMap())
|
||||||
{
|
{
|
||||||
responder->malformedResponse();
|
LL_WARNS("Inventory") << "Inventory error: " << HTTP_INTERNAL_ERROR_OTHER << ": " << "Malformed response contents" << LL_ENDL;
|
||||||
}
|
}
|
||||||
else if (status == 410) //GONE
|
else if (status == 410) //GONE
|
||||||
{
|
{
|
||||||
@@ -359,12 +370,10 @@ void AISAPI::InvokeAISCommandCoro(AISCommand* responder,
|
|||||||
gInventory.onObjectDeletedFromServer(targetId);
|
gInventory.onObjectDeletedFromServer(targetId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LL_WARNS("Inventory") << "Inventory error: " << status << ": " << responder->getReason() << LL_ENDL;
|
||||||
}
|
}
|
||||||
// Keep these statuses accounted for in the responder too
|
LL_WARNS("Inventory") << ll_pretty_print_sd(result) << LL_ENDL;
|
||||||
if (responder->onFailure()) // If we're retrying, exit early.
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else responder->markComplete();
|
|
||||||
|
|
||||||
gInventory.onAISUpdateReceived("AISCommand", result);
|
gInventory.onAISUpdateReceived("AISCommand", result);
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ private:
|
|||||||
static std::string getInvCap();
|
static std::string getInvCap();
|
||||||
static std::string getLibCap();
|
static std::string getLibCap();
|
||||||
|
|
||||||
static void InvokeAISCommandCoro(class AISCommand* responder,
|
static void InvokeAISCommandCoro(LLHTTPClient::ResponderWithCompleted* responder,
|
||||||
std::string url, LLUUID targetId, LLSD body,
|
std::string url, LLUUID targetId, LLSD body,
|
||||||
completion_t callback, COMMAND_TYPE type);
|
completion_t callback, COMMAND_TYPE type);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user