summaryrefslogtreecommitdiff
path: root/indra/llmessage
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2015-10-14 17:46:24 -0700
committerRider Linden <rider@lindenlab.com>2015-10-14 17:46:24 -0700
commitbbb9d4f21b018bfffc41f790aab7b54975504027 (patch)
tree4c81cfc2348dd98a4a157979afc854568da4caea /indra/llmessage
parent53b947e0397d6b88fdc6c0a10144e5a6d02a67d3 (diff)
MAINT-5732: Change to the way event polling handles error conditions and cancel calls.
Refactor any remaining LLCore::HTTPHandlers to use boost::shared_ptr Started minor refactor in the materials manager into coroutines (unfinished)
Diffstat (limited to 'indra/llmessage')
-rw-r--r--indra/llmessage/llcorehttputil.cpp28
-rw-r--r--indra/llmessage/llcorehttputil.h18
-rw-r--r--indra/llmessage/llhttpsdhandler.cpp30
-rw-r--r--indra/llmessage/llhttpsdhandler.h19
4 files changed, 25 insertions, 70 deletions
diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp
index a93bc03edd..9d3b8fcc1e 100644
--- a/indra/llmessage/llcorehttputil.cpp
+++ b/indra/llmessage/llcorehttputil.cpp
@@ -109,7 +109,7 @@ HttpHandle requestPostWithLLSD(HttpRequest * request,
const LLSD & body,
const HttpOptions::ptr_t &options,
const HttpHeaders::ptr_t &headers,
- HttpHandler * handler)
+ const HttpHandler::ptr_t &handler)
{
HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID);
@@ -136,7 +136,7 @@ HttpHandle requestPutWithLLSD(HttpRequest * request,
const LLSD & body,
const HttpOptions::ptr_t &options,
const HttpHeaders::ptr_t &headers,
- HttpHandler * handler)
+ const HttpHandler::ptr_t &handler)
{
HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID);
@@ -162,7 +162,7 @@ HttpHandle requestPatchWithLLSD(HttpRequest * request,
const LLSD & body,
const HttpOptions::ptr_t &options,
const HttpHeaders::ptr_t &headers,
- HttpHandler * handler)
+ const HttpHandler::ptr_t &handler)
{
HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID);
@@ -253,7 +253,7 @@ void HttpCoroHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons
LL_WARNS()
<< "\n--------------------------------------------------------------------------\n"
- << " Error[" << errType << "] cannot access url '" << response->getRequestURL()
+ << " Error[" << status.toTerseString() << "] cannot access url '" << response->getRequestURL()
<< "' because " << status.toString()
<< "\n--------------------------------------------------------------------------"
<< LL_ENDL;
@@ -678,7 +678,7 @@ LLSD HttpCoroutineAdapter::postAndSuspend_(LLCore::HttpRequest::ptr_t &request,
// pointer from the smart pointer is safe in this case.
LLCore::HttpHandle hhandle = requestPostWithLLSD(request,
mPolicyId, mPriority, url, body, options, headers,
- handler.get());
+ handler);
if (hhandle == LLCORE_HTTP_HANDLE_INVALID)
{
@@ -801,7 +801,7 @@ LLSD HttpCoroutineAdapter::postAndSuspend_(LLCore::HttpRequest::ptr_t &request,
// The HTTPCoroHandler does not self delete, so retrieval of a the contained
// pointer from the smart pointer is safe in this case.
LLCore::HttpHandle hhandle = request->requestPost(mPolicyId, mPriority, url, rawbody.get(),
- options, headers, handler.get());
+ options, headers, handler);
if (hhandle == LLCORE_HTTP_HANDLE_INVALID)
{
@@ -859,7 +859,7 @@ LLSD HttpCoroutineAdapter::putAndSuspend_(LLCore::HttpRequest::ptr_t &request,
// pointer from the smart pointer is safe in this case.
LLCore::HttpHandle hhandle = requestPutWithLLSD(request,
mPolicyId, mPriority, url, body, options, headers,
- handler.get());
+ handler);
if (hhandle == LLCORE_HTTP_HANDLE_INVALID)
{
@@ -885,7 +885,7 @@ LLSD HttpCoroutineAdapter::putAndSuspend_(LLCore::HttpRequest::ptr_t &request,
// The HTTPCoroHandler does not self delete, so retrieval of a the contained
// pointer from the smart pointer is safe in this case.
LLCore::HttpHandle hhandle = request->requestPut(mPolicyId, mPriority,
- url, rawbody.get(), options, headers, handler.get());
+ url, rawbody.get(), options, headers, handler);
if (hhandle == LLCORE_HTTP_HANDLE_INVALID)
{
@@ -941,7 +941,7 @@ LLSD HttpCoroutineAdapter::getAndSuspend_(LLCore::HttpRequest::ptr_t &request,
// The HTTPCoroHandler does not self delete, so retrieval of a the contained
// pointer from the smart pointer is safe in this case.
LLCore::HttpHandle hhandle = request->requestGet(mPolicyId, mPriority,
- url, options, headers, handler.get());
+ url, options, headers, handler);
if (hhandle == LLCORE_HTTP_HANDLE_INVALID)
{
@@ -987,7 +987,7 @@ LLSD HttpCoroutineAdapter::deleteAndSuspend_(LLCore::HttpRequest::ptr_t &request
// The HTTPCoroHandler does not self delete, so retrieval of a the contained
// pointer from the smart pointer is safe in this case.
LLCore::HttpHandle hhandle = request->requestDelete(mPolicyId, mPriority,
- url, options, headers, handler.get());
+ url, options, headers, handler);
if (hhandle == LLCORE_HTTP_HANDLE_INVALID)
{
@@ -1025,7 +1025,7 @@ LLSD HttpCoroutineAdapter::patchAndSuspend_(LLCore::HttpRequest::ptr_t &request,
// pointer from the smart pointer is safe in this case.
LLCore::HttpHandle hhandle = requestPatchWithLLSD(request,
mPolicyId, mPriority, url, body, options, headers,
- handler.get());
+ handler);
if (hhandle == LLCORE_HTTP_HANDLE_INVALID)
{
@@ -1067,7 +1067,7 @@ LLSD HttpCoroutineAdapter::copyAndSuspend_(LLCore::HttpRequest::ptr_t &request,
// pointer from the smart pointer is safe in this case.
//
LLCore::HttpHandle hhandle = request->requestCopy(mPolicyId, mPriority, url,
- options, headers, handler.get());
+ options, headers, handler);
if (hhandle == LLCORE_HTTP_HANDLE_INVALID)
{
@@ -1109,7 +1109,7 @@ LLSD HttpCoroutineAdapter::moveAndSuspend_(LLCore::HttpRequest::ptr_t &request,
// pointer from the smart pointer is safe in this case.
//
LLCore::HttpHandle hhandle = request->requestMove(mPolicyId, mPriority, url,
- options, headers, handler.get());
+ options, headers, handler);
if (hhandle == LLCORE_HTTP_HANDLE_INVALID)
{
@@ -1152,7 +1152,7 @@ void HttpCoroutineAdapter::cancelSuspendedOperation()
{
cleanState();
LL_INFOS() << "Canceling yielding request!" << LL_ENDL;
- request->requestCancel(mYieldingHandle, handler.get());
+ request->requestCancel(mYieldingHandle, handler);
}
}
diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h
index 6460155134..0ec17cda07 100644
--- a/indra/llmessage/llcorehttputil.h
+++ b/indra/llmessage/llcorehttputil.h
@@ -114,7 +114,7 @@ LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest * request,
const LLSD & body,
const LLCore::HttpOptions::ptr_t &options,
const LLCore::HttpHeaders::ptr_t &headers,
- LLCore::HttpHandler * handler);
+ const LLCore::HttpHandler::ptr_t &handler);
inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & request,
LLCore::HttpRequest::policy_t policy_id,
@@ -123,7 +123,7 @@ inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & reque
const LLSD & body,
const LLCore::HttpOptions::ptr_t & options,
const LLCore::HttpHeaders::ptr_t & headers,
- LLCore::HttpHandler * handler)
+ const LLCore::HttpHandler::ptr_t & handler)
{
return requestPostWithLLSD(request.get(), policy_id, priority,
url, body, options, headers, handler);
@@ -134,7 +134,7 @@ inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & reque
LLCore::HttpRequest::priority_t priority,
const std::string & url,
const LLSD & body,
- LLCore::HttpHandler * handler)
+ const LLCore::HttpHandler::ptr_t &handler)
{
LLCore::HttpOptions::ptr_t options;
LLCore::HttpHeaders::ptr_t headers;
@@ -167,7 +167,7 @@ LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest * request,
const LLSD & body,
const LLCore::HttpOptions::ptr_t &options,
const LLCore::HttpHeaders::ptr_t &headers,
- LLCore::HttpHandler * handler);
+ const LLCore::HttpHandler::ptr_t &handler);
inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & request,
LLCore::HttpRequest::policy_t policy_id,
@@ -176,7 +176,7 @@ inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & reques
const LLSD & body,
const LLCore::HttpOptions::ptr_t & options,
const LLCore::HttpHeaders::ptr_t & headers,
- LLCore::HttpHandler * handler)
+ LLCore::HttpHandler::ptr_t handler)
{
return requestPutWithLLSD(request.get(), policy_id, priority,
url, body, options, headers, handler);
@@ -187,7 +187,7 @@ inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & reques
LLCore::HttpRequest::priority_t priority,
const std::string & url,
const LLSD & body,
- LLCore::HttpHandler * handler)
+ LLCore::HttpHandler::ptr_t handler)
{
LLCore::HttpOptions::ptr_t options;
LLCore::HttpHeaders::ptr_t headers;
@@ -219,7 +219,7 @@ LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest * request,
const LLSD & body,
const LLCore::HttpOptions::ptr_t &options,
const LLCore::HttpHeaders::ptr_t &headers,
- LLCore::HttpHandler * handler);
+ const LLCore::HttpHandler::ptr_t &handler);
inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & request,
LLCore::HttpRequest::policy_t policy_id,
@@ -228,7 +228,7 @@ inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & requ
const LLSD & body,
const LLCore::HttpOptions::ptr_t & options,
const LLCore::HttpHeaders::ptr_t & headers,
- LLCore::HttpHandler * handler)
+ const LLCore::HttpHandler::ptr_t & handler)
{
return requestPatchWithLLSD(request.get(), policy_id, priority,
url, body, options, headers, handler);
@@ -239,7 +239,7 @@ inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & requ
LLCore::HttpRequest::priority_t priority,
const std::string & url,
const LLSD & body,
- LLCore::HttpHandler * handler)
+ const LLCore::HttpHandler::ptr_t &handler)
{
LLCore::HttpOptions::ptr_t options;
LLCore::HttpHeaders::ptr_t headers;
diff --git a/indra/llmessage/llhttpsdhandler.cpp b/indra/llmessage/llhttpsdhandler.cpp
index d99bdd3f66..648bc5cfd8 100644
--- a/indra/llmessage/llhttpsdhandler.cpp
+++ b/indra/llmessage/llhttpsdhandler.cpp
@@ -36,8 +36,7 @@
#include "llcorehttputil.h"
//========================================================================
-LLHttpSDHandler::LLHttpSDHandler(bool selfDelete):
- mSelfDelete(selfDelete)
+LLHttpSDHandler::LLHttpSDHandler()
{
}
@@ -75,31 +74,4 @@ void LLHttpSDHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespons
this->onSuccess(response, resplsd);
}
- // The handler must destroy itself when it is done.
- // *TODO: I'm not fond of this pattern. A class shooting itself in the head
- // outside of a smart pointer always makes me nervous.
- if (mSelfDelete)
- delete this;
-}
-
-//========================================================================
-LLHttpSDGenericHandler::LLHttpSDGenericHandler(const std::string &name, bool selfDelete):
- LLHttpSDHandler(selfDelete),
- mName(name)
-{
-}
-
-void LLHttpSDGenericHandler::onSuccess(LLCore::HttpResponse * response, const LLSD &content)
-{
- LL_DEBUGS() << mName << " Success." << LL_ENDL;
-}
-
-void LLHttpSDGenericHandler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status)
-{
- LL_WARNS()
- << "\n--------------------------------------------------------------------------\n"
- << mName << " Error[" << status.toULong() << "] cannot access cap with url '"
- << response->getRequestURL() << "' because " << status.toString()
- << "\n--------------------------------------------------------------------------"
- << LL_ENDL;
}
diff --git a/indra/llmessage/llhttpsdhandler.h b/indra/llmessage/llhttpsdhandler.h
index 3b81dc66b9..ce40bdfc08 100644
--- a/indra/llmessage/llhttpsdhandler.h
+++ b/indra/llmessage/llhttpsdhandler.h
@@ -44,29 +44,12 @@ public:
virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response);
protected:
- LLHttpSDHandler(bool selfDelete = true);
+ LLHttpSDHandler();
virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content) = 0;
virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) = 0;
-private:
- bool mSelfDelete;
};
-/// A trivial implementation of LLHttpSDHandler. This success and failure
-/// methods log the action taken, the URI accessed and the status code returned
-/// in the response.
-class LLHttpSDGenericHandler : public LLHttpSDHandler
-{
-public:
- LLHttpSDGenericHandler(const std::string &name, bool selfDelete = true);
-
-protected:
- virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content);
- virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status);
-
-private:
- std::string mName;
-};
#endif