From 6f4d36634e980bb989b9a8b762c3c622804c43dd Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 16 Mar 2015 17:14:34 -0700 Subject: Removal of RPCXML dep on LLCurl switching to LLCore::Html --- indra/llcorehttp/httprequest.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'indra/llcorehttp/httprequest.cpp') diff --git a/indra/llcorehttp/httprequest.cpp b/indra/llcorehttp/httprequest.cpp index 7b1888e3eb..5f1ed3d43b 100755 --- a/indra/llcorehttp/httprequest.cpp +++ b/indra/llcorehttp/httprequest.cpp @@ -117,6 +117,15 @@ HttpStatus HttpRequest::setStaticPolicyOption(EPolicyOption opt, policy_t pclass return HttpService::instanceOf()->setPolicyOption(opt, pclass, value, ret_value); } +HttpStatus HttpRequest::setStaticPolicyOption(EPolicyOption opt, policy_t pclass, policyCallback value, policyCallback * ret_value) +{ + if (HttpService::RUNNING == HttpService::instanceOf()->getState()) + { + return HttpStatus(HttpStatus::LLCORE, HE_OPT_NOT_DYNAMIC); + } + + return HttpService::instanceOf()->setPolicyOption(opt, pclass, value, ret_value); +} HttpHandle HttpRequest::setPolicyOption(EPolicyOption opt, policy_t pclass, long value, HttpHandler * handler) @@ -195,7 +204,7 @@ HttpHandle HttpRequest::requestGet(policy_t policy_id, HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(); + HttpOpRequest * op = new HttpOpRequest(this); if (! (status = op->setupGet(policy_id, priority, url, options, headers))) { op->release(); @@ -229,7 +238,7 @@ HttpHandle HttpRequest::requestGetByteRange(policy_t policy_id, HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(); + HttpOpRequest * op = new HttpOpRequest(this); if (! (status = op->setupGetByteRange(policy_id, priority, url, offset, len, options, headers))) { op->release(); @@ -262,7 +271,7 @@ HttpHandle HttpRequest::requestPost(policy_t policy_id, HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(); + HttpOpRequest * op = new HttpOpRequest(this); if (! (status = op->setupPost(policy_id, priority, url, body, options, headers))) { op->release(); @@ -295,7 +304,7 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id, HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(); + HttpOpRequest * op = new HttpOpRequest(this); if (! (status = op->setupPut(policy_id, priority, url, body, options, headers))) { op->release(); -- cgit v1.3 From 735364038767694ea29d9b6a168410e6482cc9c2 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 27 Mar 2015 17:00:02 -0700 Subject: first set of chnages from code review from Nat --- indra/llcorehttp/_httpoprequest.cpp | 10 +- indra/llcorehttp/_httpoprequest.h | 5 +- indra/llcorehttp/_httppolicyglobal.cpp | 4 +- indra/llcorehttp/_httppolicyglobal.h | 6 +- indra/llcorehttp/_httpservice.cpp | 4 +- indra/llcorehttp/_httpservice.h | 6 +- indra/llcorehttp/httpcommon.h | 75 +++++++------- indra/llcorehttp/httpoptions.cpp | 8 +- indra/llcorehttp/httpoptions.h | 90 ++++++++++------- indra/llcorehttp/httprequest.cpp | 10 +- indra/llcorehttp/httprequest.h | 4 +- indra/llmessage/llhttpsdhandler.cpp | 2 +- indra/llmessage/llhttpsdhandler.h | 4 +- indra/newview/llagent.cpp | 11 ++- indra/newview/llagent.h | 4 +- indra/newview/llagentlanguage.cpp | 2 +- indra/newview/llappcorehttp.cpp | 2 +- indra/newview/llappearancemgr.cpp | 6 +- indra/newview/llavatarrenderinfoaccountant.cpp | 131 ++++++++++++++++++++++++- indra/newview/llavatarrenderinfoaccountant.h | 10 +- indra/newview/llmaterialmgr.cpp | 4 +- 21 files changed, 271 insertions(+), 127 deletions(-) (limited to 'indra/llcorehttp/httprequest.cpp') diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 48e22468cd..5768fe5a90 100755 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -115,9 +115,8 @@ namespace LLCore { -HttpOpRequest::HttpOpRequest(HttpRequest const * const request) +HttpOpRequest::HttpOpRequest() : HttpOperation(), - mRequest(request), mProcFlags(0U), mReqMethod(HOR_GET), mReqBody(NULL), @@ -490,13 +489,13 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) long follow_redirect(1L); long sslPeerV(0L); long sslHostV(0L); - long dnsCacheTimeout(15L); + long dnsCacheTimeout(-1L); if (mReqOptions) { follow_redirect = mReqOptions->getFollowRedirects() ? 1L : 0L; - sslPeerV = mReqOptions->getSSLVerifyHost() ? 0L : 1L; - sslHostV = mReqOptions->getSSLVerifyHost(); + sslPeerV = mReqOptions->getSSLVerifyPeer() ? 1L : 0L; + sslHostV = mReqOptions->getSSLVerifyHost() ? 2L : 0L; dnsCacheTimeout = mReqOptions->getDNSCacheTimeout(); } code = curl_easy_setopt(mCurlHandle, CURLOPT_FOLLOWLOCATION, follow_redirect); @@ -516,7 +515,6 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) code = curl_easy_setopt(mCurlHandle, CURLOPT_DNS_CACHE_TIMEOUT, dnsCacheTimeout); check_curl_easy_code(code, CURLOPT_DNS_CACHE_TIMEOUT); - if (gpolicy.mUseLLProxy) { // Use the viewer-based thread-safe API which has a diff --git a/indra/llcorehttp/_httpoprequest.h b/indra/llcorehttp/_httpoprequest.h index 7a4b7c189e..e71d1d1edf 100755 --- a/indra/llcorehttp/_httpoprequest.h +++ b/indra/llcorehttp/_httpoprequest.h @@ -66,7 +66,7 @@ class HttpOptions; class HttpOpRequest : public HttpOperation { public: - HttpOpRequest(HttpRequest const * const request); + HttpOpRequest(); protected: virtual ~HttpOpRequest(); // Use release() @@ -165,11 +165,10 @@ protected: static const unsigned int PF_SAVE_HEADERS = 0x00000002U; static const unsigned int PF_USE_RETRY_AFTER = 0x00000004U; - HttpRequest::policyCallback mCallbackSSLVerify; + HttpRequest::policyCallback_t mCallbackSSLVerify; public: // Request data - HttpRequest const * const mRequest; EMethod mReqMethod; std::string mReqURL; BufferArray * mReqBody; diff --git a/indra/llcorehttp/_httppolicyglobal.cpp b/indra/llcorehttp/_httppolicyglobal.cpp index c4ef38a815..3d0df96ade 100755 --- a/indra/llcorehttp/_httppolicyglobal.cpp +++ b/indra/llcorehttp/_httppolicyglobal.cpp @@ -106,7 +106,7 @@ HttpStatus HttpPolicyGlobal::set(HttpRequest::EPolicyOption opt, const std::stri return HttpStatus(); } -HttpStatus HttpPolicyGlobal::set(HttpRequest::EPolicyOption opt, HttpRequest::policyCallback value) +HttpStatus HttpPolicyGlobal::set(HttpRequest::EPolicyOption opt, HttpRequest::policyCallback_t value) { switch (opt) { @@ -169,7 +169,7 @@ HttpStatus HttpPolicyGlobal::get(HttpRequest::EPolicyOption opt, std::string * v } -HttpStatus HttpPolicyGlobal::get(HttpRequest::EPolicyOption opt, HttpRequest::policyCallback * value) const +HttpStatus HttpPolicyGlobal::get(HttpRequest::EPolicyOption opt, HttpRequest::policyCallback_t * value) const { switch (opt) { diff --git a/indra/llcorehttp/_httppolicyglobal.h b/indra/llcorehttp/_httppolicyglobal.h index 1696238814..e02da4386a 100755 --- a/indra/llcorehttp/_httppolicyglobal.h +++ b/indra/llcorehttp/_httppolicyglobal.h @@ -60,10 +60,10 @@ private: public: HttpStatus set(HttpRequest::EPolicyOption opt, long value); HttpStatus set(HttpRequest::EPolicyOption opt, const std::string & value); - HttpStatus set(HttpRequest::EPolicyOption opt, HttpRequest::policyCallback value); + HttpStatus set(HttpRequest::EPolicyOption opt, HttpRequest::policyCallback_t value); HttpStatus get(HttpRequest::EPolicyOption opt, long * value) const; HttpStatus get(HttpRequest::EPolicyOption opt, std::string * value) const; - HttpStatus get(HttpRequest::EPolicyOption opt, HttpRequest::policyCallback * value) const; + HttpStatus get(HttpRequest::EPolicyOption opt, HttpRequest::policyCallback_t * value) const; public: long mConnectionLimit; @@ -72,7 +72,7 @@ public: std::string mHttpProxy; long mTrace; long mUseLLProxy; - HttpRequest::policyCallback mSslCtxCallback; + HttpRequest::policyCallback_t mSslCtxCallback; }; // end class HttpPolicyGlobal } // end namespace LLCore diff --git a/indra/llcorehttp/_httpservice.cpp b/indra/llcorehttp/_httpservice.cpp index 7b8aac35a8..252db78c89 100755 --- a/indra/llcorehttp/_httpservice.cpp +++ b/indra/llcorehttp/_httpservice.cpp @@ -415,7 +415,7 @@ HttpStatus HttpService::getPolicyOption(HttpRequest::EPolicyOption opt, HttpRequ } HttpStatus HttpService::getPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t pclass, - HttpRequest::policyCallback * ret_value) + HttpRequest::policyCallback_t * ret_value) { HttpStatus status(HttpStatus::LLCORE, LLCore::HE_INVALID_ARG); @@ -520,7 +520,7 @@ HttpStatus HttpService::setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequ } HttpStatus HttpService::setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t pclass, - HttpRequest::policyCallback value, HttpRequest::policyCallback * ret_value) + HttpRequest::policyCallback_t value, HttpRequest::policyCallback_t * ret_value) { HttpStatus status(HttpStatus::LLCORE, LLCore::HE_INVALID_ARG); diff --git a/indra/llcorehttp/_httpservice.h b/indra/llcorehttp/_httpservice.h index 699a8eaa4f..ac518a5de7 100755 --- a/indra/llcorehttp/_httpservice.h +++ b/indra/llcorehttp/_httpservice.h @@ -209,15 +209,15 @@ protected: HttpStatus getPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t, std::string * ret_value); HttpStatus getPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t, - HttpRequest::policyCallback * ret_value); + HttpRequest::policyCallback_t * ret_value); HttpStatus setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t, long value, long * ret_value); HttpStatus setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t, const std::string & value, std::string * ret_value); HttpStatus setPolicyOption(HttpRequest::EPolicyOption opt, HttpRequest::policy_t, - HttpRequest::policyCallback value, - HttpRequest::policyCallback * ret_value); + HttpRequest::policyCallback_t value, + HttpRequest::policyCallback_t * ret_value); protected: static const OptionDescriptor sOptionDesc[HttpRequest::PO_LAST]; diff --git a/indra/llcorehttp/httpcommon.h b/indra/llcorehttp/httpcommon.h index 64075f5f20..ada5c1bbe7 100755 --- a/indra/llcorehttp/httpcommon.h +++ b/indra/llcorehttp/httpcommon.h @@ -190,6 +190,7 @@ #include "linden_common.h" // Modifies curl/curl.h interfaces #include "boost/intrusive_ptr.hpp" #include "boost/shared_ptr.hpp" +#include "boost/function.hpp" #include namespace LLCore @@ -294,50 +295,50 @@ struct HttpStatus typedef unsigned short type_enum_t; HttpStatus() - { - mDetails = new Details(LLCORE, HE_SUCCESS); - } + { + mDetails = boost::shared_ptr
(new Details(LLCORE, HE_SUCCESS)); + } HttpStatus(type_enum_t type, short status) - { - mDetails = new Details(type, status); - } + { + mDetails = boost::shared_ptr
(new Details(type, status)); + } HttpStatus(int http_status) - { - mDetails = new Details(http_status, - (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR); - llassert(http_status >= 100 && http_status <= 999); - } + { + mDetails = boost::shared_ptr
(new Details(http_status, + (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR)); + llassert(http_status >= 100 && http_status <= 999); + } HttpStatus(int http_status, const std::string &message) - { - mDetails = new Details(http_status, - (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR); - llassert(http_status >= 100 && http_status <= 999); - mDetails->mMessage = message; - } + { + mDetails = boost::shared_ptr
(new Details(http_status, + (http_status >= 200 && http_status <= 299) ? HE_SUCCESS : HE_REPLY_ERROR)); + llassert(http_status >= 100 && http_status <= 999); + mDetails->mMessage = message; + } HttpStatus(const HttpStatus & rhs) - { - mDetails = new Details(*rhs.mDetails); - } + { + mDetails = rhs.mDetails; + } ~HttpStatus() - { - delete mDetails; - } + { + } HttpStatus & operator=(const HttpStatus & rhs) - { - // Don't care if lhs & rhs are the same object - mDetails->mType = rhs.mDetails->mType; - mDetails->mStatus = rhs.mDetails->mStatus; - mDetails->mMessage = rhs.mDetails->mMessage; - mDetails->mErrorData = rhs.mDetails->mErrorData; - - return *this; - } + { + mDetails = rhs.mDetails; + return *this; + } + + HttpStatus & clone(const HttpStatus &rhs) + { + mDetails = boost::shared_ptr
(new Details(*rhs.mDetails)); + return *this; + } static const type_enum_t EXT_CURL_EASY = 0; ///< mStatus is an error from a curl_easy_*() call static const type_enum_t EXT_CURL_MULTI = 1; ///< mStatus is an error from a curl_multi_*() call @@ -365,8 +366,7 @@ struct HttpStatus /// which will do the wrong thing in conditional expressions. bool operator==(const HttpStatus & rhs) const { - return (mDetails->mType == rhs.mDetails->mType) && - (mDetails->mStatus == rhs.mDetails->mStatus); + return (*mDetails == *rhs.mDetails); } bool operator!=(const HttpStatus & rhs) const @@ -474,6 +474,10 @@ private: mErrorData(rhs.mErrorData) {} + bool operator == (const Details &rhs) const + { + return (mType == rhs.mType) && (mStatus == rhs.mStatus); + } type_enum_t mType; short mStatus; @@ -481,8 +485,7 @@ private: void * mErrorData; }; - //boost::unique_ptr
mDetails; - Details * mDetails; + boost::shared_ptr
mDetails; }; // end struct HttpStatus diff --git a/indra/llcorehttp/httpoptions.cpp b/indra/llcorehttp/httpoptions.cpp index 28c2c25e92..a4d08a80df 100755 --- a/indra/llcorehttp/httpoptions.cpp +++ b/indra/llcorehttp/httpoptions.cpp @@ -42,8 +42,8 @@ HttpOptions::HttpOptions() : RefCounted(true), mUseRetryAfter(HTTP_USE_RETRY_AFTER_DEFAULT), mFollowRedirects(false), mVerifyPeer(false), - mVerifyHost(0), - mDNSCacheTimeout(15) + mVerifyHost(false), + mDNSCacheTimeout(-1L) {} @@ -95,9 +95,9 @@ void HttpOptions::setSSLVerifyPeer(bool verify) mVerifyPeer = verify; } -void HttpOptions::setSSLVerifyHost(unsigned int type) +void HttpOptions::setSSLVerifyHost(bool verify) { - mVerifyHost = llclamp(type, 0, 2); + mVerifyHost = verify; } void HttpOptions::setDNSCacheTimeout(int timeout) diff --git a/indra/llcorehttp/httpoptions.h b/indra/llcorehttp/httpoptions.h index 3b9ad9598b..765d2431bb 100755 --- a/indra/llcorehttp/httpoptions.h +++ b/indra/llcorehttp/httpoptions.h @@ -69,72 +69,86 @@ protected: void operator=(const HttpOptions &); // Not defined public: + // Default: false void setWantHeaders(bool wanted); bool getWantHeaders() const - { - return mWantHeaders; - } + { + return mWantHeaders; + } // Default: 0 void setTrace(int long); int getTrace() const - { - return mTracing; - } + { + return mTracing; + } // Default: 30 void setTimeout(unsigned int timeout); unsigned int getTimeout() const - { - return mTimeout; - } + { + return mTimeout; + } // Default: 0 void setTransferTimeout(unsigned int timeout); unsigned int getTransferTimeout() const - { - return mTransferTimeout; - } + { + return mTransferTimeout; + } + /// Sets the number of retries on an LLCore::HTTPRequest before the + /// request fails. // Default: 8 void setRetries(unsigned int retries); unsigned int getRetries() const - { - return mRetries; - } + { + return mRetries; + } // Default: true void setUseRetryAfter(bool use_retry); bool getUseRetryAfter() const - { - return mUseRetryAfter; - } + { + return mUseRetryAfter; + } - // Default: false + /// Instructs the LLCore::HTTPRequest to follow redirects + /// Default: false void setFollowRedirects(bool follow_redirect); bool getFollowRedirects() const - { - return mFollowRedirects; - } - - void setSSLVerifyPeer(bool verify); + { + return mFollowRedirects; + } + + /// Instructs the LLCore::HTTPRequest to verify that the exchanged security + /// certificate is authentic. + /// Default: false + void setSSLVerifyPeer(bool verify); bool getSSLVerifyPeer() const - { - return mVerifyPeer; - } - - void setSSLVerifyHost(unsigned int type); - unsigned int getSSLVerifyHost() const - { - return mVerifyHost; - } - + { + return mVerifyPeer; + } + + /// Instructs the LLCore::HTTPRequest to verify that the name in the + /// security certificate matches the name of the host contacted. + /// Default: false + void setSSLVerifyHost(bool verify); + bool getSSLVerifyHost() const + { + return mVerifyHost; + } + + /// Sets the time for DNS name caching in seconds. Setting this value + /// to 0 will disable name caching. Setting this value to -1 causes the + /// name cache to never time out. + /// Default: -1 void setDNSCacheTimeout(int timeout); int getDNSCacheTimeout() const - { - return mDNSCacheTimeout; - } + { + return mDNSCacheTimeout; + } protected: bool mWantHeaders; @@ -145,7 +159,7 @@ protected: bool mUseRetryAfter; bool mFollowRedirects; bool mVerifyPeer; - unsigned int mVerifyHost; + bool mVerifyHost; int mDNSCacheTimeout; }; // end class HttpOptions diff --git a/indra/llcorehttp/httprequest.cpp b/indra/llcorehttp/httprequest.cpp index 5f1ed3d43b..df8502b947 100755 --- a/indra/llcorehttp/httprequest.cpp +++ b/indra/llcorehttp/httprequest.cpp @@ -117,7 +117,7 @@ HttpStatus HttpRequest::setStaticPolicyOption(EPolicyOption opt, policy_t pclass return HttpService::instanceOf()->setPolicyOption(opt, pclass, value, ret_value); } -HttpStatus HttpRequest::setStaticPolicyOption(EPolicyOption opt, policy_t pclass, policyCallback value, policyCallback * ret_value) +HttpStatus HttpRequest::setStaticPolicyOption(EPolicyOption opt, policy_t pclass, policyCallback_t value, policyCallback_t * ret_value) { if (HttpService::RUNNING == HttpService::instanceOf()->getState()) { @@ -204,7 +204,7 @@ HttpHandle HttpRequest::requestGet(policy_t policy_id, HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(this); + HttpOpRequest * op = new HttpOpRequest(); if (! (status = op->setupGet(policy_id, priority, url, options, headers))) { op->release(); @@ -238,7 +238,7 @@ HttpHandle HttpRequest::requestGetByteRange(policy_t policy_id, HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(this); + HttpOpRequest * op = new HttpOpRequest(); if (! (status = op->setupGetByteRange(policy_id, priority, url, offset, len, options, headers))) { op->release(); @@ -271,7 +271,7 @@ HttpHandle HttpRequest::requestPost(policy_t policy_id, HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(this); + HttpOpRequest * op = new HttpOpRequest(); if (! (status = op->setupPost(policy_id, priority, url, body, options, headers))) { op->release(); @@ -304,7 +304,7 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id, HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(this); + HttpOpRequest * op = new HttpOpRequest(); if (! (status = op->setupPut(policy_id, priority, url, body, options, headers))) { op->release(); diff --git a/indra/llcorehttp/httprequest.h b/indra/llcorehttp/httprequest.h index 4cacb3a20b..f7ce82d412 100755 --- a/indra/llcorehttp/httprequest.h +++ b/indra/llcorehttp/httprequest.h @@ -237,7 +237,7 @@ public: /// Prototype for policy based callbacks. The callback methods will be executed /// on the worker thread so no modifications should be made to the HttpHandler object. - typedef HttpStatus(*policyCallback)(const std::string &, HttpHandler const * const, void *); + typedef boost::function policyCallback_t; /// Set a policy option for a global or class parameter at /// startup time (prior to thread start). @@ -255,7 +255,7 @@ public: static HttpStatus setStaticPolicyOption(EPolicyOption opt, policy_t pclass, const std::string & value, std::string * ret_value); static HttpStatus setStaticPolicyOption(EPolicyOption opt, policy_t pclass, - policyCallback value, policyCallback * ret_value);; + policyCallback_t value, policyCallback_t * ret_value);; /// Set a parameter on a class-based policy option. Calls /// made after the start of the servicing thread are diff --git a/indra/llmessage/llhttpsdhandler.cpp b/indra/llmessage/llhttpsdhandler.cpp index 0d385d6497..72ecfe77e2 100644 --- a/indra/llmessage/llhttpsdhandler.cpp +++ b/indra/llmessage/llhttpsdhandler.cpp @@ -89,7 +89,7 @@ LLHttpSDGenericHandler::LLHttpSDGenericHandler(const LLURI &uri, const std::stri { } -void LLHttpSDGenericHandler::onSuccess(LLCore::HttpResponse * response, LLSD &content) +void LLHttpSDGenericHandler::onSuccess(LLCore::HttpResponse * response, const LLSD &content) { LL_DEBUGS() << mCaps << " Success." << LL_ENDL; } diff --git a/indra/llmessage/llhttpsdhandler.h b/indra/llmessage/llhttpsdhandler.h index b3eb7d6145..a2598c9709 100644 --- a/indra/llmessage/llhttpsdhandler.h +++ b/indra/llmessage/llhttpsdhandler.h @@ -49,7 +49,7 @@ public: } protected: - virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content) = 0; + virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content) = 0; virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) = 0; private: @@ -65,7 +65,7 @@ public: LLHttpSDGenericHandler(const LLURI &uri, const std::string &action); protected: - virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content); + virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content); virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); private: diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 81387fb927..667d530e39 100755 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -2559,7 +2559,7 @@ public: { } protected: - virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content); + virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content); virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); private: @@ -2572,7 +2572,7 @@ private: }; //------------------------------------------------------------------------- -void LLMaturityHttpHandler::onSuccess(LLCore::HttpResponse * response, LLSD &content) +void LLMaturityHttpHandler::onSuccess(LLCore::HttpResponse * response, const LLSD &content) { U8 actualMaturity = parseMaturityFromServerResponse(content); @@ -2774,7 +2774,7 @@ void LLAgent::sendMaturityPreferenceToServer(U8 pPreferredMaturity) LL_INFOS() << "Sending viewer preferred maturity to '" << LLViewerRegion::accessToString(pPreferredMaturity) << "' via capability to: " << url << LL_ENDL; - LLCore::HttpHandle handle = requestPostCapibility("UpdateAgentInformation", url, postData, handler); + LLCore::HttpHandle handle = requestPostCapability("UpdateAgentInformation", url, postData, handler); if (handle == LLCORE_HTTP_HANDLE_INVALID) { @@ -2784,7 +2784,7 @@ void LLAgent::sendMaturityPreferenceToServer(U8 pPreferredMaturity) } } -LLCore::HttpHandle LLAgent::requestPostCapibility(const std::string &cap, const std::string &url, LLSD &postData, LLHttpSDHandler *usrhndlr) +LLCore::HttpHandle LLAgent::requestPostCapability(const std::string &cap, const std::string &url, LLSD &postData, LLHttpSDHandler *usrhndlr) { LLHttpSDHandler * handler = (usrhndlr) ? usrhndlr : new LLHttpSDGenericHandler(url, cap); LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, @@ -2793,6 +2793,9 @@ LLCore::HttpHandle LLAgent::requestPostCapibility(const std::string &cap, const if (handle == LLCORE_HTTP_HANDLE_INVALID) { + // If no handler was passed in we delete the handler default handler allocated + // at the start of this function. + // *TODO: Change this metaphore to use boost::shared_ptr<> for handlers. Requires change in LLCore::HTTP if (!usrhndlr) delete handler; LLCore::HttpStatus status = mHttpRequest->getStatus(); diff --git a/indra/newview/llagent.h b/indra/newview/llagent.h index 6b636a2dc0..26120b52f6 100755 --- a/indra/newview/llagent.h +++ b/indra/newview/llagent.h @@ -925,8 +925,8 @@ public: public: /// Utilities for allowing the the agent sub managers to post and get via /// HTTP using the agent's policy settings and headers. - LLCore::HttpHandle requestPostCapibility(const std::string &cap, const std::string &url, LLSD &postData, LLHttpSDHandler *usrhndlr = NULL); - //LLCore::HttpHandle httpGetCapibility(const std::string &cap, const LLURI &uri, LLHttpSDHandler *usrhndlr = NULL); + LLCore::HttpHandle requestPostCapability(const std::string &cap, const std::string &url, LLSD &postData, LLHttpSDHandler *usrhndlr = NULL); + //LLCore::HttpHandle httpGetCapability(const std::string &cap, const LLURI &uri, LLHttpSDHandler *usrhndlr = NULL); /** Utility ** ** diff --git a/indra/newview/llagentlanguage.cpp b/indra/newview/llagentlanguage.cpp index 81fce9b257..f2ac323578 100755 --- a/indra/newview/llagentlanguage.cpp +++ b/indra/newview/llagentlanguage.cpp @@ -71,7 +71,7 @@ bool LLAgentLanguage::update() body["language_is_public"] = gSavedSettings.getBOOL("LanguageIsPublic"); //LLHTTPClient::post(url, body, new LLHTTPClient::Responder); - LLCore::HttpHandle handle = gAgent.requestPostCapibility("UpdateAgentLanguage", url, body); + LLCore::HttpHandle handle = gAgent.requestPostCapability("UpdateAgentLanguage", url, body); if (handle == LLCORE_HTTP_HANDLE_INVALID) { LL_WARNS() << "Unable to change language." << LL_ENDL; diff --git a/indra/newview/llappcorehttp.cpp b/indra/newview/llappcorehttp.cpp index cd9166f7b7..51cca273d8 100755 --- a/indra/newview/llappcorehttp.cpp +++ b/indra/newview/llappcorehttp.cpp @@ -494,7 +494,7 @@ LLCore::HttpStatus LLAppCoreHttp::sslVerify(const std::string &url, validation_params[CERT_HOSTNAME] = uri.hostName(); - // *TODO*: In the case of an exception while validating the cert, we need a way + // *TODO: In the case of an exception while validating the cert, we need a way // to pass the offending(?) cert back out. *Rider* try diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index be71c430f4..709d9881e1 100755 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -1260,7 +1260,7 @@ public: virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); protected: - virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content); + virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content); virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); private: @@ -1278,7 +1278,7 @@ void LLAppearanceMgrHttpHandler::onCompleted(LLCore::HttpHandle handle, LLCore:: LLHttpSDHandler::onCompleted(handle, response); } -void LLAppearanceMgrHttpHandler::onSuccess(LLCore::HttpResponse * response, LLSD &content) +void LLAppearanceMgrHttpHandler::onSuccess(LLCore::HttpResponse * response, const LLSD &content) { if (!content.isMap()) { @@ -3443,7 +3443,7 @@ void LLAppearanceMgr::requestServerAppearanceUpdate() gAgentAvatarp->mLastUpdateRequestCOFVersion = cof_version; - LLCore::HttpHandle handle = gAgent.requestPostCapibility("UpdateAvatarAppearance", url, postData, handler); + LLCore::HttpHandle handle = gAgent.requestPostCapability("UpdateAvatarAppearance", url, postData, handler); if (handle == LLCORE_HTTP_HANDLE_INVALID) { diff --git a/indra/newview/llavatarrenderinfoaccountant.cpp b/indra/newview/llavatarrenderinfoaccountant.cpp index 38e153137c..aeaa832bc7 100644 --- a/indra/newview/llavatarrenderinfoaccountant.cpp +++ b/indra/newview/llavatarrenderinfoaccountant.cpp @@ -43,7 +43,9 @@ #include "llviewerregion.h" #include "llvoavatar.h" #include "llworld.h" - +#include "llhttpsdhandler.h" +#include "httpheaders.h" +#include "httpoptions.h" static const std::string KEY_AGENTS = "agents"; // map static const std::string KEY_WEIGHT = "weight"; // integer @@ -55,8 +57,113 @@ static const std::string KEY_ERROR = "error"; // Send data updates about once per minute, only need per-frame resolution LLFrameTimer LLAvatarRenderInfoAccountant::sRenderInfoReportTimer; +//LLCore::HttpRequest::ptr_t LLAvatarRenderInfoAccountant::sHttpRequest; + +#if 0 +//========================================================================= +class LLAvatarRenderInfoHandler : public LLHttpSDHandler +{ +public: + LLAvatarRenderInfoHandler(const LLURI &uri, U64 regionHandle); + +protected: + virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content); + virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); + +private: + U64 mRegionHandle; +}; + +LLAvatarRenderInfoHandler::LLAvatarRenderInfoHandler(const LLURI &uri, U64 regionHandle) : + LLHttpSDHandler(uri), + mRegionHandle(regionHandle) +{ +} + +void LLAvatarRenderInfoHandler::onSuccess(LLCore::HttpResponse * response, LLSD &content) +{ + LLViewerRegion * regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle); + if (regionp) + { + if (LLAvatarRenderInfoAccountant::logRenderInfo()) + { + LL_INFOS() << "LRI: Result for avatar weights request for region " << regionp->getName() << ":" << LL_ENDL; + } + + if (content.isMap()) + { + if (content.has(KEY_AGENTS)) + { + const LLSD & agents = content[KEY_AGENTS]; + if (agents.isMap()) + { + LLSD::map_const_iterator report_iter = agents.beginMap(); + while (report_iter != agents.endMap()) + { + LLUUID target_agent_id = LLUUID(report_iter->first); + const LLSD & agent_info_map = report_iter->second; + LLViewerObject* avatarp = gObjectList.findObject(target_agent_id); + if (avatarp && + avatarp->isAvatar() && + agent_info_map.isMap()) + { // Extract the data for this avatar + + if (LLAvatarRenderInfoAccountant::logRenderInfo()) + { + LL_INFOS() << "LRI: Agent " << target_agent_id + << ": " << agent_info_map << LL_ENDL; + } + + if (agent_info_map.has(KEY_WEIGHT)) + { + ((LLVOAvatar *)avatarp)->setReportedVisualComplexity(agent_info_map[KEY_WEIGHT].asInteger()); + } + } + report_iter++; + } + } + } // has "agents" + else if (content.has(KEY_ERROR)) + { + const LLSD & error = content[KEY_ERROR]; + LL_WARNS() << "Avatar render info GET error: " + << error[KEY_IDENTIFIER] + << ": " << error[KEY_MESSAGE] + << " from region " << regionp->getName() + << LL_ENDL; + } + } + } + else + { + LL_INFOS() << "Avatar render weight info received but region not found for " + << mRegionHandle << LL_ENDL; + } +} +void LLAvatarRenderInfoHandler::onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status) +{ + LLViewerRegion * regionp = LLWorld::getInstance()->getRegionFromHandle(mRegionHandle); + if (regionp) + { + LL_WARNS() << "HTTP error result for avatar weight GET: " << status.toULong() + << ", " << status.toString() + << " returned by region " << regionp->getName() + << LL_ENDL; + } + else + { + LL_WARNS() << "Avatar render weight GET error received but region not found for " + << mRegionHandle + << ", error " << status.toULong() + << ", " << status.toString() + << LL_ENDL; + } +} + +//------------------------------------------------------------------------- +#else // HTTP responder class for GET request for avatar render weight information class LLAvatarRenderInfoGetResponder : public LLHTTPClient::Responder { @@ -142,7 +249,7 @@ public: } else { - LL_INFOS() << "Avatar render weight info recieved but region not found for " + LL_INFOS() << "Avatar render weight info received but region not found for " << mRegionHandle << LL_ENDL; } } @@ -150,7 +257,7 @@ public: private: U64 mRegionHandle; }; - +#endif // HTTP responder class for POST request for avatar render weight information class LLAvatarRenderInfoPostResponder : public LLHTTPClient::Responder @@ -172,7 +279,7 @@ public: } else { - LL_WARNS() << "Avatar render weight POST error recieved but region not found for " + LL_WARNS() << "Avatar render weight POST error received but region not found for " << mRegionHandle << ", error " << statusNum << ", " << reason @@ -215,7 +322,6 @@ private: U64 mRegionHandle; }; - // static // Send request for one region, no timer checks void LLAvatarRenderInfoAccountant::sendRenderInfoToRegion(LLViewerRegion * regionp) @@ -292,7 +398,19 @@ void LLAvatarRenderInfoAccountant::getRenderInfoFromRegion(LLViewerRegion * regi } // First send a request to get the latest data +#if 0 + if (!LLAvatarRenderInfoAccountant::sHttpRequest) + sHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); + LLAppCoreHttp & app_core_http(LLAppViewer::instance()->getAppCoreHttp()); + + LLCore::HttpHeaders::ptr_t httpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders(), false); + LLCore::HttpOptions::ptr_t httpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions(), false); + LLCore::HttpRequest::policy_t httpPolicy = app_core_http.getPolicy(LLAppCoreHttp::AP_AGENT); + + LLCore::HttpHandle handle = sHttpRequest-> +#else LLHTTPClient::get(url, new LLAvatarRenderInfoGetResponder(regionp->getHandle())); +#endif } } @@ -301,6 +419,9 @@ void LLAvatarRenderInfoAccountant::getRenderInfoFromRegion(LLViewerRegion * regi // Called every frame - send render weight requests to every region void LLAvatarRenderInfoAccountant::idle() { +// if (!LLAvatarRenderInfoAccountant::sHttpRequest) +// sHttpRequest = LLCore::HttpRequest::ptr_t(new LLCore::HttpRequest()); + if (sRenderInfoReportTimer.hasExpired()) { const F32 SECS_BETWEEN_REGION_SCANS = 5.f; // Scan the region list every 5 seconds diff --git a/indra/newview/llavatarrenderinfoaccountant.h b/indra/newview/llavatarrenderinfoaccountant.h index d68f2dccfb..13054f5e2f 100644 --- a/indra/newview/llavatarrenderinfoaccountant.h +++ b/indra/newview/llavatarrenderinfoaccountant.h @@ -29,6 +29,8 @@ #if ! defined(LL_llavatarrenderinfoaccountant_H) #define LL_llavatarrenderinfoaccountant_H +#include "httpcommon.h" + class LLViewerRegion; // Class to gather avatar rendering information @@ -36,8 +38,6 @@ class LLViewerRegion; class LLAvatarRenderInfoAccountant { public: - LLAvatarRenderInfoAccountant() {}; - ~LLAvatarRenderInfoAccountant() {}; static void sendRenderInfoToRegion(LLViewerRegion * regionp); static void getRenderInfoFromRegion(LLViewerRegion * regionp); @@ -49,8 +49,14 @@ public: static bool logRenderInfo(); private: + LLAvatarRenderInfoAccountant() {}; + ~LLAvatarRenderInfoAccountant() {}; + // Send data updates about once per minute, only need per-frame resolution static LLFrameTimer sRenderInfoReportTimer; + +// static LLCore::HttpRequest::ptr_t sHttpRequest; + }; #endif /* ! defined(LL_llavatarrenderinfoaccountant_H) */ diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 065d763596..78fbe9af0a 100755 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -75,7 +75,7 @@ public: virtual ~LLMaterialHttpHandler(); protected: - virtual void onSuccess(LLCore::HttpResponse * response, LLSD &content); + virtual void onSuccess(LLCore::HttpResponse * response, const LLSD &content); virtual void onFailure(LLCore::HttpResponse * response, LLCore::HttpStatus status); private: @@ -95,7 +95,7 @@ LLMaterialHttpHandler::~LLMaterialHttpHandler() { } -void LLMaterialHttpHandler::onSuccess(LLCore::HttpResponse * response, LLSD &content) +void LLMaterialHttpHandler::onSuccess(LLCore::HttpResponse * response, const LLSD &content) { LL_DEBUGS("Materials") << LL_ENDL; mCallback(true, content); -- cgit v1.3 From d0c85b6dd964164b6d92103ad65b5cd859197de2 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 10 Apr 2015 17:23:58 -0700 Subject: Adding support for DELETE, PATCH and COPY --- indra/llcorehttp/_httpoprequest.cpp | 68 +++++++++++++++++++++++---- indra/llcorehttp/_httpoprequest.h | 26 +++++++++- indra/llcorehttp/httprequest.cpp | 94 +++++++++++++++++++++++++++++++++++++ indra/llcorehttp/httprequest.h | 63 ++++++++++++++++++++++++- indra/llmessage/llcorehttputil.cpp | 40 ++++++++++++++++ indra/llmessage/llcorehttputil.h | 35 ++++++++++++++ 6 files changed, 315 insertions(+), 11 deletions(-) (limited to 'indra/llcorehttp/httprequest.cpp') diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 7c2309b31d..b1b05dc285 100755 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -357,6 +357,46 @@ HttpStatus HttpOpRequest::setupPut(HttpRequest::policy_t policy_id, } +HttpStatus HttpOpRequest::setupDelete(HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + HttpOptions * options, + HttpHeaders * headers) +{ + setupCommon(policy_id, priority, url, NULL, options, headers); + mReqMethod = HOR_DELETE; + + return HttpStatus(); +} + + +HttpStatus HttpOpRequest::setupPatch(HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + BufferArray * body, + HttpOptions * options, + HttpHeaders * headers) +{ + setupCommon(policy_id, priority, url, body, options, headers); + mReqMethod = HOR_PATCH; + + return HttpStatus(); +} + + +HttpStatus HttpOpRequest::setupCopy(HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + HttpOptions * options, + HttpHeaders * headers) +{ + setupCommon(policy_id, priority, url, NULL, options, headers); + mReqMethod = HOR_COPY; + + return HttpStatus(); +} + + void HttpOpRequest::setupCommon(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, @@ -549,8 +589,6 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) case HOR_GET: code = curl_easy_setopt(mCurlHandle, CURLOPT_HTTPGET, 1); check_curl_easy_code(code, CURLOPT_HTTPGET); - mCurlHeaders = curl_slist_append(mCurlHeaders, "Connection: keep-alive"); - mCurlHeaders = curl_slist_append(mCurlHeaders, "Keep-alive: 300"); break; case HOR_POST: @@ -569,12 +607,14 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) code = curl_easy_setopt(mCurlHandle, CURLOPT_POSTFIELDSIZE, data_size); check_curl_easy_code(code, CURLOPT_POSTFIELDSIZE); mCurlHeaders = curl_slist_append(mCurlHeaders, "Expect:"); - mCurlHeaders = curl_slist_append(mCurlHeaders, "Connection: keep-alive"); - mCurlHeaders = curl_slist_append(mCurlHeaders, "Keep-alive: 300"); } break; - case HOR_PUT: + case HOR_PATCH: + code = curl_easy_setopt(mCurlHandle, CURLOPT_CUSTOMREQUEST, "PATCH"); + check_curl_easy_code(code, CURLOPT_CUSTOMREQUEST); + // fall through. The rest is the same as PUT + case HOR_PUT: { code = curl_easy_setopt(mCurlHandle, CURLOPT_UPLOAD, 1); check_curl_easy_code(code, CURLOPT_UPLOAD); @@ -588,12 +628,19 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) code = curl_easy_setopt(mCurlHandle, CURLOPT_POSTFIELDS, (void *) NULL); check_curl_easy_code(code, CURLOPT_POSTFIELDS); mCurlHeaders = curl_slist_append(mCurlHeaders, "Expect:"); - // *TODO: Should this be 'Keep-Alive' ? - mCurlHeaders = curl_slist_append(mCurlHeaders, "Connection: keep-alive"); - mCurlHeaders = curl_slist_append(mCurlHeaders, "Keep-alive: 300"); } break; + case HOR_DELETE: + code = curl_easy_setopt(mCurlHandle, CURLOPT_CUSTOMREQUEST, "DELETE"); + check_curl_easy_code(code, CURLOPT_CUSTOMREQUEST); + break; + + case HOR_COPY: + code = curl_easy_setopt(mCurlHandle, CURLOPT_CUSTOMREQUEST, "COPY"); + check_curl_easy_code(code, CURLOPT_CUSTOMREQUEST); + break; + default: LL_ERRS(LOG_CORE) << "Invalid HTTP method in request: " << int(mReqMethod) << ". Can't recover." @@ -601,6 +648,11 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) break; } + + // *TODO: Should this be 'Keep-Alive' ? + mCurlHeaders = curl_slist_append(mCurlHeaders, "Connection: keep-alive"); + mCurlHeaders = curl_slist_append(mCurlHeaders, "Keep-alive: 300"); + // Tracing if (mTracing >= HTTP_TRACE_CURL_HEADERS) { diff --git a/indra/llcorehttp/_httpoprequest.h b/indra/llcorehttp/_httpoprequest.h index e71d1d1edf..ca40898a81 100755 --- a/indra/llcorehttp/_httpoprequest.h +++ b/indra/llcorehttp/_httpoprequest.h @@ -80,7 +80,10 @@ public: { HOR_GET, HOR_POST, - HOR_PUT + HOR_PUT, + HOR_DELETE, + HOR_PATCH, + HOR_COPY }; virtual void stageFromRequest(HttpService *); @@ -126,7 +129,26 @@ public: HttpOptions * options, HttpHeaders * headers); - // Internal method used to setup the libcurl options for a request. + HttpStatus setupDelete(HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + HttpOptions * options, + HttpHeaders * headers); + + HttpStatus setupPatch(HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + BufferArray * body, + HttpOptions * options, + HttpHeaders * headers); + + HttpStatus setupCopy(HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + HttpOptions * options, + HttpHeaders * headers); + + // Internal method used to setup the libcurl options for a request. // Does all the libcurl handle setup in one place. // // Threading: called by worker thread diff --git a/indra/llcorehttp/httprequest.cpp b/indra/llcorehttp/httprequest.cpp index df8502b947..d4c60a6f14 100755 --- a/indra/llcorehttp/httprequest.cpp +++ b/indra/llcorehttp/httprequest.cpp @@ -325,6 +325,100 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id, return handle; } +HttpHandle HttpRequest::requestDelete(policy_t policy_id, + priority_t priority, + const std::string & url, + HttpOptions * options, + HttpHeaders * headers, + HttpHandler * user_handler) +{ + HttpStatus status; + HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); + + HttpOpRequest * op = new HttpOpRequest(); + if (!(status = op->setupDelete(policy_id, priority, url, options, headers))) + { + op->release(); + mLastReqStatus = status; + return handle; + } + op->setReplyPath(mReplyQueue, user_handler); + if (!(status = mRequestQueue->addOp(op))) // transfers refcount + { + op->release(); + mLastReqStatus = status; + return handle; + } + + mLastReqStatus = status; + handle = static_cast(op); + + return handle; +} + +HttpHandle HttpRequest::requestPatch(policy_t policy_id, + priority_t priority, + const std::string & url, + BufferArray * body, + HttpOptions * options, + HttpHeaders * headers, + HttpHandler * user_handler) +{ + HttpStatus status; + HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); + + HttpOpRequest * op = new HttpOpRequest(); + if (!(status = op->setupPatch(policy_id, priority, url, body, options, headers))) + { + op->release(); + mLastReqStatus = status; + return handle; + } + op->setReplyPath(mReplyQueue, user_handler); + if (!(status = mRequestQueue->addOp(op))) // transfers refcount + { + op->release(); + mLastReqStatus = status; + return handle; + } + + mLastReqStatus = status; + handle = static_cast(op); + + return handle; +} + +HttpHandle HttpRequest::requestCopy(policy_t policy_id, + priority_t priority, + const std::string & url, + HttpOptions * options, + HttpHeaders * headers, + HttpHandler * user_handler) +{ + HttpStatus status; + HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); + + HttpOpRequest * op = new HttpOpRequest(); + if (!(status = op->setupCopy(policy_id, priority, url, options, headers))) + { + op->release(); + mLastReqStatus = status; + return handle; + } + op->setReplyPath(mReplyQueue, user_handler); + if (!(status = mRequestQueue->addOp(op))) // transfers refcount + { + op->release(); + mLastReqStatus = status; + return handle; + } + + mLastReqStatus = status; + handle = static_cast(op); + + return handle; +} + HttpHandle HttpRequest::requestNoOp(HttpHandler * user_handler) { diff --git a/indra/llcorehttp/httprequest.h b/indra/llcorehttp/httprequest.h index 6688f06eb5..e87a8b691a 100755 --- a/indra/llcorehttp/httprequest.h +++ b/indra/llcorehttp/httprequest.h @@ -478,7 +478,68 @@ public: HttpHandler * handler); - /// Queue a NoOp request. + /// Queue a full HTTP PUT. Query arguments and body may + /// be provided. Caller is responsible for escaping and + /// encoding and communicating the content types. + /// + /// @param policy_id @see requestGet() + /// @param priority " + /// @param url " + /// @param options @see requestGet()K(optional) + /// @param headers " + /// @param handler " + /// @return " + /// + HttpHandle requestDelete(policy_t policy_id, + priority_t priority, + const std::string & url, + HttpOptions * options, + HttpHeaders * headers, + HttpHandler * user_handler); + + /// Queue a full HTTP PUT. Query arguments and body may + /// be provided. Caller is responsible for escaping and + /// encoding and communicating the content types. + /// + /// @param policy_id @see requestGet() + /// @param priority " + /// @param url " + /// @param body Byte stream to be sent as the body. No + /// further encoding or escaping will be done + /// to the content. + /// @param options @see requestGet()K(optional) + /// @param headers " + /// @param handler " + /// @return " + /// + HttpHandle requestPatch(policy_t policy_id, + priority_t priority, + const std::string & url, + BufferArray * body, + HttpOptions * options, + HttpHeaders * headers, + HttpHandler * user_handler); + + /// Queue a full HTTP PUT. Query arguments and body may + /// be provided. Caller is responsible for escaping and + /// encoding and communicating the content types. + /// + /// @param policy_id @see requestGet() + /// @param priority " + /// @param url " + /// @param options @see requestGet()K(optional) + /// @param headers " + /// @param handler " + /// @return " + /// + HttpHandle requestCopy(policy_t policy_id, + priority_t priority, + const std::string & url, + HttpOptions * options, + HttpHeaders * headers, + HttpHandler * user_handler); + + /// Queue a NoOp request. /// The request is queued and serviced by the working thread which /// immediately processes it and returns the request to the reply /// queue. diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index a32c4cad22..2d6cca214c 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -142,6 +142,46 @@ HttpHandle requestPutWithLLSD(HttpRequest::ptr_t & request, url, body, options.get(), headers.get(), handler); } +HttpHandle requestPatchWithLLSD(HttpRequest * request, + HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + HttpOptions * options, + HttpHeaders * headers, + HttpHandler * handler) +{ + HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); + + BufferArray * ba = new BufferArray(); + BufferArrayStream bas(ba); + LLSDSerialize::toXML(body, bas); + + handle = request->requestPatch(policy_id, + priority, + url, + ba, + options, + headers, + handler); + ba->release(); + return handle; +} + +HttpHandle requestPatchWithLLSD(HttpRequest::ptr_t & request, + HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, + HttpHandler * handler) +{ + return requestPatchWithLLSD(request.get(), policy_id, priority, + url, body, options.get(), headers.get(), handler); +} + + std::string responseToString(LLCore::HttpResponse * response) { static const std::string empty("[Empty]"); diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 471710f61b..6fcf03b95c 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -155,6 +155,41 @@ LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & request, LLCore::HttpHeaders::ptr_t & headers, LLCore::HttpHandler * handler); +/// Issue a standard HttpRequest::requestPatch() call but using +/// and LLSD object as the request body. Conventions are the +/// same as with that method. Caller is expected to provide +/// an HttpHeaders object with a correct 'Content-Type:' header. +/// One will not be provided by this call. +/// +/// @return If request is successfully issued, the +/// HttpHandle representing the request. +/// On error, LLCORE_HTTP_HANDLE_INVALID +/// is returned and caller can fetch detailed +/// status with the getStatus() method on the +/// request object. In case of error, no +/// request is queued and caller may need to +/// perform additional cleanup such as freeing +/// a now-useless HttpHandler object. +/// +LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest * request, + LLCore::HttpRequest::policy_t policy_id, + LLCore::HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + LLCore::HttpOptions * options, + LLCore::HttpHeaders * headers, + LLCore::HttpHandler * handler); + +LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & request, + LLCore::HttpRequest::policy_t policy_id, + LLCore::HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + LLCore::HttpOptions::ptr_t & options, + LLCore::HttpHeaders::ptr_t & headers, + LLCore::HttpHandler * handler); + + /// The HttpCoroHandler is a specialization of the LLCore::HttpHandler for /// interacting with coroutines. When the request is completed the response /// will be posted onto the supplied Event Pump. -- cgit v1.3 From 1138c57f9a8553903199e727912d7f1b092697e4 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Jul 2015 10:01:27 -0700 Subject: Convert LLCore::HttpHeaders to use shared_ptr<> rather than an intrusive_ptr<> for refrence counting. --- indra/llcorehttp/_httplibcurl.cpp | 2 +- indra/llcorehttp/_httpoprequest.cpp | 41 ++++++++++--------------------- indra/llcorehttp/_httpoprequest.h | 23 ++++++++--------- indra/llcorehttp/httpheaders.cpp | 1 - indra/llcorehttp/httpheaders.h | 7 +++--- indra/llcorehttp/httprequest.cpp | 14 +++++------ indra/llcorehttp/httprequest.h | 15 +++++------ indra/llcorehttp/httpresponse.cpp | 21 +++------------- indra/llcorehttp/httpresponse.h | 12 ++++----- indra/llcrashlogger/llcrashlogger.cpp | 2 +- indra/llmessage/llcorehttputil.cpp | 14 +++++------ indra/llmessage/llcorehttputil.h | 18 +++++++------- indra/newview/llassetuploadresponders.cpp | 2 ++ indra/newview/llassetuploadresponders.h | 3 ++- indra/newview/llhttpretrypolicy.cpp | 4 +-- indra/newview/llhttpretrypolicy.h | 2 +- indra/newview/llinventorymodel.cpp | 10 +++----- indra/newview/llinventorymodel.h | 2 +- indra/newview/llmaterialmgr.cpp | 2 +- indra/newview/llmeshrepository.cpp | 17 +++---------- indra/newview/llmeshrepository.h | 4 +-- indra/newview/lltexturefetch.cpp | 29 +++++----------------- indra/newview/lltexturefetch.h | 8 +++--- indra/newview/llviewerassetupload.cpp | 4 +++ indra/newview/llviewerassetupload.h | 13 ++++++++++ indra/newview/llxmlrpctransaction.cpp | 2 +- 26 files changed, 118 insertions(+), 154 deletions(-) (limited to 'indra/llcorehttp/httprequest.cpp') diff --git a/indra/llcorehttp/_httplibcurl.cpp b/indra/llcorehttp/_httplibcurl.cpp index 81b44ab90b..17e997688f 100755 --- a/indra/llcorehttp/_httplibcurl.cpp +++ b/indra/llcorehttp/_httplibcurl.cpp @@ -554,7 +554,7 @@ void HttpLibcurl::HandleCache::freeHandle(CURL * handle) // --------------------------------------- -struct curl_slist * append_headers_to_slist(const HttpHeaders * headers, struct curl_slist * slist) +struct curl_slist * append_headers_to_slist(const HttpHeaders::ptr_t &headers, struct curl_slist * slist) { const HttpHeaders::const_iterator end(headers->end()); for (HttpHeaders::const_iterator it(headers->begin()); end != it; ++it) diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 799587ff22..5d118a9afb 100755 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -122,7 +122,7 @@ HttpOpRequest::HttpOpRequest() mReqBody(NULL), mReqOffset(0), mReqLength(0), - mReqHeaders(NULL), + mReqHeaders(), mReqOptions(NULL), mCurlActive(false), mCurlHandle(NULL), @@ -135,7 +135,7 @@ HttpOpRequest::HttpOpRequest() mReplyOffset(0), mReplyLength(0), mReplyFullLength(0), - mReplyHeaders(NULL), + mReplyHeaders(), mPolicyRetries(0), mPolicy503Retries(0), mPolicyRetryAt(HttpTime(0)), @@ -162,12 +162,6 @@ HttpOpRequest::~HttpOpRequest() mReqOptions = NULL; } - if (mReqHeaders) - { - mReqHeaders->release(); - mReqHeaders = NULL; - } - if (mCurlHandle) { // Uncertain of thread context so free using @@ -194,11 +188,6 @@ HttpOpRequest::~HttpOpRequest() mReplyBody = NULL; } - if (mReplyHeaders) - { - mReplyHeaders->release(); - mReplyHeaders = NULL; - } } @@ -299,7 +288,7 @@ HttpStatus HttpOpRequest::setupGet(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers) + HttpHeaders::ptr_t &headers) { setupCommon(policy_id, priority, url, NULL, options, headers); mReqMethod = HOR_GET; @@ -314,7 +303,7 @@ HttpStatus HttpOpRequest::setupGetByteRange(HttpRequest::policy_t policy_id, size_t offset, size_t len, HttpOptions * options, - HttpHeaders * headers) + HttpHeaders::ptr_t &headers) { setupCommon(policy_id, priority, url, NULL, options, headers); mReqMethod = HOR_GET; @@ -334,7 +323,7 @@ HttpStatus HttpOpRequest::setupPost(HttpRequest::policy_t policy_id, const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers) + HttpHeaders::ptr_t &headers) { setupCommon(policy_id, priority, url, body, options, headers); mReqMethod = HOR_POST; @@ -348,7 +337,7 @@ HttpStatus HttpOpRequest::setupPut(HttpRequest::policy_t policy_id, const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers) + HttpHeaders::ptr_t &headers) { setupCommon(policy_id, priority, url, body, options, headers); mReqMethod = HOR_PUT; @@ -361,7 +350,7 @@ HttpStatus HttpOpRequest::setupDelete(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers) + HttpHeaders::ptr_t &headers) { setupCommon(policy_id, priority, url, NULL, options, headers); mReqMethod = HOR_DELETE; @@ -375,7 +364,7 @@ HttpStatus HttpOpRequest::setupPatch(HttpRequest::policy_t policy_id, const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers) + HttpHeaders::ptr_t &headers) { setupCommon(policy_id, priority, url, body, options, headers); mReqMethod = HOR_PATCH; @@ -388,7 +377,7 @@ HttpStatus HttpOpRequest::setupCopy(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers) + HttpHeaders::ptr_t &headers) { setupCommon(policy_id, priority, url, NULL, options, headers); mReqMethod = HOR_COPY; @@ -402,7 +391,7 @@ void HttpOpRequest::setupCommon(HttpRequest::policy_t policy_id, const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers) + HttpHeaders::ptr_t &headers) { mProcFlags = 0U; mReqPolicy = policy_id; @@ -415,7 +404,7 @@ void HttpOpRequest::setupCommon(HttpRequest::policy_t policy_id, } if (headers && ! mReqHeaders) { - headers->addRef(); + //headers->addRef(); mReqHeaders = headers; } if (options && ! mReqOptions) @@ -467,11 +456,7 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) mReplyOffset = 0; mReplyLength = 0; mReplyFullLength = 0; - if (mReplyHeaders) - { - mReplyHeaders->release(); - mReplyHeaders = NULL; - } + mReplyHeaders.reset(); mReplyConType.clear(); // *FIXME: better error handling later @@ -946,7 +931,7 @@ size_t HttpOpRequest::headerCallback(void * data, size_t size, size_t nmemb, voi // Save headers in response if (! op->mReplyHeaders) { - op->mReplyHeaders = new HttpHeaders; + op->mReplyHeaders = HttpHeaders::ptr_t(new HttpHeaders); } op->mReplyHeaders->append(name, value ? value : ""); } diff --git a/indra/llcorehttp/_httpoprequest.h b/indra/llcorehttp/_httpoprequest.h index b1bb101bea..0465c2b83f 100755 --- a/indra/llcorehttp/_httpoprequest.h +++ b/indra/llcorehttp/_httpoprequest.h @@ -41,6 +41,7 @@ #include "_httpoperation.h" #include "_refcounted.h" +#include "httpheaders.h" namespace LLCore { @@ -105,7 +106,7 @@ public: HttpRequest::priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers); + HttpHeaders::ptr_t & headers); HttpStatus setupGetByteRange(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, @@ -113,40 +114,40 @@ public: size_t offset, size_t len, HttpOptions * options, - HttpHeaders * headers); + HttpHeaders::ptr_t & headers); HttpStatus setupPost(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers); + HttpHeaders::ptr_t & headers); HttpStatus setupPut(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers); + HttpHeaders::ptr_t & headers); HttpStatus setupDelete(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers); + HttpHeaders::ptr_t & headers); HttpStatus setupPatch(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers); + HttpHeaders::ptr_t & headers); HttpStatus setupCopy(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers); + HttpHeaders::ptr_t & headers); // Internal method used to setup the libcurl options for a request. // Does all the libcurl handle setup in one place. @@ -167,7 +168,7 @@ protected: const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers); + HttpHeaders::ptr_t &headers); // libcurl operational callbacks // @@ -197,7 +198,7 @@ public: BufferArray * mReqBody; off_t mReqOffset; size_t mReqLength; - HttpHeaders * mReqHeaders; + HttpHeaders::ptr_t mReqHeaders; HttpOptions * mReqOptions; // Transport data @@ -215,7 +216,7 @@ public: off_t mReplyOffset; size_t mReplyLength; size_t mReplyFullLength; - HttpHeaders * mReplyHeaders; + HttpHeaders::ptr_t mReplyHeaders; std::string mReplyConType; int mReplyRetryAfter; @@ -246,7 +247,7 @@ public: // Internal function to append the contents of an HttpHeaders // instance to a curl_slist object. -curl_slist * append_headers_to_slist(const HttpHeaders *, curl_slist * slist); +curl_slist * append_headers_to_slist(const HttpHeaders::ptr_t &, curl_slist * slist); } // end namespace LLCore diff --git a/indra/llcorehttp/httpheaders.cpp b/indra/llcorehttp/httpheaders.cpp index e03b1b080d..f586191a7c 100755 --- a/indra/llcorehttp/httpheaders.cpp +++ b/indra/llcorehttp/httpheaders.cpp @@ -34,7 +34,6 @@ namespace LLCore HttpHeaders::HttpHeaders() - : RefCounted(true) {} diff --git a/indra/llcorehttp/httpheaders.h b/indra/llcorehttp/httpheaders.h index 8f14568fa3..a97bae5537 100755 --- a/indra/llcorehttp/httpheaders.h +++ b/indra/llcorehttp/httpheaders.h @@ -74,7 +74,7 @@ namespace LLCore /// constructor is given a refcount. /// -class HttpHeaders : public LLCoreInt::RefCounted +class HttpHeaders: private boost::noncopyable { public: typedef std::pair header_t; @@ -91,10 +91,11 @@ public: /// to the instance. A call to @see release() will destroy /// the instance. HttpHeaders(); + virtual ~HttpHeaders(); // Use release() - typedef LLCoreInt::IntrusivePtr ptr_t; + //typedef LLCoreInt::IntrusivePtr ptr_t; + typedef boost::shared_ptr ptr_t; protected: - virtual ~HttpHeaders(); // Use release() HttpHeaders(const HttpHeaders &); // Not defined void operator=(const HttpHeaders &); // Not defined diff --git a/indra/llcorehttp/httprequest.cpp b/indra/llcorehttp/httprequest.cpp index d4c60a6f14..b5ea0b44b0 100755 --- a/indra/llcorehttp/httprequest.cpp +++ b/indra/llcorehttp/httprequest.cpp @@ -198,7 +198,7 @@ HttpHandle HttpRequest::requestGet(policy_t policy_id, priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * user_handler) { HttpStatus status; @@ -232,7 +232,7 @@ HttpHandle HttpRequest::requestGetByteRange(policy_t policy_id, size_t offset, size_t len, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * user_handler) { HttpStatus status; @@ -265,7 +265,7 @@ HttpHandle HttpRequest::requestPost(policy_t policy_id, const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * user_handler) { HttpStatus status; @@ -298,7 +298,7 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id, const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * user_handler) { HttpStatus status; @@ -329,7 +329,7 @@ HttpHandle HttpRequest::requestDelete(policy_t policy_id, priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * user_handler) { HttpStatus status; @@ -361,7 +361,7 @@ HttpHandle HttpRequest::requestPatch(policy_t policy_id, const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * user_handler) { HttpStatus status; @@ -392,7 +392,7 @@ HttpHandle HttpRequest::requestCopy(policy_t policy_id, priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * user_handler) { HttpStatus status; diff --git a/indra/llcorehttp/httprequest.h b/indra/llcorehttp/httprequest.h index e87a8b691a..c0622372e1 100755 --- a/indra/llcorehttp/httprequest.h +++ b/indra/llcorehttp/httprequest.h @@ -31,6 +31,7 @@ #include "httpcommon.h" #include "httphandler.h" +#include "httpheaders.h" namespace LLCore { @@ -349,7 +350,7 @@ public: priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * handler); @@ -392,7 +393,7 @@ public: size_t offset, size_t len, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * handler); @@ -433,7 +434,7 @@ public: const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * handler); @@ -474,7 +475,7 @@ public: const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * handler); @@ -494,7 +495,7 @@ public: priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * user_handler); /// Queue a full HTTP PUT. Query arguments and body may @@ -517,7 +518,7 @@ public: const std::string & url, BufferArray * body, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * user_handler); /// Queue a full HTTP PUT. Query arguments and body may @@ -536,7 +537,7 @@ public: priority_t priority, const std::string & url, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * user_handler); /// Queue a NoOp request. diff --git a/indra/llcorehttp/httpresponse.cpp b/indra/llcorehttp/httpresponse.cpp index 7d88f02527..f5ad2ebd47 100755 --- a/indra/llcorehttp/httpresponse.cpp +++ b/indra/llcorehttp/httpresponse.cpp @@ -39,7 +39,7 @@ HttpResponse::HttpResponse() mReplyLength(0U), mReplyFullLength(0U), mBufferArray(NULL), - mHeaders(NULL), + mHeaders(), mRetries(0U), m503Retries(0U), mRequestUrl() @@ -49,7 +49,7 @@ HttpResponse::HttpResponse() HttpResponse::~HttpResponse() { setBody(NULL); - setHeaders(NULL); + //setHeaders(); } @@ -72,22 +72,9 @@ void HttpResponse::setBody(BufferArray * ba) } -void HttpResponse::setHeaders(HttpHeaders * headers) +void HttpResponse::setHeaders(HttpHeaders::ptr_t &headers) { - if (mHeaders == headers) - return; - - if (mHeaders) - { - mHeaders->release(); - } - - if (headers) - { - headers->addRef(); - } - - mHeaders = headers; + mHeaders = headers; } size_t HttpResponse::getBodySize() const diff --git a/indra/llcorehttp/httpresponse.h b/indra/llcorehttp/httpresponse.h index 6c3b4da5e6..0bfa4585c7 100755 --- a/indra/llcorehttp/httpresponse.h +++ b/indra/llcorehttp/httpresponse.h @@ -31,7 +31,7 @@ #include #include "httpcommon.h" - +#include "httpheaders.h" #include "_refcounted.h" @@ -120,13 +120,13 @@ public: /// /// Caller can hold onto the headers by incrementing the reference /// count of the returned object. - HttpHeaders * getHeaders() const - { + HttpHeaders::ptr_t getHeaders() const + { return mHeaders; - } + } /// Behaves like @see setResponse() but for header data. - void setHeaders(HttpHeaders * headers); + void setHeaders(HttpHeaders::ptr_t &headers); /// If a 'Range:' header was used, these methods are involved /// in setting and returning data about the actual response. @@ -212,7 +212,7 @@ protected: unsigned int mReplyLength; unsigned int mReplyFullLength; BufferArray * mBufferArray; - HttpHeaders * mHeaders; + HttpHeaders::ptr_t mHeaders; std::string mContentType; unsigned int mRetries; unsigned int m503Retries; diff --git a/indra/llcrashlogger/llcrashlogger.cpp b/indra/llcrashlogger/llcrashlogger.cpp index cb05c4ff03..ed585ff64e 100755 --- a/indra/llcrashlogger/llcrashlogger.cpp +++ b/indra/llcrashlogger/llcrashlogger.cpp @@ -407,7 +407,7 @@ bool LLCrashLogger::runCrashLogPost(std::string host, LLSD data, std::string msg updateApplication(llformat("%s, try %d...", msg.c_str(), i+1)); LLCoreHttpUtil::requestPostWithLLSD(httpRequest.get(), LLCore::HttpRequest::DEFAULT_POLICY_ID, 0, - host, data, httpOpts.get(), NULL, new LLCrashLoggerHandler); + host, data, httpOpts.get(), LLCore::HttpHeaders::ptr_t(), new LLCrashLoggerHandler); while(!gBreak) { diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 4ec01aa405..e3588b74ee 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -103,7 +103,7 @@ HttpHandle requestPostWithLLSD(HttpRequest * request, const std::string & url, const LLSD & body, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -130,7 +130,7 @@ HttpHandle requestPutWithLLSD(HttpRequest * request, const std::string & url, const LLSD & body, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -156,7 +156,7 @@ HttpHandle requestPatchWithLLSD(HttpRequest * request, const std::string & url, const LLSD & body, HttpOptions * options, - HttpHeaders * headers, + HttpHeaders::ptr_t &headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -286,7 +286,7 @@ void HttpCoroHandler::buildStatusEntry(LLCore::HttpResponse *response, LLCore::H writeStatusCodes(status, response->getRequestURL(), httpresults); LLSD httpHeaders = LLSD::emptyMap(); - LLCore::HttpHeaders * hdrs = response->getHeaders(); + LLCore::HttpHeaders::ptr_t hdrs = response->getHeaders(); if (hdrs) { @@ -689,7 +689,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpReque // 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.get(), headers.get(), handler.get()); + options.get(), headers, handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { @@ -782,7 +782,7 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpReques // 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.get(), headers.get(), handler.get()); + url, options.get(), headers, handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { @@ -817,7 +817,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpReq // 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.get(), headers.get(), handler.get()); + url, options.get(), headers, handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 7dd161d1cd..a54f94e6f0 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -112,7 +112,7 @@ LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest * request, const std::string & url, const LLSD & body, LLCore::HttpOptions * options, - LLCore::HttpHeaders * headers, + LLCore::HttpHeaders::ptr_t &headers, LLCore::HttpHandler * handler); inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -125,7 +125,7 @@ inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & reque LLCore::HttpHandler * handler) { return requestPostWithLLSD(request.get(), policy_id, priority, - url, body, options.get(), headers.get(), handler); + url, body, options.get(), headers, handler); } inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -136,7 +136,7 @@ inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & reque LLCore::HttpHandler * handler) { return requestPostWithLLSD(request.get(), policy_id, priority, - url, body, NULL, NULL, handler); + url, body, NULL, LLCore::HttpHeaders::ptr_t(), handler); } @@ -162,7 +162,7 @@ LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest * request, const std::string & url, const LLSD & body, LLCore::HttpOptions * options, - LLCore::HttpHeaders * headers, + LLCore::HttpHeaders::ptr_t &headers, LLCore::HttpHandler * handler); inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -175,7 +175,7 @@ inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & reques LLCore::HttpHandler * handler) { return requestPutWithLLSD(request.get(), policy_id, priority, - url, body, options.get(), headers.get(), handler); + url, body, options.get(), headers, handler); } inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -186,7 +186,7 @@ inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & reques LLCore::HttpHandler * handler) { return requestPutWithLLSD(request.get(), policy_id, priority, - url, body, NULL, NULL, handler); + url, body, NULL, LLCore::HttpHeaders::ptr_t(), handler); } /// Issue a standard HttpRequest::requestPatch() call but using @@ -211,7 +211,7 @@ LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest * request, const std::string & url, const LLSD & body, LLCore::HttpOptions * options, - LLCore::HttpHeaders * headers, + LLCore::HttpHeaders::ptr_t &headers, LLCore::HttpHandler * handler); inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -224,7 +224,7 @@ inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & requ LLCore::HttpHandler * handler) { return requestPatchWithLLSD(request.get(), policy_id, priority, - url, body, options.get(), headers.get(), handler); + url, body, options.get(), headers, handler); } inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -235,7 +235,7 @@ inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & requ LLCore::HttpHandler * handler) { return requestPatchWithLLSD(request.get(), policy_id, priority, - url, body, NULL, NULL, handler); + url, body, NULL, LLCore::HttpHeaders::ptr_t(), handler); } //========================================================================= diff --git a/indra/newview/llassetuploadresponders.cpp b/indra/newview/llassetuploadresponders.cpp index e492b8cf5d..fe01288e23 100755 --- a/indra/newview/llassetuploadresponders.cpp +++ b/indra/newview/llassetuploadresponders.cpp @@ -352,6 +352,7 @@ void LLAssetUploadResponder::uploadComplete(const LLSD& content) { } +#if 0 LLNewAgentInventoryResponder::LLNewAgentInventoryResponder( const LLSD& post_data, const LLUUID& vfile_id, @@ -473,6 +474,7 @@ void LLNewAgentInventoryResponder::uploadComplete(const LLSD& content) //LLImportColladaAssetCache::getInstance()->assetUploaded(mVFileID, content["new_asset"], TRUE); } +#endif LLUpdateAgentInventoryResponder::LLUpdateAgentInventoryResponder( const LLSD& post_data, diff --git a/indra/newview/llassetuploadresponders.h b/indra/newview/llassetuploadresponders.h index 18968bb1af..6828678f09 100755 --- a/indra/newview/llassetuploadresponders.h +++ b/indra/newview/llassetuploadresponders.h @@ -60,6 +60,7 @@ protected: std::string mFileName; }; +#if 0 // TODO*: Remove this once deprecated class LLNewAgentInventoryResponder : public LLAssetUploadResponder { @@ -78,7 +79,7 @@ public: protected: virtual void httpFailure(); }; - +#endif #if 0 // A base class which goes through and performs some default // actions for variable price uploads. If more specific actions diff --git a/indra/newview/llhttpretrypolicy.cpp b/indra/newview/llhttpretrypolicy.cpp index 530eb685fa..e2e151eb63 100755 --- a/indra/newview/llhttpretrypolicy.cpp +++ b/indra/newview/llhttpretrypolicy.cpp @@ -56,7 +56,7 @@ bool LLAdaptiveRetryPolicy::getRetryAfter(const LLSD& headers, F32& retry_header && getSecondsUntilRetryAfter(headers[HTTP_IN_HEADER_RETRY_AFTER].asStringRef(), retry_header_time)); } -bool LLAdaptiveRetryPolicy::getRetryAfter(const LLCore::HttpHeaders *headers, F32& retry_header_time) +bool LLAdaptiveRetryPolicy::getRetryAfter(const LLCore::HttpHeaders::ptr_t &headers, F32& retry_header_time) { if (headers) { @@ -85,7 +85,7 @@ void LLAdaptiveRetryPolicy::onFailure(S32 status, const LLSD& headers) void LLAdaptiveRetryPolicy::onFailure(const LLCore::HttpResponse *response) { F32 retry_header_time; - const LLCore::HttpHeaders *headers = response->getHeaders(); + const LLCore::HttpHeaders::ptr_t headers = response->getHeaders(); bool has_retry_header_time = getRetryAfter(headers,retry_header_time); onFailureCommon(response->getStatus().getType(), has_retry_header_time, retry_header_time); } diff --git a/indra/newview/llhttpretrypolicy.h b/indra/newview/llhttpretrypolicy.h index cf79e0b401..c0cc263546 100755 --- a/indra/newview/llhttpretrypolicy.h +++ b/indra/newview/llhttpretrypolicy.h @@ -79,7 +79,7 @@ public: protected: void init(); bool getRetryAfter(const LLSD& headers, F32& retry_header_time); - bool getRetryAfter(const LLCore::HttpHeaders *headers, F32& retry_header_time); + bool getRetryAfter(const LLCore::HttpHeaders::ptr_t &headers, F32& retry_header_time); void onFailureCommon(S32 status, bool has_retry_header_time, F32 retry_header_time); private: diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 6d21dd4ba7..cf550c20c5 100755 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -149,7 +149,7 @@ LLInventoryModel::LLInventoryModel() mHttpRequestFG(NULL), mHttpRequestBG(NULL), mHttpOptions(NULL), - mHttpHeaders(NULL), + mHttpHeaders(), mHttpPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), mHttpPriorityFG(0), mHttpPriorityBG(0), @@ -178,11 +178,7 @@ void LLInventoryModel::cleanupInventory() mObservers.clear(); // Run down HTTP transport - if (mHttpHeaders) - { - mHttpHeaders->release(); - mHttpHeaders = NULL; - } + mHttpHeaders.reset(); if (mHttpOptions) { mHttpOptions->release(); @@ -2422,7 +2418,7 @@ void LLInventoryModel::initHttpRequest() mHttpOptions->setTransferTimeout(300); mHttpOptions->setUseRetryAfter(true); // mHttpOptions->setTrace(2); // Do tracing of requests - mHttpHeaders = new LLCore::HttpHeaders; + mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders); mHttpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML); mHttpHeaders->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_LLSD_XML); mHttpPolicyClass = app_core_http.getPolicy(LLAppCoreHttp::AP_INVENTORY); diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h index 26ee06535a..9711fb95f6 100755 --- a/indra/newview/llinventorymodel.h +++ b/indra/newview/llinventorymodel.h @@ -572,7 +572,7 @@ private: LLCore::HttpRequest * mHttpRequestFG; LLCore::HttpRequest * mHttpRequestBG; LLCore::HttpOptions * mHttpOptions; - LLCore::HttpHeaders * mHttpHeaders; + LLCore::HttpHeaders::ptr_t mHttpHeaders; LLCore::HttpRequest::policy_t mHttpPolicyClass; LLCore::HttpRequest::priority_t mHttpPriorityFG; LLCore::HttpRequest::priority_t mHttpPriorityBG; diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index aef5bcf0dd..e6f3540877 100755 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -712,7 +712,7 @@ void LLMaterialMgr::processGetAllQueue() ); LLCore::HttpHandle handle = mHttpRequest->requestGet(mHttpPolicy, mHttpPriority, capURL, - mHttpOptions.get(), mHttpHeaders.get(), handler); + mHttpOptions.get(), mHttpHeaders, handler); if (handle == LLCORE_HTTP_HANDLE_INVALID) { diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 648056484e..7f8e357e33 100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -740,7 +740,7 @@ LLMeshRepoThread::LLMeshRepoThread() mHttpRequest(NULL), mHttpOptions(NULL), mHttpLargeOptions(NULL), - mHttpHeaders(NULL), + mHttpHeaders(), mHttpPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), mHttpLegacyPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), mHttpLargePolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), @@ -759,7 +759,7 @@ LLMeshRepoThread::LLMeshRepoThread() mHttpLargeOptions = new LLCore::HttpOptions; mHttpLargeOptions->setTransferTimeout(LARGE_MESH_XFER_TIMEOUT); mHttpLargeOptions->setUseRetryAfter(gSavedSettings.getBOOL("MeshUseHttpRetryAfter")); - mHttpHeaders = new LLCore::HttpHeaders; + mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders); mHttpHeaders->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_VND_LL_MESH); mHttpPolicyClass = app_core_http.getPolicy(LLAppCoreHttp::AP_MESH2); mHttpLegacyPolicyClass = app_core_http.getPolicy(LLAppCoreHttp::AP_MESH1); @@ -781,11 +781,7 @@ LLMeshRepoThread::~LLMeshRepoThread() delete *iter; } mHttpRequestSet.clear(); - if (mHttpHeaders) - { - mHttpHeaders->release(); - mHttpHeaders = NULL; - } + mHttpHeaders.reset(); if (mHttpOptions) { mHttpOptions->release(); @@ -1886,7 +1882,7 @@ LLMeshUploadThread::LLMeshUploadThread(LLMeshUploadThread::instance_list& data, mHttpOptions->setTransferTimeout(mMeshUploadTimeOut); mHttpOptions->setUseRetryAfter(gSavedSettings.getBOOL("MeshUseHttpRetryAfter")); mHttpOptions->setRetries(UPLOAD_RETRY_LIMIT); - mHttpHeaders = new LLCore::HttpHeaders; + mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders); mHttpHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML); mHttpPolicyClass = LLAppViewer::instance()->getAppCoreHttp().getPolicy(LLAppCoreHttp::AP_UPLOADS); mHttpPriority = 0; @@ -1894,11 +1890,6 @@ LLMeshUploadThread::LLMeshUploadThread(LLMeshUploadThread::instance_list& data, LLMeshUploadThread::~LLMeshUploadThread() { - if (mHttpHeaders) - { - mHttpHeaders->release(); - mHttpHeaders = NULL; - } if (mHttpOptions) { mHttpOptions->release(); diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h index 39280bea3a..dc1fa883b3 100755 --- a/indra/newview/llmeshrepository.h +++ b/indra/newview/llmeshrepository.h @@ -324,7 +324,7 @@ public: LLCore::HttpRequest * mHttpRequest; LLCore::HttpOptions * mHttpOptions; LLCore::HttpOptions * mHttpLargeOptions; - LLCore::HttpHeaders * mHttpHeaders; + LLCore::HttpHeaders::ptr_t mHttpHeaders; LLCore::HttpRequest::policy_t mHttpPolicyClass; LLCore::HttpRequest::policy_t mHttpLegacyPolicyClass; LLCore::HttpRequest::policy_t mHttpLargePolicyClass; @@ -494,7 +494,7 @@ private: LLCore::HttpStatus mHttpStatus; LLCore::HttpRequest * mHttpRequest; LLCore::HttpOptions * mHttpOptions; - LLCore::HttpHeaders * mHttpHeaders; + LLCore::HttpHeaders::ptr_t mHttpHeaders; LLCore::HttpRequest::policy_t mHttpPolicyClass; LLCore::HttpRequest::priority_t mHttpPriority; }; diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index f4b1ff7313..1055216b65 100755 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -2511,9 +2511,9 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image mHttpRequest(NULL), mHttpOptions(NULL), mHttpOptionsWithHeaders(NULL), - mHttpHeaders(NULL), + mHttpHeaders(), mHttpPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), - mHttpMetricsHeaders(NULL), + mHttpMetricsHeaders(), mHttpMetricsPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), mTotalCacheReadCount(0U), mTotalCacheWriteCount(0U), @@ -2531,10 +2531,10 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image mHttpOptions = new LLCore::HttpOptions; mHttpOptionsWithHeaders = new LLCore::HttpOptions; mHttpOptionsWithHeaders->setWantHeaders(true); - mHttpHeaders = new LLCore::HttpHeaders; + mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders); mHttpHeaders->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_IMAGE_X_J2C); mHttpPolicyClass = app_core_http.getPolicy(LLAppCoreHttp::AP_TEXTURE); - mHttpMetricsHeaders = new LLCore::HttpHeaders; + mHttpMetricsHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders); mHttpMetricsHeaders->append(HTTP_OUT_HEADER_CONTENT_TYPE, HTTP_CONTENT_LLSD_XML); mHttpMetricsPolicyClass = app_core_http.getPolicy(LLAppCoreHttp::AP_REPORTING); mHttpHighWater = HTTP_NONPIPE_REQUESTS_HIGH_WATER; @@ -2580,18 +2580,6 @@ LLTextureFetch::~LLTextureFetch() mHttpOptionsWithHeaders = NULL; } - if (mHttpHeaders) - { - mHttpHeaders->release(); - mHttpHeaders = NULL; - } - - if (mHttpMetricsHeaders) - { - mHttpMetricsHeaders->release(); - mHttpMetricsHeaders = NULL; - } - mHttpWaitResource.clear(); delete mHttpRequest; @@ -4162,7 +4150,7 @@ LLTextureFetchDebugger::LLTextureFetchDebugger(LLTextureFetch* fetcher, LLTextur mFetcher(fetcher), mTextureCache(cache), mImageDecodeThread(imagedecodethread), - mHttpHeaders(NULL), + mHttpHeaders(), mHttpPolicyClass(fetcher->getPolicyClass()), mNbCurlCompleted(0), mTempIndex(0), @@ -4176,11 +4164,6 @@ LLTextureFetchDebugger::~LLTextureFetchDebugger() mFetchingHistory.clear(); mStopDebug = TRUE; tryToStopDebug(); - if (mHttpHeaders) - { - mHttpHeaders->release(); - mHttpHeaders = NULL; - } } void LLTextureFetchDebugger::init() @@ -4225,7 +4208,7 @@ void LLTextureFetchDebugger::init() if (! mHttpHeaders) { - mHttpHeaders = new LLCore::HttpHeaders; + mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders); mHttpHeaders->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_IMAGE_X_J2C); } } diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h index 27779a31e0..a5d6cd63d7 100755 --- a/indra/newview/lltexturefetch.h +++ b/indra/newview/lltexturefetch.h @@ -177,7 +177,7 @@ public: // to do that to hold a reference for any length of time. // // Threads: T* - LLCore::HttpHeaders * getMetricsHeaders() const { return mHttpMetricsHeaders; } + LLCore::HttpHeaders::ptr_t getMetricsHeaders() const { return mHttpMetricsHeaders; } // Threads: T* LLCore::HttpRequest::policy_t getMetricsPolicyClass() const { return mHttpMetricsPolicyClass; } @@ -356,9 +356,9 @@ private: LLCore::HttpRequest * mHttpRequest; // Ttf LLCore::HttpOptions * mHttpOptions; // Ttf LLCore::HttpOptions * mHttpOptionsWithHeaders; // Ttf - LLCore::HttpHeaders * mHttpHeaders; // Ttf + LLCore::HttpHeaders::ptr_t mHttpHeaders; // Ttf LLCore::HttpRequest::policy_t mHttpPolicyClass; // T* - LLCore::HttpHeaders * mHttpMetricsHeaders; // Ttf + LLCore::HttpHeaders::ptr_t mHttpMetricsHeaders; // Ttf LLCore::HttpRequest::policy_t mHttpMetricsPolicyClass; // T* S32 mHttpHighWater; // Ttf S32 mHttpLowWater; // Ttf @@ -510,7 +510,7 @@ private: LLTextureFetch* mFetcher; LLTextureCache* mTextureCache; LLImageDecodeThread* mImageDecodeThread; - LLCore::HttpHeaders* mHttpHeaders; + LLCore::HttpHeaders::ptr_t mHttpHeaders; LLCore::HttpRequest::policy_t mHttpPolicyClass; S32 mNumFetchedTextures; diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp index bfcdbfc109..efaf95444d 100644 --- a/indra/newview/llviewerassetupload.cpp +++ b/indra/newview/llviewerassetupload.cpp @@ -393,6 +393,9 @@ LLSD NewFileResourceUploadInfo::exportTempFile() } +//========================================================================= + + //========================================================================= /*static*/ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoros::self &self, LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter, const LLUUID &id, @@ -552,3 +555,4 @@ void LLViewerAssetUpload::HandleUploadError(LLCore::HttpStatus status, LLSD &res } } + diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h index 771828b393..a2b250b33b 100644 --- a/indra/newview/llviewerassetupload.h +++ b/indra/newview/llviewerassetupload.h @@ -176,6 +176,19 @@ private: }; +#if 0 +class NotecardResourceUploadInfo : public NewResourceUploadInfo +{ +public: + NotecardResourceUploadInfo( + ); + + +protected: + +private: +}; +#endif class LLViewerAssetUpload { diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp index 066970614a..63ad4bd49b 100755 --- a/indra/newview/llxmlrpctransaction.cpp +++ b/indra/newview/llxmlrpctransaction.cpp @@ -390,7 +390,7 @@ void LLXMLRPCTransaction::Impl::init(XMLRPC_REQUEST request, bool useGzip) mHandler = LLXMLRPCTransaction::Handler::ptr_t(new Handler( mHttpRequest, this )); mPostH = mHttpRequest->requestPost(LLCore::HttpRequest::DEFAULT_POLICY_ID, 0, - mURI, body.get(), httpOpts.get(), httpHeaders.get(), mHandler.get()); + mURI, body.get(), httpOpts.get(), httpHeaders, mHandler.get()); } -- cgit v1.3 From fe5567639d7d4b6f13f66da0a1fb4bf2af295283 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Jul 2015 12:09:36 -0700 Subject: Change HttpOptions::ptr_t to be shared_ptr<> rather than intrusive. --- indra/llcorehttp/_httpoprequest.cpp | 42 ++++++++++--------------- indra/llcorehttp/_httpoprequest.h | 23 +++++++------- indra/llcorehttp/examples/http_texture_load.cpp | 6 ++-- indra/llcorehttp/httpheaders.h | 2 +- indra/llcorehttp/httpoptions.cpp | 2 +- indra/llcorehttp/httpoptions.h | 7 +++-- indra/llcorehttp/httprequest.cpp | 28 ++++++++--------- indra/llcorehttp/httprequest.h | 31 +++++++++--------- indra/llcrashlogger/llcrashlogger.cpp | 2 +- indra/llmessage/llcorehttputil.cpp | 12 +++---- indra/llmessage/llcorehttputil.h | 18 +++++------ indra/newview/llinventorymodel.cpp | 13 +++----- indra/newview/llinventorymodel.h | 2 +- indra/newview/llmaterialmgr.cpp | 2 +- indra/newview/llmeshrepository.cpp | 28 +++++------------ indra/newview/llmeshrepository.h | 6 ++-- indra/newview/lltexturefetch.cpp | 26 +++++---------- indra/newview/lltexturefetch.h | 4 +-- indra/newview/llxmlrpctransaction.cpp | 2 +- 19 files changed, 109 insertions(+), 147 deletions(-) (limited to 'indra/llcorehttp/httprequest.cpp') diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 5d118a9afb..7baef25aca 100755 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -123,7 +123,7 @@ HttpOpRequest::HttpOpRequest() mReqOffset(0), mReqLength(0), mReqHeaders(), - mReqOptions(NULL), + mReqOptions(), mCurlActive(false), mCurlHandle(NULL), mCurlService(NULL), @@ -156,12 +156,6 @@ HttpOpRequest::~HttpOpRequest() mReqBody = NULL; } - if (mReqOptions) - { - mReqOptions->release(); - mReqOptions = NULL; - } - if (mCurlHandle) { // Uncertain of thread context so free using @@ -287,8 +281,8 @@ HttpStatus HttpOpRequest::cancel() HttpStatus HttpOpRequest::setupGet(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions * options, - HttpHeaders::ptr_t &headers) + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, NULL, options, headers); mReqMethod = HOR_GET; @@ -302,8 +296,8 @@ HttpStatus HttpOpRequest::setupGetByteRange(HttpRequest::policy_t policy_id, const std::string & url, size_t offset, size_t len, - HttpOptions * options, - HttpHeaders::ptr_t &headers) + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, NULL, options, headers); mReqMethod = HOR_GET; @@ -322,8 +316,8 @@ HttpStatus HttpOpRequest::setupPost(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, - HttpHeaders::ptr_t &headers) + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, body, options, headers); mReqMethod = HOR_POST; @@ -336,8 +330,8 @@ HttpStatus HttpOpRequest::setupPut(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, - HttpHeaders::ptr_t &headers) + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, body, options, headers); mReqMethod = HOR_PUT; @@ -349,8 +343,8 @@ HttpStatus HttpOpRequest::setupPut(HttpRequest::policy_t policy_id, HttpStatus HttpOpRequest::setupDelete(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions * options, - HttpHeaders::ptr_t &headers) + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, NULL, options, headers); mReqMethod = HOR_DELETE; @@ -363,8 +357,8 @@ HttpStatus HttpOpRequest::setupPatch(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, - HttpHeaders::ptr_t &headers) + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, body, options, headers); mReqMethod = HOR_PATCH; @@ -376,7 +370,7 @@ HttpStatus HttpOpRequest::setupPatch(HttpRequest::policy_t policy_id, HttpStatus HttpOpRequest::setupCopy(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions * options, + HttpOptions::ptr_t & options, HttpHeaders::ptr_t &headers) { setupCommon(policy_id, priority, url, NULL, options, headers); @@ -390,8 +384,8 @@ void HttpOpRequest::setupCommon(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, - HttpHeaders::ptr_t &headers) + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers) { mProcFlags = 0U; mReqPolicy = policy_id; @@ -404,12 +398,10 @@ void HttpOpRequest::setupCommon(HttpRequest::policy_t policy_id, } if (headers && ! mReqHeaders) { - //headers->addRef(); mReqHeaders = headers; } - if (options && ! mReqOptions) + if (options && !mReqOptions) { - options->addRef(); mReqOptions = options; if (options->getWantHeaders()) { diff --git a/indra/llcorehttp/_httpoprequest.h b/indra/llcorehttp/_httpoprequest.h index 0465c2b83f..42db71e7a0 100755 --- a/indra/llcorehttp/_httpoprequest.h +++ b/indra/llcorehttp/_httpoprequest.h @@ -42,14 +42,13 @@ #include "_refcounted.h" #include "httpheaders.h" +#include "httpoptions.h" namespace LLCore { class BufferArray; -class HttpHeaders; -class HttpOptions; /// HttpOpRequest requests a supported HTTP method invocation with @@ -105,7 +104,7 @@ public: HttpStatus setupGet(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions * options, + HttpOptions::ptr_t & options, HttpHeaders::ptr_t & headers); HttpStatus setupGetByteRange(HttpRequest::policy_t policy_id, @@ -113,40 +112,40 @@ public: const std::string & url, size_t offset, size_t len, - HttpOptions * options, + HttpOptions::ptr_t & options, HttpHeaders::ptr_t & headers); HttpStatus setupPost(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, + HttpOptions::ptr_t & options, HttpHeaders::ptr_t & headers); HttpStatus setupPut(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, + HttpOptions::ptr_t & options, HttpHeaders::ptr_t & headers); HttpStatus setupDelete(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions * options, + HttpOptions::ptr_t & options, HttpHeaders::ptr_t & headers); HttpStatus setupPatch(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, + HttpOptions::ptr_t & options, HttpHeaders::ptr_t & headers); HttpStatus setupCopy(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions * options, + HttpOptions::ptr_t & options, HttpHeaders::ptr_t & headers); // Internal method used to setup the libcurl options for a request. @@ -167,8 +166,8 @@ protected: HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, - HttpHeaders::ptr_t &headers); + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers); // libcurl operational callbacks // @@ -199,7 +198,7 @@ public: off_t mReqOffset; size_t mReqLength; HttpHeaders::ptr_t mReqHeaders; - HttpOptions * mReqOptions; + HttpOptions::ptr_t mReqOptions; // Transport data bool mCurlActive; diff --git a/indra/llcorehttp/examples/http_texture_load.cpp b/indra/llcorehttp/examples/http_texture_load.cpp index 9d9631b980..13c9f90b2e 100755 --- a/indra/llcorehttp/examples/http_texture_load.cpp +++ b/indra/llcorehttp/examples/http_texture_load.cpp @@ -83,7 +83,7 @@ public: WorkingSet(); ~WorkingSet(); - bool reload(LLCore::HttpRequest *, LLCore::HttpOptions *); + bool reload(LLCore::HttpRequest *, LLCore::HttpOptions::ptr_t &); virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); @@ -304,7 +304,7 @@ int main(int argc, char** argv) LLCore::HttpRequest * hr = new LLCore::HttpRequest(); // Get request options - LLCore::HttpOptions * opt = new LLCore::HttpOptions(); + LLCore::HttpOptions::ptr_t opt = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()); opt->setRetries(12); opt->setUseRetryAfter(true); @@ -442,7 +442,7 @@ WorkingSet::~WorkingSet() } -bool WorkingSet::reload(LLCore::HttpRequest * hr, LLCore::HttpOptions * opt) +bool WorkingSet::reload(LLCore::HttpRequest * hr, LLCore::HttpOptions::ptr_t & opt) { if (mRequestLowWater <= mHandles.size()) { diff --git a/indra/llcorehttp/httpheaders.h b/indra/llcorehttp/httpheaders.h index a97bae5537..b9168cb6ec 100755 --- a/indra/llcorehttp/httpheaders.h +++ b/indra/llcorehttp/httpheaders.h @@ -85,6 +85,7 @@ public: typedef container_t::const_reverse_iterator const_reverse_iterator; typedef container_t::value_type value_type; typedef container_t::size_type size_type; + typedef boost::shared_ptr ptr_t; public: /// @post In addition to the instance, caller has a refcount @@ -94,7 +95,6 @@ public: virtual ~HttpHeaders(); // Use release() //typedef LLCoreInt::IntrusivePtr ptr_t; - typedef boost::shared_ptr ptr_t; protected: HttpHeaders(const HttpHeaders &); // Not defined diff --git a/indra/llcorehttp/httpoptions.cpp b/indra/llcorehttp/httpoptions.cpp index 3459a37aff..aab447f2dd 100755 --- a/indra/llcorehttp/httpoptions.cpp +++ b/indra/llcorehttp/httpoptions.cpp @@ -33,7 +33,7 @@ namespace LLCore { -HttpOptions::HttpOptions() : RefCounted(true), +HttpOptions::HttpOptions() : mWantHeaders(false), mTracing(HTTP_TRACE_OFF), mTimeout(HTTP_REQUEST_TIMEOUT_DEFAULT), diff --git a/indra/llcorehttp/httpoptions.h b/indra/llcorehttp/httpoptions.h index 2fe05a65ff..510eaa45bb 100755 --- a/indra/llcorehttp/httpoptions.h +++ b/indra/llcorehttp/httpoptions.h @@ -55,15 +55,16 @@ namespace LLCore /// Allocation: Refcounted, heap only. Caller of the constructor /// is given a refcount. /// -class HttpOptions : public LLCoreInt::RefCounted +class HttpOptions : private boost::noncopyable { public: HttpOptions(); - typedef LLCoreInt::IntrusivePtr ptr_t; + typedef boost::shared_ptr ptr_t; + + virtual ~HttpOptions(); // Use release() protected: - virtual ~HttpOptions(); // Use release() HttpOptions(const HttpOptions &); // Not defined void operator=(const HttpOptions &); // Not defined diff --git a/indra/llcorehttp/httprequest.cpp b/indra/llcorehttp/httprequest.cpp index b5ea0b44b0..4a7352c962 100755 --- a/indra/llcorehttp/httprequest.cpp +++ b/indra/llcorehttp/httprequest.cpp @@ -197,8 +197,8 @@ HttpStatus HttpRequest::getStatus() const HttpHandle HttpRequest::requestGet(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -231,8 +231,8 @@ HttpHandle HttpRequest::requestGetByteRange(policy_t policy_id, const std::string & url, size_t offset, size_t len, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -264,8 +264,8 @@ HttpHandle HttpRequest::requestPost(policy_t policy_id, priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -297,8 +297,8 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id, priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -328,8 +328,8 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id, HttpHandle HttpRequest::requestDelete(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -360,8 +360,8 @@ HttpHandle HttpRequest::requestPatch(policy_t policy_id, priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -391,8 +391,8 @@ HttpHandle HttpRequest::requestPatch(policy_t policy_id, HttpHandle HttpRequest::requestCopy(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; diff --git a/indra/llcorehttp/httprequest.h b/indra/llcorehttp/httprequest.h index c0622372e1..58aea1444c 100755 --- a/indra/llcorehttp/httprequest.h +++ b/indra/llcorehttp/httprequest.h @@ -32,6 +32,7 @@ #include "httphandler.h" #include "httpheaders.h" +#include "httpoptions.h" namespace LLCore { @@ -39,8 +40,6 @@ namespace LLCore class HttpRequestQueue; class HttpReplyQueue; class HttpService; -class HttpOptions; -class HttpHeaders; class HttpOperation; class BufferArray; @@ -349,8 +348,8 @@ public: HttpHandle requestGet(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * handler); @@ -392,8 +391,8 @@ public: const std::string & url, size_t offset, size_t len, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * handler); @@ -433,8 +432,8 @@ public: priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * handler); @@ -474,8 +473,8 @@ public: priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * handler); @@ -494,8 +493,8 @@ public: HttpHandle requestDelete(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * user_handler); /// Queue a full HTTP PUT. Query arguments and body may @@ -517,8 +516,8 @@ public: priority_t priority, const std::string & url, BufferArray * body, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * user_handler); /// Queue a full HTTP PUT. Query arguments and body may @@ -536,8 +535,8 @@ public: HttpHandle requestCopy(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions * options, - HttpHeaders::ptr_t &headers, + HttpOptions::ptr_t & options, + HttpHeaders::ptr_t & headers, HttpHandler * user_handler); /// Queue a NoOp request. diff --git a/indra/llcrashlogger/llcrashlogger.cpp b/indra/llcrashlogger/llcrashlogger.cpp index ed585ff64e..4caf6dcd05 100755 --- a/indra/llcrashlogger/llcrashlogger.cpp +++ b/indra/llcrashlogger/llcrashlogger.cpp @@ -407,7 +407,7 @@ bool LLCrashLogger::runCrashLogPost(std::string host, LLSD data, std::string msg updateApplication(llformat("%s, try %d...", msg.c_str(), i+1)); LLCoreHttpUtil::requestPostWithLLSD(httpRequest.get(), LLCore::HttpRequest::DEFAULT_POLICY_ID, 0, - host, data, httpOpts.get(), LLCore::HttpHeaders::ptr_t(), new LLCrashLoggerHandler); + host, data, httpOpts, LLCore::HttpHeaders::ptr_t(), new LLCrashLoggerHandler); while(!gBreak) { diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index e3588b74ee..24f5d77ee1 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -102,7 +102,7 @@ HttpHandle requestPostWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions * options, + HttpOptions::ptr_t &options, HttpHeaders::ptr_t &headers, HttpHandler * handler) { @@ -129,7 +129,7 @@ HttpHandle requestPutWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions * options, + HttpOptions::ptr_t &options, HttpHeaders::ptr_t &headers, HttpHandler * handler) { @@ -155,7 +155,7 @@ HttpHandle requestPatchWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions * options, + HttpOptions::ptr_t &options, HttpHeaders::ptr_t &headers, HttpHandler * handler) { @@ -689,7 +689,7 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCoros::self & self, LLCore::HttpReque // 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.get(), headers, handler.get()); + options, headers, handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { @@ -782,7 +782,7 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCoros::self & self, LLCore::HttpReques // 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.get(), headers, handler.get()); + url, options, headers, handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { @@ -817,7 +817,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCoros::self & self, LLCore::HttpReq // 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.get(), headers, handler.get()); + url, options, headers, handler.get()); if (hhandle == LLCORE_HTTP_HANDLE_INVALID) { diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index a54f94e6f0..1e575e0e0c 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -111,7 +111,7 @@ LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest * request, LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - LLCore::HttpOptions * options, + LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, LLCore::HttpHandler * handler); @@ -125,7 +125,7 @@ inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & reque LLCore::HttpHandler * handler) { return requestPostWithLLSD(request.get(), policy_id, priority, - url, body, options.get(), headers, handler); + url, body, options, headers, handler); } inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -136,7 +136,7 @@ inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & reque LLCore::HttpHandler * handler) { return requestPostWithLLSD(request.get(), policy_id, priority, - url, body, NULL, LLCore::HttpHeaders::ptr_t(), handler); + url, body, LLCore::HttpOptions::ptr_t(), LLCore::HttpHeaders::ptr_t(), handler); } @@ -161,7 +161,7 @@ LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest * request, LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - LLCore::HttpOptions * options, + LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, LLCore::HttpHandler * handler); @@ -175,7 +175,7 @@ inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & reques LLCore::HttpHandler * handler) { return requestPutWithLLSD(request.get(), policy_id, priority, - url, body, options.get(), headers, handler); + url, body, options, headers, handler); } inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -186,7 +186,7 @@ inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & reques LLCore::HttpHandler * handler) { return requestPutWithLLSD(request.get(), policy_id, priority, - url, body, NULL, LLCore::HttpHeaders::ptr_t(), handler); + url, body, LLCore::HttpOptions::ptr_t(), LLCore::HttpHeaders::ptr_t(), handler); } /// Issue a standard HttpRequest::requestPatch() call but using @@ -210,7 +210,7 @@ LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest * request, LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - LLCore::HttpOptions * options, + LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, LLCore::HttpHandler * handler); @@ -224,7 +224,7 @@ inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & requ LLCore::HttpHandler * handler) { return requestPatchWithLLSD(request.get(), policy_id, priority, - url, body, options.get(), headers, handler); + url, body, options, headers, handler); } inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -235,7 +235,7 @@ inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & requ LLCore::HttpHandler * handler) { return requestPatchWithLLSD(request.get(), policy_id, priority, - url, body, NULL, LLCore::HttpHeaders::ptr_t(), handler); + url, body, LLCore::HttpOptions::ptr_t(), LLCore::HttpHeaders::ptr_t(), handler); } //========================================================================= diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index cf550c20c5..39aeab22e5 100755 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -148,7 +148,7 @@ LLInventoryModel::LLInventoryModel() mObservers(), mHttpRequestFG(NULL), mHttpRequestBG(NULL), - mHttpOptions(NULL), + mHttpOptions(), mHttpHeaders(), mHttpPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), mHttpPriorityFG(0), @@ -179,11 +179,8 @@ void LLInventoryModel::cleanupInventory() // Run down HTTP transport mHttpHeaders.reset(); - if (mHttpOptions) - { - mHttpOptions->release(); - mHttpOptions = NULL; - } + mHttpOptions.reset(); + delete mHttpRequestFG; mHttpRequestFG = NULL; delete mHttpRequestBG; @@ -609,7 +606,7 @@ void LLInventoryModel::createNewCategoryCoro(LLCoros::self& self, std::string ur LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("createNewCategoryCoro", httpPolicy)); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); + LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); httpOpts->setWantHeaders(true); @@ -2414,7 +2411,7 @@ void LLInventoryModel::initHttpRequest() mHttpRequestFG = new LLCore::HttpRequest; mHttpRequestBG = new LLCore::HttpRequest; - mHttpOptions = new LLCore::HttpOptions; + mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); mHttpOptions->setTransferTimeout(300); mHttpOptions->setUseRetryAfter(true); // mHttpOptions->setTrace(2); // Do tracing of requests diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h index 9711fb95f6..f768e61ccb 100755 --- a/indra/newview/llinventorymodel.h +++ b/indra/newview/llinventorymodel.h @@ -571,7 +571,7 @@ private: // Usual plumbing for LLCore:: HTTP operations. LLCore::HttpRequest * mHttpRequestFG; LLCore::HttpRequest * mHttpRequestBG; - LLCore::HttpOptions * mHttpOptions; + LLCore::HttpOptions::ptr_t mHttpOptions; LLCore::HttpHeaders::ptr_t mHttpHeaders; LLCore::HttpRequest::policy_t mHttpPolicyClass; LLCore::HttpRequest::priority_t mHttpPriorityFG; diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index e6f3540877..1045def72e 100755 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -712,7 +712,7 @@ void LLMaterialMgr::processGetAllQueue() ); LLCore::HttpHandle handle = mHttpRequest->requestGet(mHttpPolicy, mHttpPriority, capURL, - mHttpOptions.get(), mHttpHeaders, handler); + mHttpOptions, mHttpHeaders, handler); if (handle == LLCORE_HTTP_HANDLE_INVALID) { diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 7f8e357e33..d6aaf18cb7 100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -738,8 +738,8 @@ void log_upload_error(LLCore::HttpStatus status, const LLSD& content, LLMeshRepoThread::LLMeshRepoThread() : LLThread("mesh repo"), mHttpRequest(NULL), - mHttpOptions(NULL), - mHttpLargeOptions(NULL), + mHttpOptions(), + mHttpLargeOptions(), mHttpHeaders(), mHttpPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), mHttpLegacyPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), @@ -753,10 +753,10 @@ LLMeshRepoThread::LLMeshRepoThread() mHeaderMutex = new LLMutex(NULL); mSignal = new LLCondition(NULL); mHttpRequest = new LLCore::HttpRequest; - mHttpOptions = new LLCore::HttpOptions; + mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); mHttpOptions->setTransferTimeout(SMALL_MESH_XFER_TIMEOUT); mHttpOptions->setUseRetryAfter(gSavedSettings.getBOOL("MeshUseHttpRetryAfter")); - mHttpLargeOptions = new LLCore::HttpOptions; + mHttpLargeOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); mHttpLargeOptions->setTransferTimeout(LARGE_MESH_XFER_TIMEOUT); mHttpLargeOptions->setUseRetryAfter(gSavedSettings.getBOOL("MeshUseHttpRetryAfter")); mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders); @@ -782,17 +782,8 @@ LLMeshRepoThread::~LLMeshRepoThread() } mHttpRequestSet.clear(); mHttpHeaders.reset(); - if (mHttpOptions) - { - mHttpOptions->release(); - mHttpOptions = NULL; - } - if (mHttpLargeOptions) - { - mHttpLargeOptions->release(); - mHttpLargeOptions = NULL; - } - delete mHttpRequest; + + delete mHttpRequest; mHttpRequest = NULL; delete mMutex; mMutex = NULL; @@ -1878,7 +1869,7 @@ LLMeshUploadThread::LLMeshUploadThread(LLMeshUploadThread::instance_list& data, mMeshUploadTimeOut = gSavedSettings.getS32("MeshUploadTimeOut") ; mHttpRequest = new LLCore::HttpRequest; - mHttpOptions = new LLCore::HttpOptions; + mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); mHttpOptions->setTransferTimeout(mMeshUploadTimeOut); mHttpOptions->setUseRetryAfter(gSavedSettings.getBOOL("MeshUseHttpRetryAfter")); mHttpOptions->setRetries(UPLOAD_RETRY_LIMIT); @@ -1890,11 +1881,6 @@ LLMeshUploadThread::LLMeshUploadThread(LLMeshUploadThread::instance_list& data, LLMeshUploadThread::~LLMeshUploadThread() { - if (mHttpOptions) - { - mHttpOptions->release(); - mHttpOptions = NULL; - } delete mHttpRequest; mHttpRequest = NULL; } diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h index dc1fa883b3..55157cc040 100755 --- a/indra/newview/llmeshrepository.h +++ b/indra/newview/llmeshrepository.h @@ -322,8 +322,8 @@ public: // llcorehttp library interface objects. LLCore::HttpStatus mHttpStatus; LLCore::HttpRequest * mHttpRequest; - LLCore::HttpOptions * mHttpOptions; - LLCore::HttpOptions * mHttpLargeOptions; + LLCore::HttpOptions::ptr_t mHttpOptions; + LLCore::HttpOptions::ptr_t mHttpLargeOptions; LLCore::HttpHeaders::ptr_t mHttpHeaders; LLCore::HttpRequest::policy_t mHttpPolicyClass; LLCore::HttpRequest::policy_t mHttpLegacyPolicyClass; @@ -493,7 +493,7 @@ private: // llcorehttp library interface objects. LLCore::HttpStatus mHttpStatus; LLCore::HttpRequest * mHttpRequest; - LLCore::HttpOptions * mHttpOptions; + LLCore::HttpOptions::ptr_t mHttpOptions; LLCore::HttpHeaders::ptr_t mHttpHeaders; LLCore::HttpRequest::policy_t mHttpPolicyClass; LLCore::HttpRequest::priority_t mHttpPriority; diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 1055216b65..e61eeb2f4e 100755 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -1557,7 +1557,7 @@ bool LLTextureFetchWorker::doWork(S32 param) // Will call callbackHttpGet when curl request completes // Only server bake images use the returned headers currently, for getting retry-after field. - LLCore::HttpOptions *options = (mFTType == FTT_SERVER_BAKE) ? mFetcher->mHttpOptionsWithHeaders: mFetcher->mHttpOptions; + LLCore::HttpOptions::ptr_t options = (mFTType == FTT_SERVER_BAKE) ? mFetcher->mHttpOptionsWithHeaders: mFetcher->mHttpOptions; if (disable_range_req) { // 'Range:' requests may be disabled in which case all HTTP @@ -2509,8 +2509,8 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image mTotalHTTPRequests(0), mQAMode(qa_mode), mHttpRequest(NULL), - mHttpOptions(NULL), - mHttpOptionsWithHeaders(NULL), + mHttpOptions(), + mHttpOptionsWithHeaders(), mHttpHeaders(), mHttpPolicyClass(LLCore::HttpRequest::DEFAULT_POLICY_ID), mHttpMetricsHeaders(), @@ -2528,8 +2528,8 @@ LLTextureFetch::LLTextureFetch(LLTextureCache* cache, LLImageDecodeThread* image LLAppCoreHttp & app_core_http(LLAppViewer::instance()->getAppCoreHttp()); mHttpRequest = new LLCore::HttpRequest; - mHttpOptions = new LLCore::HttpOptions; - mHttpOptionsWithHeaders = new LLCore::HttpOptions; + mHttpOptions = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); + mHttpOptionsWithHeaders = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); mHttpOptionsWithHeaders->setWantHeaders(true); mHttpHeaders = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders); mHttpHeaders->append(HTTP_OUT_HEADER_ACCEPT, HTTP_CONTENT_IMAGE_X_J2C); @@ -2568,18 +2568,6 @@ LLTextureFetch::~LLTextureFetch() delete req; } - if (mHttpOptions) - { - mHttpOptions->release(); - mHttpOptions = NULL; - } - - if (mHttpOptionsWithHeaders) - { - mHttpOptionsWithHeaders->release(); - mHttpOptionsWithHeaders = NULL; - } - mHttpWaitResource.clear(); delete mHttpRequest; @@ -4031,7 +4019,7 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher) report_priority, mCapsURL, sd, - NULL, + LLCore::HttpOptions::ptr_t(), fetcher->getMetricsHeaders(), handler); LLTextureFetch::svMetricsDataBreak = false; @@ -4608,7 +4596,7 @@ S32 LLTextureFetchDebugger::fillCurlQueue() texture_url, 0, requestedSize, - NULL, + LLCore::HttpOptions::ptr_t(), mHttpHeaders, this); if (LLCORE_HTTP_HANDLE_INVALID != handle) diff --git a/indra/newview/lltexturefetch.h b/indra/newview/lltexturefetch.h index a5d6cd63d7..e569175e8f 100755 --- a/indra/newview/lltexturefetch.h +++ b/indra/newview/lltexturefetch.h @@ -354,8 +354,8 @@ private: // to make our HTTP requests. These replace the various // LLCurl interfaces used in the past. LLCore::HttpRequest * mHttpRequest; // Ttf - LLCore::HttpOptions * mHttpOptions; // Ttf - LLCore::HttpOptions * mHttpOptionsWithHeaders; // Ttf + LLCore::HttpOptions::ptr_t mHttpOptions; // Ttf + LLCore::HttpOptions::ptr_t mHttpOptionsWithHeaders; // Ttf LLCore::HttpHeaders::ptr_t mHttpHeaders; // Ttf LLCore::HttpRequest::policy_t mHttpPolicyClass; // T* LLCore::HttpHeaders::ptr_t mHttpMetricsHeaders; // Ttf diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp index 63ad4bd49b..5828aee7fc 100755 --- a/indra/newview/llxmlrpctransaction.cpp +++ b/indra/newview/llxmlrpctransaction.cpp @@ -390,7 +390,7 @@ void LLXMLRPCTransaction::Impl::init(XMLRPC_REQUEST request, bool useGzip) mHandler = LLXMLRPCTransaction::Handler::ptr_t(new Handler( mHttpRequest, this )); mPostH = mHttpRequest->requestPost(LLCore::HttpRequest::DEFAULT_POLICY_ID, 0, - mURI, body.get(), httpOpts.get(), httpHeaders, mHandler.get()); + mURI, body.get(), httpOpts, httpHeaders, mHandler.get()); } -- cgit v1.3 From 75b12d79e1aeeef297182e4419df7022ede485f3 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 Jul 2015 14:49:08 -0700 Subject: Enforcing constness of refs --- indra/llcorehttp/_httpoprequest.cpp | 32 ++++++++++++++++---------------- indra/llcorehttp/_httpoprequest.h | 32 ++++++++++++++++---------------- indra/llcorehttp/httprequest.cpp | 28 ++++++++++++++-------------- indra/llcorehttp/httprequest.h | 28 ++++++++++++++-------------- indra/llmessage/llcorehttputil.cpp | 12 ++++++------ indra/llmessage/llcorehttputil.h | 34 +++++++++++++++++----------------- 6 files changed, 83 insertions(+), 83 deletions(-) (limited to 'indra/llcorehttp/httprequest.cpp') diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 7baef25aca..e588ed8a9b 100755 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -281,8 +281,8 @@ HttpStatus HttpOpRequest::cancel() HttpStatus HttpOpRequest::setupGet(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers) + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, NULL, options, headers); mReqMethod = HOR_GET; @@ -296,8 +296,8 @@ HttpStatus HttpOpRequest::setupGetByteRange(HttpRequest::policy_t policy_id, const std::string & url, size_t offset, size_t len, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers) + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, NULL, options, headers); mReqMethod = HOR_GET; @@ -316,8 +316,8 @@ HttpStatus HttpOpRequest::setupPost(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers) + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, body, options, headers); mReqMethod = HOR_POST; @@ -330,8 +330,8 @@ HttpStatus HttpOpRequest::setupPut(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers) + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, body, options, headers); mReqMethod = HOR_PUT; @@ -343,8 +343,8 @@ HttpStatus HttpOpRequest::setupPut(HttpRequest::policy_t policy_id, HttpStatus HttpOpRequest::setupDelete(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers) + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, NULL, options, headers); mReqMethod = HOR_DELETE; @@ -357,8 +357,8 @@ HttpStatus HttpOpRequest::setupPatch(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers) + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers) { setupCommon(policy_id, priority, url, body, options, headers); mReqMethod = HOR_PATCH; @@ -370,8 +370,8 @@ HttpStatus HttpOpRequest::setupPatch(HttpRequest::policy_t policy_id, HttpStatus HttpOpRequest::setupCopy(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t &headers) + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t &headers) { setupCommon(policy_id, priority, url, NULL, options, headers); mReqMethod = HOR_COPY; @@ -384,8 +384,8 @@ void HttpOpRequest::setupCommon(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers) + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers) { mProcFlags = 0U; mReqPolicy = policy_id; diff --git a/indra/llcorehttp/_httpoprequest.h b/indra/llcorehttp/_httpoprequest.h index 42db71e7a0..a9083be02b 100755 --- a/indra/llcorehttp/_httpoprequest.h +++ b/indra/llcorehttp/_httpoprequest.h @@ -104,49 +104,49 @@ public: HttpStatus setupGet(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers); + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers); HttpStatus setupGetByteRange(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, size_t offset, size_t len, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers); + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers); HttpStatus setupPost(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers); + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers); HttpStatus setupPut(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers); + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers); HttpStatus setupDelete(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers); + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers); HttpStatus setupPatch(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers); + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers); HttpStatus setupCopy(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers); + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers); // Internal method used to setup the libcurl options for a request. // Does all the libcurl handle setup in one place. @@ -166,8 +166,8 @@ protected: HttpRequest::priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers); + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers); // libcurl operational callbacks // diff --git a/indra/llcorehttp/httprequest.cpp b/indra/llcorehttp/httprequest.cpp index 4a7352c962..f0dfde6153 100755 --- a/indra/llcorehttp/httprequest.cpp +++ b/indra/llcorehttp/httprequest.cpp @@ -197,8 +197,8 @@ HttpStatus HttpRequest::getStatus() const HttpHandle HttpRequest::requestGet(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -231,8 +231,8 @@ HttpHandle HttpRequest::requestGetByteRange(policy_t policy_id, const std::string & url, size_t offset, size_t len, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -264,8 +264,8 @@ HttpHandle HttpRequest::requestPost(policy_t policy_id, priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -297,8 +297,8 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id, priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -328,8 +328,8 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id, HttpHandle HttpRequest::requestDelete(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -360,8 +360,8 @@ HttpHandle HttpRequest::requestPatch(policy_t policy_id, priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; @@ -391,8 +391,8 @@ HttpHandle HttpRequest::requestPatch(policy_t policy_id, HttpHandle HttpRequest::requestCopy(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * user_handler) { HttpStatus status; diff --git a/indra/llcorehttp/httprequest.h b/indra/llcorehttp/httprequest.h index 58aea1444c..20a223c482 100755 --- a/indra/llcorehttp/httprequest.h +++ b/indra/llcorehttp/httprequest.h @@ -348,8 +348,8 @@ public: HttpHandle requestGet(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * handler); @@ -391,8 +391,8 @@ public: const std::string & url, size_t offset, size_t len, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * handler); @@ -432,8 +432,8 @@ public: priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * handler); @@ -473,8 +473,8 @@ public: priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * handler); @@ -493,8 +493,8 @@ public: HttpHandle requestDelete(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * user_handler); /// Queue a full HTTP PUT. Query arguments and body may @@ -516,8 +516,8 @@ public: priority_t priority, const std::string & url, BufferArray * body, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * user_handler); /// Queue a full HTTP PUT. Query arguments and body may @@ -535,8 +535,8 @@ public: HttpHandle requestCopy(policy_t policy_id, priority_t priority, const std::string & url, - HttpOptions::ptr_t & options, - HttpHeaders::ptr_t & headers, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, HttpHandler * user_handler); /// Queue a NoOp request. diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 5b5929383a..a2004db30a 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -102,8 +102,8 @@ HttpHandle requestPostWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions::ptr_t options, - HttpHeaders::ptr_t headers, + const HttpOptions::ptr_t &options, + const HttpHeaders::ptr_t &headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -129,8 +129,8 @@ HttpHandle requestPutWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions::ptr_t options, - HttpHeaders::ptr_t headers, + const HttpOptions::ptr_t &options, + const HttpHeaders::ptr_t &headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -155,8 +155,8 @@ HttpHandle requestPatchWithLLSD(HttpRequest * request, HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - HttpOptions::ptr_t options, - HttpHeaders::ptr_t headers, + const HttpOptions::ptr_t &options, + const HttpHeaders::ptr_t &headers, HttpHandler * handler) { HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 3dd13d0a0c..6d8f333c72 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -107,21 +107,21 @@ std::string responseToString(LLCore::HttpResponse * response); /// a now-useless HttpHandler object. /// LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest * request, - LLCore::HttpRequest::policy_t policy_id, - LLCore::HttpRequest::priority_t priority, - const std::string & url, - const LLSD & body, - LLCore::HttpOptions::ptr_t options, - LLCore::HttpHeaders::ptr_t headers, - LLCore::HttpHandler * handler); + LLCore::HttpRequest::policy_t policy_id, + LLCore::HttpRequest::priority_t priority, + const std::string & url, + const LLSD & body, + const LLCore::HttpOptions::ptr_t &options, + const LLCore::HttpHeaders::ptr_t &headers, + LLCore::HttpHandler * handler); inline LLCore::HttpHandle requestPostWithLLSD(LLCore::HttpRequest::ptr_t & request, LLCore::HttpRequest::policy_t policy_id, LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - LLCore::HttpOptions::ptr_t & options, - LLCore::HttpHeaders::ptr_t & headers, + const LLCore::HttpOptions::ptr_t & options, + const LLCore::HttpHeaders::ptr_t & headers, LLCore::HttpHandler * handler) { return requestPostWithLLSD(request.get(), policy_id, priority, @@ -164,8 +164,8 @@ LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest * request, LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - LLCore::HttpOptions::ptr_t options, - LLCore::HttpHeaders::ptr_t headers, + const LLCore::HttpOptions::ptr_t &options, + const LLCore::HttpHeaders::ptr_t &headers, LLCore::HttpHandler * handler); inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -173,8 +173,8 @@ inline LLCore::HttpHandle requestPutWithLLSD(LLCore::HttpRequest::ptr_t & reques LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - LLCore::HttpOptions::ptr_t & options, - LLCore::HttpHeaders::ptr_t & headers, + const LLCore::HttpOptions::ptr_t & options, + const LLCore::HttpHeaders::ptr_t & headers, LLCore::HttpHandler * handler) { return requestPutWithLLSD(request.get(), policy_id, priority, @@ -216,8 +216,8 @@ LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest * request, LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - LLCore::HttpOptions::ptr_t options, - LLCore::HttpHeaders::ptr_t headers, + const LLCore::HttpOptions::ptr_t &options, + const LLCore::HttpHeaders::ptr_t &headers, LLCore::HttpHandler * handler); inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & request, @@ -225,8 +225,8 @@ inline LLCore::HttpHandle requestPatchWithLLSD(LLCore::HttpRequest::ptr_t & requ LLCore::HttpRequest::priority_t priority, const std::string & url, const LLSD & body, - LLCore::HttpOptions::ptr_t & options, - LLCore::HttpHeaders::ptr_t & headers, + const LLCore::HttpOptions::ptr_t & options, + const LLCore::HttpHeaders::ptr_t & headers, LLCore::HttpHandler * handler) { return requestPatchWithLLSD(request.get(), policy_id, priority, -- cgit v1.3 From 248d61fe0eadd128c7704e37922ba7fdef35d630 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 12 Aug 2015 16:32:49 -0700 Subject: MAINT-5500: Finish converting the AIS responders to the new coroutine model, Cleaned up dead an unused code. MAINT-4952: Added COPY and MOVE methods to Core:Http adapter --- indra/llcorehttp/_httpoprequest.cpp | 18 + indra/llcorehttp/_httpoprequest.h | 9 +- indra/llcorehttp/httprequest.cpp | 31 ++ indra/llcorehttp/httprequest.h | 27 +- indra/llmessage/llcorehttputil.cpp | 94 ++++- indra/llmessage/llcorehttputil.h | 52 ++- indra/newview/llaisapi.cpp | 659 +++++++++--------------------------- indra/newview/llaisapi.h | 146 ++------ indra/newview/llappearancemgr.cpp | 24 +- indra/newview/llviewerinventory.cpp | 84 ++--- indra/newview/llviewerregion.cpp | 2 +- 11 files changed, 441 insertions(+), 705 deletions(-) (limited to 'indra/llcorehttp/httprequest.cpp') diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index e588ed8a9b..86110f5b46 100755 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -380,6 +380,19 @@ HttpStatus HttpOpRequest::setupCopy(HttpRequest::policy_t policy_id, } +HttpStatus HttpOpRequest::setupMove(HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t &headers) +{ + setupCommon(policy_id, priority, url, NULL, options, headers); + mReqMethod = HOR_MOVE; + + return HttpStatus(); +} + + void HttpOpRequest::setupCommon(HttpRequest::policy_t policy_id, HttpRequest::priority_t priority, const std::string & url, @@ -626,6 +639,11 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) check_curl_easy_code(code, CURLOPT_CUSTOMREQUEST); break; + case HOR_MOVE: + code = curl_easy_setopt(mCurlHandle, CURLOPT_CUSTOMREQUEST, "MOVE"); + check_curl_easy_code(code, CURLOPT_CUSTOMREQUEST); + break; + default: LL_ERRS(LOG_CORE) << "Invalid HTTP method in request: " << int(mReqMethod) << ". Can't recover." diff --git a/indra/llcorehttp/_httpoprequest.h b/indra/llcorehttp/_httpoprequest.h index a9083be02b..1b449a5abc 100755 --- a/indra/llcorehttp/_httpoprequest.h +++ b/indra/llcorehttp/_httpoprequest.h @@ -83,7 +83,8 @@ public: HOR_PUT, HOR_DELETE, HOR_PATCH, - HOR_COPY + HOR_COPY, + HOR_MOVE }; virtual void stageFromRequest(HttpService *); @@ -148,6 +149,12 @@ public: const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers); + HttpStatus setupMove(HttpRequest::policy_t policy_id, + HttpRequest::priority_t priority, + const std::string & url, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers); + // Internal method used to setup the libcurl options for a request. // Does all the libcurl handle setup in one place. // diff --git a/indra/llcorehttp/httprequest.cpp b/indra/llcorehttp/httprequest.cpp index f0dfde6153..63233259fb 100755 --- a/indra/llcorehttp/httprequest.cpp +++ b/indra/llcorehttp/httprequest.cpp @@ -419,6 +419,37 @@ HttpHandle HttpRequest::requestCopy(policy_t policy_id, return handle; } +HttpHandle HttpRequest::requestMove(policy_t policy_id, + priority_t priority, + const std::string & url, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, + HttpHandler * user_handler) +{ + HttpStatus status; + HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); + + HttpOpRequest * op = new HttpOpRequest(); + if (!(status = op->setupMove(policy_id, priority, url, options, headers))) + { + op->release(); + mLastReqStatus = status; + return handle; + } + op->setReplyPath(mReplyQueue, user_handler); + if (!(status = mRequestQueue->addOp(op))) // transfers refcount + { + op->release(); + mLastReqStatus = status; + return handle; + } + + mLastReqStatus = status; + handle = static_cast(op); + + return handle; +} + HttpHandle HttpRequest::requestNoOp(HttpHandler * user_handler) { diff --git a/indra/llcorehttp/httprequest.h b/indra/llcorehttp/httprequest.h index 20a223c482..6c2449266f 100755 --- a/indra/llcorehttp/httprequest.h +++ b/indra/llcorehttp/httprequest.h @@ -478,7 +478,7 @@ public: HttpHandler * handler); - /// Queue a full HTTP PUT. Query arguments and body may + /// Queue a full HTTP DELETE. Query arguments and body may /// be provided. Caller is responsible for escaping and /// encoding and communicating the content types. /// @@ -497,7 +497,7 @@ public: const HttpHeaders::ptr_t & headers, HttpHandler * user_handler); - /// Queue a full HTTP PUT. Query arguments and body may + /// Queue a full HTTP PATCH. Query arguments and body may /// be provided. Caller is responsible for escaping and /// encoding and communicating the content types. /// @@ -520,7 +520,7 @@ public: const HttpHeaders::ptr_t & headers, HttpHandler * user_handler); - /// Queue a full HTTP PUT. Query arguments and body may + /// Queue a full HTTP COPY. Query arguments and body may /// be provided. Caller is responsible for escaping and /// encoding and communicating the content types. /// @@ -538,7 +538,26 @@ public: const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, HttpHandler * user_handler); - + + /// Queue a full HTTP MOVE. Query arguments and body may + /// be provided. Caller is responsible for escaping and + /// encoding and communicating the content types. + /// + /// @param policy_id @see requestGet() + /// @param priority " + /// @param url " + /// @param options @see requestGet()K(optional) + /// @param headers " + /// @param handler " + /// @return " + /// + HttpHandle requestMove(policy_t policy_id, + priority_t priority, + const std::string & url, + const HttpOptions::ptr_t & options, + const HttpHeaders::ptr_t & headers, + HttpHandler * user_handler); + /// Queue a NoOp request. /// The request is queued and serviced by the working thread which /// immediately processes it and returns the request to the reply diff --git a/indra/llmessage/llcorehttputil.cpp b/indra/llmessage/llcorehttputil.cpp index 50c866f370..d342888255 100644 --- a/indra/llmessage/llcorehttputil.cpp +++ b/indra/llmessage/llcorehttputil.cpp @@ -700,7 +700,6 @@ LLSD HttpCoroutineAdapter::postAndYield_(LLCore::HttpRequest::ptr_t &request, LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); - //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; return results; } @@ -737,7 +736,7 @@ LLSD HttpCoroutineAdapter::putAndYield_(LLCore::HttpRequest::ptr_t &request, saveState(hhandle, request, handler); LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); - //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; + return results; } @@ -792,7 +791,7 @@ LLSD HttpCoroutineAdapter::getAndYield_(LLCore::HttpRequest::ptr_t &request, saveState(hhandle, request, handler); LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); - //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; + return results; } @@ -827,7 +826,7 @@ LLSD HttpCoroutineAdapter::deleteAndYield_(LLCore::HttpRequest::ptr_t &request, saveState(hhandle, request, handler); LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); - //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; + return results; } @@ -865,10 +864,95 @@ LLSD HttpCoroutineAdapter::patchAndYield_(LLCore::HttpRequest::ptr_t &request, saveState(hhandle, request, handler); LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); cleanState(); - //LL_INFOS() << "Results for transaction " << transactionId << LL_ENDL; + + return results; +} + +LLSD HttpCoroutineAdapter::copyAndYield(LLCore::HttpRequest::ptr_t request, + const std::string & url, const std::string dest, + LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) +{ + LLEventStream replyPump(mAdapterName + "Reply", true); + HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); + + if (!headers) + headers.reset(new LLCore::HttpHeaders); + headers->append(HTTP_OUT_HEADER_DESTINATION, dest); + + return copyAndYield_(request, url, options, headers, httpHandler); +} + + +LLSD HttpCoroutineAdapter::copyAndYield_(LLCore::HttpRequest::ptr_t &request, + const std::string & url, + LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, + HttpCoroHandler::ptr_t &handler) +{ + HttpRequestPumper pumper(request); + + checkDefaultHeaders(headers); + + // 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->requestCopy(mPolicyId, mPriority, url, + options, headers, handler.get()); + + if (hhandle == LLCORE_HTTP_HANDLE_INVALID) + { + return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); + } + + saveState(hhandle, request, handler); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); + cleanState(); + + return results; +} + +LLSD HttpCoroutineAdapter::moveAndYield(LLCore::HttpRequest::ptr_t request, + const std::string & url, const std::string dest, + LLCore::HttpOptions::ptr_t options, LLCore::HttpHeaders::ptr_t headers) +{ + LLEventStream replyPump(mAdapterName + "Reply", true); + HttpCoroHandler::ptr_t httpHandler = HttpCoroHandler::ptr_t(new HttpCoroLLSDHandler(replyPump)); + + if (!headers) + headers.reset(new LLCore::HttpHeaders); + headers->append(HTTP_OUT_HEADER_DESTINATION, dest); + + return moveAndYield_(request, url, options, headers, httpHandler); +} + + +LLSD HttpCoroutineAdapter::moveAndYield_(LLCore::HttpRequest::ptr_t &request, + const std::string & url, + LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, + HttpCoroHandler::ptr_t &handler) +{ + HttpRequestPumper pumper(request); + + checkDefaultHeaders(headers); + + // 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->requestMove(mPolicyId, mPriority, url, + options, headers, handler.get()); + + if (hhandle == LLCORE_HTTP_HANDLE_INVALID) + { + return HttpCoroutineAdapter::buildImmediateErrorResult(request, url); + } + + saveState(hhandle, request, handler); + LLSD results = llcoro::waitForEventOn(handler->getReplyPump()); + cleanState(); + return results; } + void HttpCoroutineAdapter::checkDefaultHeaders(LLCore::HttpHeaders::ptr_t &headers) { if (!headers) diff --git a/indra/llmessage/llcorehttputil.h b/indra/llmessage/llcorehttputil.h index 8fe2354d6b..31a73bb900 100644 --- a/indra/llmessage/llcorehttputil.h +++ b/indra/llmessage/llcorehttputil.h @@ -457,7 +457,7 @@ public: LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); - /// Execute a Post transaction on the supplied URL and yield execution of + /// Execute a PATCH transaction on the supplied URL and yield execution of /// the coroutine until a result is available. /// /// @Note: the request's smart pointer is passed by value so that it will @@ -474,6 +474,46 @@ public: LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); } + /// Execute a COPY transaction on the supplied URL and yield execution of + /// the coroutine until a result is available. + /// + /// @Note: The destination is passed through the HTTP pipe as a header + /// The header used is defined as: HTTP_OUT_HEADER_DESTINATION("Destination"); + /// + /// @Note: the request's smart pointer is passed by value so that it will + /// not be deallocated during the yield. + LLSD copyAndYield(LLCore::HttpRequest::ptr_t request, + const std::string & url, const std::string dest, + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); + LLSD copyAndYield(LLCore::HttpRequest::ptr_t &request, + const std::string & url, const std::string & dest, + LLCore::HttpHeaders::ptr_t &headers) + { + return copyAndYield(request, url, dest, + LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); + } + + /// Execute a MOVE transaction on the supplied URL and yield execution of + /// the coroutine until a result is available. + /// + /// @Note: The destination is passed through the HTTP pipe in the headers. + /// The header used is defined as: HTTP_OUT_HEADER_DESTINATION("Destination"); + /// + /// @Note: the request's smart pointer is passed by value so that it will + /// not be deallocated during the yield. + LLSD moveAndYield(LLCore::HttpRequest::ptr_t request, + const std::string & url, const std::string dest, + LLCore::HttpOptions::ptr_t options = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), + LLCore::HttpHeaders::ptr_t headers = LLCore::HttpHeaders::ptr_t(new LLCore::HttpHeaders())); + LLSD moveAndYield(LLCore::HttpRequest::ptr_t &request, + const std::string & url, const std::string & dest, + LLCore::HttpHeaders::ptr_t &headers) + { + return moveAndYield(request, url, dest, + LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions()), headers); + } + /// void cancelYieldingOperation(); @@ -541,6 +581,16 @@ private: LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, HttpCoroHandler::ptr_t &handler); + LLSD copyAndYield_(LLCore::HttpRequest::ptr_t &request, + const std::string & url, + LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, + HttpCoroHandler::ptr_t &handler); + + LLSD moveAndYield_(LLCore::HttpRequest::ptr_t &request, + const std::string & url, + LLCore::HttpOptions::ptr_t &options, LLCore::HttpHeaders::ptr_t &headers, + HttpCoroHandler::ptr_t &handler); + static void trivialGetCoro(std::string url, LLCore::HttpRequest::policy_t policyId, completionCallback_t success, completionCallback_t failure); static void trivialPostCoro(std::string url, LLCore::HttpRequest::policy_t policyId, LLSD postData, completionCallback_t success, completionCallback_t failure); diff --git a/indra/newview/llaisapi.cpp b/indra/newview/llaisapi.cpp index 3565c04609..23ea692a16 100755 --- a/indra/newview/llaisapi.cpp +++ b/indra/newview/llaisapi.cpp @@ -37,11 +37,54 @@ #include "llviewercontrol.h" ///---------------------------------------------------------------------------- -#if 1 +/// Classes for AISv3 support. +///---------------------------------------------------------------------------- + +//========================================================================= +const std::string AISAPI::INVENTORY_CAP_NAME("InventoryAPIv3"); +const std::string AISAPI::LIBRARY_CAP_NAME("LibraryAPIv3"); + +//------------------------------------------------------------------------- +/*static*/ +bool AISAPI::isAvailable() +{ + if (gAgent.getRegion()) + { + return gAgent.getRegion()->isCapabilityAvailable(INVENTORY_CAP_NAME); + } + return false; +} + +/*static*/ +void AISAPI::getCapNames(LLSD& capNames) +{ + capNames.append(INVENTORY_CAP_NAME); + capNames.append(LIBRARY_CAP_NAME); +} + +/*static*/ +std::string AISAPI::getInvCap() +{ + if (gAgent.getRegion()) + { + return gAgent.getRegion()->getCapability(INVENTORY_CAP_NAME); + } + return std::string(); +} + +/*static*/ +std::string AISAPI::getLibCap() +{ + if (gAgent.getRegion()) + { + return gAgent.getRegion()->getCapability(LIBRARY_CAP_NAME); + } + return std::string(); +} + /*static*/ -void AISAPI::CreateInventoryCommand(const LLUUID& parentId, const LLSD& newInventory, completion_t callback) +void AISAPI::CreateInventory(const LLUUID& parentId, const LLSD& newInventory, completion_t callback) { -#if 1 std::string cap = getInvCap(); if (cap.empty()) { @@ -68,23 +111,22 @@ void AISAPI::CreateInventoryCommand(const LLUUID& parentId, const LLSD& newInven // Humans ignore next line. It is just a cast. static_cast //---- + // _1 -> httpAdapter + // _2 -> httpRequest + // _3 -> url + // _4 -> body + // _5 -> httpOptions + // _6 -> httpHeaders (&LLCoreHttpUtil::HttpCoroutineAdapter::postAndYield), _1, _2, _3, _4, _5, _6); LLCoprocedureManager::CoProcedure_t proc(boost::bind(&AISAPI::InvokeAISCommandCoro, - _1, postFn, url, parentId, newInventory, callback)); -#else - LLCoprocedureManager::CoProcedure_t proc(boost::bind(&AISAPI::CreateInventoryCommandCoro, - _1, parentId, newInventory, callback)); - -#endif + _1, postFn, url, parentId, newInventory, callback, COPYINVENTORY)); EnqueueAISCommand("CreateInventory", proc); - } /*static*/ -void AISAPI::SlamFolderCommand(const LLUUID& folderId, const LLSD& newInventory, completion_t callback) +void AISAPI::SlamFolder(const LLUUID& folderId, const LLSD& newInventory, completion_t callback) { -#if 1 std::string cap = getInvCap(); if (cap.empty()) { @@ -99,23 +141,24 @@ void AISAPI::SlamFolderCommand(const LLUUID& folderId, const LLSD& newInventory, // see comment above in CreateInventoryCommand invokationFn_t putFn = boost::bind( - // Humans ignore next line. It is just a cast. + // Humans ignore next line. It is just a cast to specify which LLCoreHttpUtil::HttpCoroutineAdapter routine overload. static_cast //---- + // _1 -> httpAdapter + // _2 -> httpRequest + // _3 -> url + // _4 -> body + // _5 -> httpOptions + // _6 -> httpHeaders (&LLCoreHttpUtil::HttpCoroutineAdapter::putAndYield), _1, _2, _3, _4, _5, _6); LLCoprocedureManager::CoProcedure_t proc(boost::bind(&AISAPI::InvokeAISCommandCoro, - _1, putFn, url, folderId, newInventory, callback)); - -#else - LLCoprocedureManager::CoProcedure_t proc(boost::bind(&AISAPI::SlamFolderCommandCoro, - _1, folderId, newInventory, callback)); -#endif + _1, putFn, url, folderId, newInventory, callback, SLAMFOLDER)); EnqueueAISCommand("SlamFolder", proc); } -void AISAPI::RemoveCategoryCommand(const LLUUID &categoryId, completion_t callback) +void AISAPI::RemoveCategory(const LLUUID &categoryId, completion_t callback) { std::string cap; @@ -130,21 +173,26 @@ void AISAPI::RemoveCategoryCommand(const LLUUID &categoryId, completion_t callba LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL; invokationFn_t delFn = boost::bind( - // Humans ignore next line. It is just a cast. + // Humans ignore next line. It is just a cast to specify which LLCoreHttpUtil::HttpCoroutineAdapter routine overload. static_cast //---- + // _1 -> httpAdapter + // _2 -> httpRequest + // _3 -> url + // _4 -> body + // _5 -> httpOptions + // _6 -> httpHeaders (&LLCoreHttpUtil::HttpCoroutineAdapter::deleteAndYield), _1, _2, _3, _5, _6); LLCoprocedureManager::CoProcedure_t proc(boost::bind(&AISAPI::InvokeAISCommandCoro, - _1, delFn, url, categoryId, LLSD(), callback)); + _1, delFn, url, categoryId, LLSD(), callback, REMOVECATEGORY)); EnqueueAISCommand("RemoveCategory", proc); } /*static*/ -void AISAPI::RemoveItemCommand(const LLUUID &itemId, completion_t callback) +void AISAPI::RemoveItem(const LLUUID &itemId, completion_t callback) { -#if 1 std::string cap; cap = getInvCap(); @@ -158,25 +206,64 @@ void AISAPI::RemoveItemCommand(const LLUUID &itemId, completion_t callback) LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL; invokationFn_t delFn = boost::bind( - // Humans ignore next line. It is just a cast. + // Humans ignore next line. It is just a cast to specify which LLCoreHttpUtil::HttpCoroutineAdapter routine overload. static_cast //---- + // _1 -> httpAdapter + // _2 -> httpRequest + // _3 -> url + // _4 -> body + // _5 -> httpOptions + // _6 -> httpHeaders (&LLCoreHttpUtil::HttpCoroutineAdapter::deleteAndYield), _1, _2, _3, _5, _6); LLCoprocedureManager::CoProcedure_t proc(boost::bind(&AISAPI::InvokeAISCommandCoro, - _1, delFn, url, itemId, LLSD(), callback)); - -#else - LLCoprocedureManager::CoProcedure_t proc(boost::bind(&AISAPI::RemoveItemCommandCoro, - _1, itemId, callback)); -#endif + _1, delFn, url, itemId, LLSD(), callback, REMOVEITEM)); EnqueueAISCommand("RemoveItem", proc); } +void AISAPI::CopyLibraryCategory(const LLUUID& sourceId, const LLUUID& destId, completion_t callback) +{ + std::string cap; + + cap = getLibCap(); + if (cap.empty()) + { + LL_WARNS("Inventory") << "Library cap not found!" << LL_ENDL; + return; + } + + LL_DEBUGS("Inventory") << "Copying library category: " << sourceId << " => " << destId << LL_ENDL; + + LLUUID tid; + tid.generate(); + + std::string url = cap + std::string("/category/") + sourceId.asString() + "?tid=" + tid.asString(); + LL_INFOS() << url << LL_ENDL; + + std::string destination = destId.asString(); + + invokationFn_t copyFn = boost::bind( + // Humans ignore next line. It is just a cast to specify which LLCoreHttpUtil::HttpCoroutineAdapter routine overload. + static_cast + //---- + // _1 -> httpAdapter + // _2 -> httpRequest + // _3 -> url + // _4 -> body + // _5 -> httpOptions + // _6 -> httpHeaders + (&LLCoreHttpUtil::HttpCoroutineAdapter::copyAndYield), _1, _2, _3, destination, _5, _6); + + LLCoprocedureManager::CoProcedure_t proc(boost::bind(&AISAPI::InvokeAISCommandCoro, + _1, copyFn, url, destId, LLSD(), callback, COPYLIBRARYCATEGORY)); + + EnqueueAISCommand("CopyLibraryCategory", proc); +} /*static*/ -void AISAPI::PurgeDescendentsCommand(const LLUUID &categoryId, completion_t callback) +void AISAPI::PurgeDescendents(const LLUUID &categoryId, completion_t callback) { std::string cap; @@ -191,20 +278,26 @@ void AISAPI::PurgeDescendentsCommand(const LLUUID &categoryId, completion_t call LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL; invokationFn_t delFn = boost::bind( - // Humans ignore next line. It is just a cast. + // Humans ignore next line. It is just a cast to specify which LLCoreHttpUtil::HttpCoroutineAdapter routine overload. static_cast //---- + // _1 -> httpAdapter + // _2 -> httpRequest + // _3 -> url + // _4 -> body + // _5 -> httpOptions + // _6 -> httpHeaders (&LLCoreHttpUtil::HttpCoroutineAdapter::deleteAndYield), _1, _2, _3, _5, _6); LLCoprocedureManager::CoProcedure_t proc(boost::bind(&AISAPI::InvokeAISCommandCoro, - _1, delFn, url, categoryId, LLSD(), callback)); + _1, delFn, url, categoryId, LLSD(), callback, PURGEDESCENDENTS)); EnqueueAISCommand("PurgeDescendents", proc); } /*static*/ -void AISAPI::UpdateCategoryCommand(const LLUUID &categoryId, const LLSD &updates, completion_t callback) +void AISAPI::UpdateCategory(const LLUUID &categoryId, const LLSD &updates, completion_t callback) { std::string cap; @@ -217,19 +310,25 @@ void AISAPI::UpdateCategoryCommand(const LLUUID &categoryId, const LLSD &updates std::string url = cap + std::string("/category/") + categoryId.asString(); invokationFn_t patchFn = boost::bind( - // Humans ignore next line. It is just a cast. + // Humans ignore next line. It is just a cast to specify which LLCoreHttpUtil::HttpCoroutineAdapter routine overload. static_cast //---- + // _1 -> httpAdapter + // _2 -> httpRequest + // _3 -> url + // _4 -> body + // _5 -> httpOptions + // _6 -> httpHeaders (&LLCoreHttpUtil::HttpCoroutineAdapter::patchAndYield), _1, _2, _3, _4, _5, _6); LLCoprocedureManager::CoProcedure_t proc(boost::bind(&AISAPI::InvokeAISCommandCoro, - _1, patchFn, url, categoryId, updates, callback)); + _1, patchFn, url, categoryId, updates, callback, UPDATECATEGORY)); EnqueueAISCommand("UpdateCategory", proc); } /*static*/ -void AISAPI::UpdateItemCommand(const LLUUID &itemId, const LLSD &updates, completion_t callback) +void AISAPI::UpdateItem(const LLUUID &itemId, const LLSD &updates, completion_t callback) { std::string cap; @@ -243,13 +342,19 @@ void AISAPI::UpdateItemCommand(const LLUUID &itemId, const LLSD &updates, comple std::string url = cap + std::string("/item/") + itemId.asString(); invokationFn_t patchFn = boost::bind( - // Humans ignore next line. It is just a cast. + // Humans ignore next line. It is just a cast to specify which LLCoreHttpUtil::HttpCoroutineAdapter routine overload. static_cast //---- + // _1 -> httpAdapter + // _2 -> httpRequest + // _3 -> url + // _4 -> body + // _5 -> httpOptions + // _6 -> httpHeaders (&LLCoreHttpUtil::HttpCoroutineAdapter::patchAndYield), _1, _2, _3, _4, _5, _6); LLCoprocedureManager::CoProcedure_t proc(boost::bind(&AISAPI::InvokeAISCommandCoro, - _1, patchFn, url, itemId, updates, callback)); + _1, patchFn, url, itemId, updates, callback, UPDATEITEM)); EnqueueAISCommand("UpdateItem", proc); } @@ -262,31 +367,10 @@ void AISAPI::EnqueueAISCommand(const std::string &procName, LLCoprocedureManager } -/*static*/ -std::string AISAPI::getInvCap() -{ - if (gAgent.getRegion()) - { - return gAgent.getRegion()->getCapability("InventoryAPIv3"); - } - - return std::string(); -} - -/*static*/ -std::string AISAPI::getLibCap() -{ - if (gAgent.getRegion()) - { - return gAgent.getRegion()->getCapability("LibraryAPIv3"); - } - return std::string(); -} - /*static*/ void AISAPI::InvokeAISCommandCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter, invokationFn_t invoke, std::string url, - LLUUID targetId, LLSD body, completion_t callback) + LLUUID targetId, LLSD body, completion_t callback, COMMAND_TYPE type) { LLCore::HttpOptions::ptr_t httpOptions(new LLCore::HttpOptions); LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest()); @@ -313,455 +397,20 @@ void AISAPI::InvokeAISCommandCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t ht gInventory.onAISUpdateReceived("AISCommand", result); if (callback) - { // UUID always null - callback(LLUUID::null); - } - -} - -#if 0 -/*static*/ -void AISAPI::CreateInventoryCommandCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter, LLUUID parentId, LLSD newInventory, completion_t callback) -{ - std::string cap; - LLCore::HttpOptions::ptr_t httpOptions(new LLCore::HttpOptions); - LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest()); - - httpOptions->setTimeout(HTTP_REQUEST_EXPIRY_SECS); - - cap = getInvCap(); - if (cap.empty()) - { - LL_WARNS("Inventory") << "Inventory cap not found!" << LL_ENDL; - return; - } - - LLUUID tid; - tid.generate(); + { + LLUUID id(LLUUID::null); - std::string url = cap + std::string("/category/") + parentId.asString() + "?tid=" + tid.asString(); - LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL; + if (result.has("category_id") && (type == COPYLIBRARYCATEGORY)) + { + id = result["category_id"]; + } - LLSD result = httpAdapter->postAndYield(httpRequest, url, newInventory, httpOptions); - LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - - if (!status || !result.isMap()) - { - if (!result.isMap()) - { - status = LLCore::HttpStatus(HTTP_INTERNAL_ERROR, "Malformed response contents"); - } - LL_WARNS("Inventory") << "Inventory error: " << status.toString() << LL_ENDL; - LL_WARNS("Inventory") << ll_pretty_print_sd(result) << LL_ENDL; + callback(id); } - gInventory.onAISUpdateReceived("AISCommand", result); - - if (callback) - { // UUID always null - callback(LLUUID::null); - } - -} - -/*static*/ -void AISAPI::SlamFolderCommandCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter, LLUUID folderId, LLSD newInventory, completion_t callback) -{ - std::string cap; - LLCore::HttpOptions::ptr_t httpOptions(new LLCore::HttpOptions); - LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest()); - - httpOptions->setTimeout(HTTP_REQUEST_EXPIRY_SECS); - - cap = getInvCap(); - if (cap.empty()) - { - LL_WARNS("Inventory") << "Inventory cap not found!" << LL_ENDL; - return; - } - - LLUUID tid; - tid.generate(); - - std::string url = cap + std::string("/category/") + folderId.asString() + "/links?tid=" + tid.asString(); - - LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL; - - LLSD result = httpAdapter->putAndYield(httpRequest, url, newInventory, httpOptions); - LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - - if (!status || !result.isMap()) - { - if (!result.isMap()) - { - status = LLCore::HttpStatus(HTTP_INTERNAL_ERROR, "Malformed response contents"); - } - LL_WARNS("Inventory") << "Inventory error: " << status.toString() << LL_ENDL; - LL_WARNS("Inventory") << ll_pretty_print_sd(result) << LL_ENDL; - } - - gInventory.onAISUpdateReceived("AISCommand", result); - - if (callback) - { // UUID always null - callback(LLUUID::null); - } - -} - -void AISAPI::RemoveItemCommandCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter, LLUUID itemId, completion_t callback) -{ - std::string cap; - LLCore::HttpOptions::ptr_t httpOptions(new LLCore::HttpOptions); - LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest()); - - httpOptions->setTimeout(HTTP_REQUEST_EXPIRY_SECS); - - cap = getInvCap(); - if (cap.empty()) - { - LL_WARNS("Inventory") << "Inventory cap not found!" << LL_ENDL; - return; - } - - std::string url = cap + std::string("/item/") + itemId.asString(); - LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL; - - LLSD result = httpAdapter->deleteAndYield(httpRequest, url, httpOptions); - LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - - if (!status || !result.isMap()) - { - if (!result.isMap()) - { - status = LLCore::HttpStatus(HTTP_INTERNAL_ERROR, "Malformed response contents"); - } - LL_WARNS("Inventory") << "Inventory error: " << status.toString() << LL_ENDL; - LL_WARNS("Inventory") << ll_pretty_print_sd(result) << LL_ENDL; - } - - gInventory.onAISUpdateReceived("AISCommand", result); - - if (callback) - { // UUID always null - callback(LLUUID::null); - } -} -#endif -#endif -///---------------------------------------------------------------------------- -/// Classes for AISv3 support. -///---------------------------------------------------------------------------- - -// AISCommand - base class for retry-able HTTP requests using the AISv3 cap. -AISCommand::AISCommand(LLPointer callback): - mCommandFunc(NULL), - mCallback(callback) -{ - mRetryPolicy = new LLAdaptiveRetryPolicy(1.0, 32.0, 2.0, 10); -} - -bool AISCommand::run_command() -{ - if (NULL == mCommandFunc) - { - // This may happen if a command failed to initiate itself. - LL_WARNS("Inventory") << "AIS command attempted with null command function" << LL_ENDL; - return false; - } - else - { - mCommandFunc(); - return true; - } -} - -void AISCommand::setCommandFunc(command_func_type command_func) -{ - mCommandFunc = command_func; -} - -// virtual -bool AISCommand::getResponseUUID(const LLSD& content, LLUUID& id) -{ - return false; -} - -/* virtual */ -void AISCommand::httpSuccess() -{ - // Command func holds a reference to self, need to release it - // after a success or final failure. - setCommandFunc(no_op); - - const LLSD& content = getContent(); - if (!content.isMap()) - { - failureResult(HTTP_INTERNAL_ERROR, "Malformed response contents", content); - return; - } - mRetryPolicy->onSuccess(); - - gInventory.onAISUpdateReceived("AISCommand", content); - - if (mCallback) - { - LLUUID id; // will default to null if parse fails. - getResponseUUID(content,id); - mCallback->fire(id); - } -} - -/*virtual*/ -void AISCommand::httpFailure() -{ - LL_WARNS("Inventory") << dumpResponse() << LL_ENDL; - S32 status = getStatus(); - const LLSD& headers = getResponseHeaders(); - mRetryPolicy->onFailure(status, headers); - F32 seconds_to_wait; - if (mRetryPolicy->shouldRetry(seconds_to_wait)) - { - doAfterInterval(boost::bind(&AISCommand::run_command,this),seconds_to_wait); - } - else - { - // Command func holds a reference to self, need to release it - // after a success or final failure. - // *TODO: Notify user? This seems bad. - setCommandFunc(no_op); - } -} - -//static -bool AISCommand::isAPIAvailable() -{ - if (gAgent.getRegion()) - { - return gAgent.getRegion()->isCapabilityAvailable("InventoryAPIv3"); - } - return false; -} - -//static -bool AISCommand::getInvCap(std::string& cap) -{ - if (gAgent.getRegion()) - { - cap = gAgent.getRegion()->getCapability("InventoryAPIv3"); - } - if (!cap.empty()) - { - return true; - } - return false; -} - -//static -bool AISCommand::getLibCap(std::string& cap) -{ - if (gAgent.getRegion()) - { - cap = gAgent.getRegion()->getCapability("LibraryAPIv3"); - } - if (!cap.empty()) - { - return true; - } - return false; -} - -//static -void AISCommand::getCapabilityNames(LLSD& capabilityNames) -{ - capabilityNames.append("InventoryAPIv3"); - capabilityNames.append("LibraryAPIv3"); -} - -// RemoveItemCommand::RemoveItemCommand(const LLUUID& item_id, -// LLPointer callback): -// AISCommand(callback) -// { -// std::string cap; -// if (!getInvCap(cap)) -// { -// LL_WARNS() << "No cap found" << LL_ENDL; -// return; -// } -// std::string url = cap + std::string("/item/") + item_id.asString(); -// LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL; -// LLHTTPClient::ResponderPtr responder = this; -// LLSD headers; -// F32 timeout = HTTP_REQUEST_EXPIRY_SECS; -// command_func_type cmd = boost::bind(&LLHTTPClient::del, url, responder, headers, timeout); -// setCommandFunc(cmd); -// } - -// RemoveCategoryCommand::RemoveCategoryCommand(const LLUUID& item_id, -// LLPointer callback): -// AISCommand(callback) -// { -// std::string cap; -// if (!getInvCap(cap)) -// { -// LL_WARNS() << "No cap found" << LL_ENDL; -// return; -// } -// std::string url = cap + std::string("/category/") + item_id.asString(); -// LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL; -// LLHTTPClient::ResponderPtr responder = this; -// LLSD headers; -// F32 timeout = HTTP_REQUEST_EXPIRY_SECS; -// command_func_type cmd = boost::bind(&LLHTTPClient::del, url, responder, headers, timeout); -// setCommandFunc(cmd); -// } - -// PurgeDescendentsCommand::PurgeDescendentsCommand(const LLUUID& item_id, -// LLPointer callback): -// AISCommand(callback) -// { -// std::string cap; -// if (!getInvCap(cap)) -// { -// LL_WARNS() << "No cap found" << LL_ENDL; -// return; -// } -// std::string url = cap + std::string("/category/") + item_id.asString() + "/children"; -// LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL; -// LLCurl::ResponderPtr responder = this; -// LLSD headers; -// F32 timeout = HTTP_REQUEST_EXPIRY_SECS; -// command_func_type cmd = boost::bind(&LLHTTPClient::del, url, responder, headers, timeout); -// setCommandFunc(cmd); -// } - -// UpdateItemCommand::UpdateItemCommand(const LLUUID& item_id, -// const LLSD& updates, -// LLPointer callback): -// mUpdates(updates), -// AISCommand(callback) -// { -// std::string cap; -// if (!getInvCap(cap)) -// { -// LL_WARNS() << "No cap found" << LL_ENDL; -// return; -// } -// std::string url = cap + std::string("/item/") + item_id.asString(); -// LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL; -// LL_DEBUGS("Inventory") << "request: " << ll_pretty_print_sd(mUpdates) << LL_ENDL; -// LLCurl::ResponderPtr responder = this; -// LLSD headers; -// headers["Content-Type"] = "application/llsd+xml"; -// F32 timeout = HTTP_REQUEST_EXPIRY_SECS; -// command_func_type cmd = boost::bind(&LLHTTPClient::patch, url, mUpdates, responder, headers, timeout); -// setCommandFunc(cmd); -// } - -// UpdateCategoryCommand::UpdateCategoryCommand(const LLUUID& cat_id, -// const LLSD& updates, -// LLPointer callback): -// mUpdates(updates), -// AISCommand(callback) -// { -// std::string cap; -// if (!getInvCap(cap)) -// { -// LL_WARNS() << "No cap found" << LL_ENDL; -// return; -// } -// std::string url = cap + std::string("/category/") + cat_id.asString(); -// LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL; -// LLCurl::ResponderPtr responder = this; -// LLSD headers; -// headers["Content-Type"] = "application/llsd+xml"; -// F32 timeout = HTTP_REQUEST_EXPIRY_SECS; -// command_func_type cmd = boost::bind(&LLHTTPClient::patch, url, mUpdates, responder, headers, timeout); -// setCommandFunc(cmd); -// } - -// CreateInventoryCommand::CreateInventoryCommand(const LLUUID& parent_id, -// const LLSD& new_inventory, -// LLPointer callback): -// mNewInventory(new_inventory), -// AISCommand(callback) -// { -// std::string cap; -// if (!getInvCap(cap)) -// { -// LL_WARNS() << "No cap found" << LL_ENDL; -// return; -// } -// LLUUID tid; -// tid.generate(); -// std::string url = cap + std::string("/category/") + parent_id.asString() + "?tid=" + tid.asString(); -// LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL; -// LLCurl::ResponderPtr responder = this; -// LLSD headers; -// headers["Content-Type"] = "application/llsd+xml"; -// F32 timeout = HTTP_REQUEST_EXPIRY_SECS; -// command_func_type cmd = boost::bind(&LLHTTPClient::post, url, mNewInventory, responder, headers, timeout); -// setCommandFunc(cmd); -// } - -// SlamFolderCommand::SlamFolderCommand(const LLUUID& folder_id, const LLSD& contents, LLPointer callback): -// mContents(contents), -// AISCommand(callback) -// { -// std::string cap; -// if (!getInvCap(cap)) -// { -// LL_WARNS() << "No cap found" << LL_ENDL; -// return; -// } -// LLUUID tid; -// tid.generate(); -// std::string url = cap + std::string("/category/") + folder_id.asString() + "/links?tid=" + tid.asString(); -// LL_INFOS() << url << LL_ENDL; -// LLCurl::ResponderPtr responder = this; -// LLSD headers; -// headers["Content-Type"] = "application/llsd+xml"; -// F32 timeout = HTTP_REQUEST_EXPIRY_SECS; -// command_func_type cmd = boost::bind(&LLHTTPClient::put, url, mContents, responder, headers, timeout); -// setCommandFunc(cmd); -// } - -CopyLibraryCategoryCommand::CopyLibraryCategoryCommand(const LLUUID& source_id, - const LLUUID& dest_id, - LLPointer callback): - AISCommand(callback) -{ - std::string cap; - if (!getLibCap(cap)) - { - LL_WARNS() << "No cap found" << LL_ENDL; - return; - } - LL_DEBUGS("Inventory") << "Copying library category: " << source_id << " => " << dest_id << LL_ENDL; - LLUUID tid; - tid.generate(); - std::string url = cap + std::string("/category/") + source_id.asString() + "?tid=" + tid.asString(); - LL_INFOS() << url << LL_ENDL; - LLCurl::ResponderPtr responder = this; - LLSD headers; - F32 timeout = HTTP_REQUEST_EXPIRY_SECS; - command_func_type cmd = boost::bind(&LLHTTPClient::copy, url, dest_id.asString(), responder, headers, timeout); - setCommandFunc(cmd); -} - -bool CopyLibraryCategoryCommand::getResponseUUID(const LLSD& content, LLUUID& id) -{ - if (content.has("category_id")) - { - id = content["category_id"]; - return true; - } - return false; } +//------------------------------------------------------------------------- AISUpdate::AISUpdate(const LLSD& update) { parseUpdate(update); diff --git a/indra/newview/llaisapi.h b/indra/newview/llaisapi.h index ebb952a3ec..fc2bedc9ec 100755 --- a/indra/newview/llaisapi.h +++ b/indra/newview/llaisapi.h @@ -38,21 +38,38 @@ #include "llcorehttputil.h" #include "llcoproceduremanager.h" -#if 1 class AISAPI { public: typedef boost::function completion_t; - static void CreateInventoryCommand(const LLUUID& parentId, const LLSD& newInventory, completion_t callback); - static void SlamFolderCommand(const LLUUID& folderId, const LLSD& newInventory, completion_t callback); - static void RemoveCategoryCommand(const LLUUID &categoryId, completion_t callback); - static void RemoveItemCommand(const LLUUID &itemId, completion_t callback); - static void PurgeDescendentsCommand(const LLUUID &categoryId, completion_t callback); - static void UpdateCategoryCommand(const LLUUID &categoryId, const LLSD &updates, completion_t callback); - static void UpdateItemCommand(const LLUUID &itemId, const LLSD &updates, completion_t callback); + static bool isAvailable(); + static void getCapNames(LLSD& capNames); + + static void CreateInventory(const LLUUID& parentId, const LLSD& newInventory, completion_t callback); + static void SlamFolder(const LLUUID& folderId, const LLSD& newInventory, completion_t callback); + static void RemoveCategory(const LLUUID &categoryId, completion_t callback); + static void RemoveItem(const LLUUID &itemId, completion_t callback); + static void PurgeDescendents(const LLUUID &categoryId, completion_t callback); + static void UpdateCategory(const LLUUID &categoryId, const LLSD &updates, completion_t callback); + static void UpdateItem(const LLUUID &itemId, const LLSD &updates, completion_t callback); + static void CopyLibraryCategory(const LLUUID& sourceId, const LLUUID& destId, completion_t callback); private: + typedef enum { + COPYINVENTORY, + SLAMFOLDER, + REMOVECATEGORY, + REMOVEITEM, + PURGEDESCENDENTS, + UPDATECATEGORY, + UPDATEITEM, + COPYLIBRARYCATEGORY + } COMMAND_TYPE; + + static const std::string INVENTORY_CAP_NAME; + static const std::string LIBRARY_CAP_NAME; + typedef boost::function < LLSD (LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t, LLCore::HttpRequest::ptr_t, const std::string, LLSD, LLCore::HttpOptions::ptr_t, LLCore::HttpHeaders::ptr_t) > invokationFn_t; @@ -61,118 +78,11 @@ private: static std::string getInvCap(); static std::string getLibCap(); - static void InvokeAISCommandCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter, invokationFn_t invoke, std::string url, LLUUID targetId, LLSD body, completion_t callback); + static void InvokeAISCommandCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter, + invokationFn_t invoke, std::string url, LLUUID targetId, LLSD body, + completion_t callback, COMMAND_TYPE type); -#if 0 - static void CreateInventoryCommandCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t adapter, LLUUID parentId, LLSD newInventory, completion_t callback); - static void SlamFolderCommandCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter, LLUUID folderId, LLSD newInventory, completion_t callback); - static void RemoveItemCommandCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter, LLUUID itemId, completion_t callback); -#endif }; -#endif - -class AISCommand: public LLHTTPClient::Responder -{ -public: - typedef boost::function command_func_type; - - AISCommand(LLPointer callback); - - virtual ~AISCommand() {} - - bool run_command(); - - void setCommandFunc(command_func_type command_func); - - // Need to do command-specific parsing to get an id here, for - // LLInventoryCallback::fire(). May or may not need to bother, - // since most LLInventoryCallbacks do their work in the - // destructor. - - /* virtual */ void httpSuccess(); - /* virtual */ void httpFailure(); - - static bool isAPIAvailable(); - static bool getInvCap(std::string& cap); - static bool getLibCap(std::string& cap); - static void getCapabilityNames(LLSD& capabilityNames); - -protected: - virtual bool getResponseUUID(const LLSD& content, LLUUID& id); - -private: - command_func_type mCommandFunc; - LLPointer mRetryPolicy; - LLPointer mCallback; -}; - -// class RemoveItemCommand: public AISCommand -// { -// public: -// RemoveItemCommand(const LLUUID& item_id, -// LLPointer callback); -// }; - -// class RemoveCategoryCommand: public AISCommand -// { -// public: -// RemoveCategoryCommand(const LLUUID& item_id, -// LLPointer callback); -// }; - -// class PurgeDescendentsCommand: public AISCommand -// { -// public: -// PurgeDescendentsCommand(const LLUUID& item_id, -// LLPointer callback); -// }; - -// class UpdateItemCommand: public AISCommand -// { -// public: -// UpdateItemCommand(const LLUUID& item_id, -// const LLSD& updates, -// LLPointer callback); -// private: -// LLSD mUpdates; -// }; - -// class UpdateCategoryCommand: public AISCommand -// { -// public: -// UpdateCategoryCommand(const LLUUID& cat_id, -// const LLSD& updates, -// LLPointer callback); -// private: -// LLSD mUpdates; -// }; - -// class SlamFolderCommand: public AISCommand -// { -// public: -// SlamFolderCommand(const LLUUID& folder_id, const LLSD& contents, LLPointer callback); -// -// private: -// LLSD mContents; -// }; - -class CopyLibraryCategoryCommand: public AISCommand -{ -public: - CopyLibraryCategoryCommand(const LLUUID& source_id, const LLUUID& dest_id, LLPointer callback); - -protected: - /* virtual */ bool getResponseUUID(const LLSD& content, LLUUID& id); -}; - -// class CreateInventoryCommand: public AISCommand -// { -// public: -// CreateInventoryCommand(const LLUUID& parent_id, const LLSD& new_inventory, LLPointer callback); -// -// private: -// LLSD mNewInventory; -// }; class AISUpdate { diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index ff420a3600..2883886fa1 100755 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -63,6 +63,17 @@ #pragma warning (disable:4702) #endif +#if 1 +// *TODO$: LLInventoryCallback should be deprecated to conform to the new boost::bind/coroutine model. +// temp code in transition +void doAppearanceCb(LLPointer cb, LLUUID id) +{ + if (cb.notNull()) + cb->fire(id); +} +#endif + + std::string self_av_string() { // On logout gAgentAvatarp can already be invalid @@ -2457,8 +2468,7 @@ void LLAppearanceMgr::wearInventoryCategory(LLInventoryCategory* category, bool << " )" << LL_ENDL; // If we are copying from library, attempt to use AIS to copy the category. - bool ais_ran=false; - if (copy && AISCommand::isAPIAvailable()) + if (copy && AISAPI::isAvailable()) { LLUUID parent_id; parent_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_CLOTHING); @@ -2470,11 +2480,11 @@ void LLAppearanceMgr::wearInventoryCategory(LLInventoryCategory* category, bool LLPointer copy_cb = new LLWearCategoryAfterCopy(append); LLPointer track_cb = new LLTrackPhaseWrapper( std::string("wear_inventory_category_callback"), copy_cb); - LLPointer cmd_ptr = new CopyLibraryCategoryCommand(category->getUUID(), parent_id, track_cb); - ais_ran=cmd_ptr->run_command(); - } - if (!ais_ran) + AISAPI::completion_t cr = boost::bind(&doAppearanceCb, track_cb, _1); + AISAPI::CopyLibraryCategory(category->getUUID(), parent_id, cr); + } + else { selfStartPhase("wear_inventory_category_fetch"); callAfterCategoryFetch(category->getUUID(),boost::bind(&LLAppearanceMgr::wearCategoryFinal, @@ -3602,7 +3612,7 @@ void LLAppearanceMgr::makeNewOutfitLinks(const std::string& new_folder_name, boo // First, make a folder in the My Outfits directory. const LLUUID parent_id = gInventory.findCategoryUUIDForType(LLFolderType::FT_MY_OUTFITS); - if (AISCommand::isAPIAvailable()) + if (AISAPI::isAvailable()) { // cap-based category creation was buggy until recently. use // existence of AIS as an indicator the fix is present. Does diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 729af3c8ed..ac19d84a5e 100755 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -80,6 +80,7 @@ static const char * const LOG_LOCAL("InventoryLocalize"); static const char * const LOG_NOTECARD("copy_inventory_from_notecard"); #if 1 +// *TODO$: LLInventoryCallback should be deprecated to conform to the new boost::bind/coroutine model. // temp code in transition void doInventoryCb(LLPointer cb, LLUUID id) { @@ -1289,21 +1290,14 @@ void link_inventory_array(const LLUUID& category, #endif } - bool ais_ran = false; - if (AISCommand::isAPIAvailable()) + if (AISAPI::isAvailable()) { LLSD new_inventory = LLSD::emptyMap(); new_inventory["links"] = links; -#if 1 AISAPI::completion_t cr = boost::bind(&doInventoryCb, cb, _1); - AISAPI::CreateInventoryCommand(category, new_inventory, cr); -#else - LLPointer cmd_ptr = new CreateInventoryCommand(category, new_inventory, cb); - ais_ran = cmd_ptr->run_command(); -#endif + AISAPI::CreateInventory(category, new_inventory, cr); } - - if (!ais_ran) + else { LLMessageSystem* msg = gMessageSystem; for (LLSD::array_iterator iter = links.beginArray(); iter != links.endArray(); ++iter ) @@ -1360,8 +1354,7 @@ void update_inventory_item( LLPointer cb) { const LLUUID& item_id = update_item->getUUID(); - bool ais_ran = false; - if (AISCommand::isAPIAvailable()) + if (AISAPI::isAvailable()) { LLSD updates = update_item->asLLSD(); // Replace asset_id and/or shadow_id with transaction_id (hash_id) @@ -1375,15 +1368,10 @@ void update_inventory_item( updates.erase("shadow_id"); updates["hash_id"] = update_item->getTransactionID(); } -#if 1 AISAPI::completion_t cr = boost::bind(&doInventoryCb, cb, _1); - AISAPI::UpdateItemCommand(item_id, updates, cr); -#else - LLPointer cmd_ptr = new UpdateItemCommand(item_id, updates, cb); - ais_ran = cmd_ptr->run_command(); -#endif + AISAPI::UpdateItem(item_id, updates, cr); } - if (!ais_ran) + else { LLPointer obj = gInventory.getItem(item_id); LL_DEBUGS(LOG_INV) << "item_id: [" << item_id << "] name " << (update_item ? update_item->getName() : "(NOT FOUND)") << LL_ENDL; @@ -1419,18 +1407,12 @@ void update_inventory_item( const LLSD& updates, LLPointer cb) { - bool ais_ran = false; - if (AISCommand::isAPIAvailable()) + if (AISAPI::isAvailable()) { -#if 1 AISAPI::completion_t cr = boost::bind(&doInventoryCb, cb, _1); - AISAPI::UpdateItemCommand(item_id, updates, cr); -#else - LLPointer cmd_ptr = new UpdateItemCommand(item_id, updates, cb); - ais_ran = cmd_ptr->run_command(); -#endif + AISAPI::UpdateItem(item_id, updates, cr); } - if (!ais_ran) + else { LLPointer obj = gInventory.getItem(item_id); LL_DEBUGS(LOG_INV) << "item_id: [" << item_id << "] name " << (obj ? obj->getName() : "(NOT FOUND)") << LL_ENDL; @@ -1480,16 +1462,11 @@ void update_inventory_category( LLPointer new_cat = new LLViewerInventoryCategory(obj); new_cat->fromLLSD(updates); // FIXME - restore this once the back-end work has been done. - if (AISCommand::isAPIAvailable()) + if (AISAPI::isAvailable()) { LLSD new_llsd = new_cat->asLLSD(); -#if 1 AISAPI::completion_t cr = boost::bind(&doInventoryCb, cb, _1); - AISAPI::UpdateCategoryCommand(cat_id, new_llsd, cr); -#else - LLPointer cmd_ptr = new UpdateCategoryCommand(cat_id, new_llsd, cb); - cmd_ptr->run_command(); -#endif + AISAPI::UpdateCategory(cat_id, new_llsd, cr); } else // no cap { @@ -1551,15 +1528,10 @@ void remove_inventory_item( { const LLUUID item_id(obj->getUUID()); LL_DEBUGS(LOG_INV) << "item_id: [" << item_id << "] name " << obj->getName() << LL_ENDL; - if (AISCommand::isAPIAvailable()) + if (AISAPI::isAvailable()) { -#if 1 AISAPI::completion_t cr = boost::bind(&doInventoryCb, cb, _1); - AISAPI::RemoveItemCommand(item_id, cr); -#else - LLPointer cmd_ptr = new RemoveItemCommand(item_id, cb); - cmd_ptr->run_command(); -#endif + AISAPI::RemoveItem(item_id, cr); if (immediate_delete) { @@ -1632,15 +1604,10 @@ void remove_inventory_category( LLNotificationsUtil::add("CannotRemoveProtectedCategories"); return; } - if (AISCommand::isAPIAvailable()) + if (AISAPI::isAvailable()) { -#if 1 AISAPI::completion_t cr = boost::bind(&doInventoryCb, cb, _1); - AISAPI::RemoveCategoryCommand(cat_id, cr); -#else - LLPointer cmd_ptr = new RemoveCategoryCommand(cat_id, cb); - cmd_ptr->run_command(); -#endif + AISAPI::RemoveCategory(cat_id, cr); } else // no cap { @@ -1740,15 +1707,10 @@ void purge_descendents_of(const LLUUID& id, LLPointer cb) } else { - if (AISCommand::isAPIAvailable()) + if (AISAPI::isAvailable()) { -#if 1 AISAPI::completion_t cr = boost::bind(&doInventoryCb, cb, _1); - AISAPI::PurgeDescendentsCommand(id, cr); -#else - LLPointer cmd_ptr = new PurgeDescendentsCommand(id, cb); - cmd_ptr->run_command(); -#endif + AISAPI::PurgeDescendents(id, cr); } else // no cap { @@ -1895,17 +1857,13 @@ void slam_inventory_folder(const LLUUID& folder_id, const LLSD& contents, LLPointer cb) { - if (AISCommand::isAPIAvailable()) + if (AISAPI::isAvailable()) { LL_DEBUGS(LOG_INV) << "using AISv3 to slam folder, id " << folder_id << " new contents: " << ll_pretty_print_sd(contents) << LL_ENDL; -#if 1 + AISAPI::completion_t cr = boost::bind(&doInventoryCb, cb, _1); - AISAPI::SlamFolderCommand(folder_id, contents, cr); -#else - LLPointer cmd_ptr = new SlamFolderCommand(folder_id, contents, cb); - cmd_ptr->run_command(); -#endif + AISAPI::SlamFolder(folder_id, contents, cr); } else // no cap { diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 5c7071c63d..32b57dae25 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -2822,7 +2822,7 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames) capabilityNames.append("FetchInventory2"); capabilityNames.append("FetchInventoryDescendents2"); capabilityNames.append("IncrementCOFVersion"); - AISCommand::getCapabilityNames(capabilityNames); + AISAPI::getCapNames(capabilityNames); capabilityNames.append("GetDisplayNames"); capabilityNames.append("GetExperiences"); -- cgit v1.3 From bbb9d4f21b018bfffc41f790aab7b54975504027 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 14 Oct 2015 17:46:24 -0700 Subject: 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) --- indra/llcorehttp/_httpoperation.cpp | 29 +- indra/llcorehttp/_httpoperation.h | 10 +- indra/llcorehttp/_httpreplyqueue.cpp | 1 - indra/llcorehttp/_httpreplyqueue.h | 17 +- indra/llcorehttp/httphandler.h | 3 + indra/llcorehttp/httprequest.cpp | 38 ++- indra/llcorehttp/httprequest.h | 34 +-- indra/llcrashlogger/llcrashlogger.cpp | 2 +- indra/llmessage/llcorehttputil.cpp | 28 +- indra/llmessage/llcorehttputil.h | 18 +- indra/llmessage/llhttpsdhandler.cpp | 30 +- indra/llmessage/llhttpsdhandler.h | 19 +- indra/newview/llappcorehttp.cpp | 11 +- indra/newview/llappcorehttp.h | 2 +- indra/newview/lleventpoll.cpp | 12 +- indra/newview/llinventorymodel.cpp | 6 +- indra/newview/llinventorymodel.h | 5 +- indra/newview/llinventorymodelbackgroundfetch.cpp | 11 +- indra/newview/llinventoryobserver.cpp | 2 +- indra/newview/llmaterialmgr.cpp | 325 +++++++++++++++++----- indra/newview/llmaterialmgr.h | 7 + indra/newview/llmediadataclient.cpp | 16 +- indra/newview/llmediadataclient.h | 8 +- indra/newview/llmeshrepository.cpp | 42 ++- indra/newview/llmeshrepository.h | 4 +- indra/newview/lltexturefetch.cpp | 47 ++-- indra/newview/llviewerinventory.cpp | 2 +- indra/newview/llxmlrpctransaction.cpp | 4 +- 28 files changed, 440 insertions(+), 293 deletions(-) (limited to 'indra/llcorehttp/httprequest.cpp') diff --git a/indra/llcorehttp/_httpoperation.cpp b/indra/llcorehttp/_httpoperation.cpp index fefe561f80..dc03b059a4 100755 --- a/indra/llcorehttp/_httpoperation.cpp +++ b/indra/llcorehttp/_httpoperation.cpp @@ -57,8 +57,8 @@ namespace LLCore HttpOperation::HttpOperation() : LLCoreInt::RefCounted(true), - mReplyQueue(NULL), - mUserHandler(NULL), + mReplyQueue(), + mUserHandler(), mReqPolicy(HttpRequest::DEFAULT_POLICY_ID), mReqPriority(0U), mTracing(HTTP_TRACE_OFF) @@ -69,30 +69,15 @@ HttpOperation::HttpOperation() HttpOperation::~HttpOperation() { - setReplyPath(NULL, NULL); + setReplyPath(HttpReplyQueue::ptr_t(), HttpHandler::ptr_t()); } -void HttpOperation::setReplyPath(HttpReplyQueue * reply_queue, - HttpHandler * user_handler) +void HttpOperation::setReplyPath(HttpReplyQueue::ptr_t reply_queue, + HttpHandler::ptr_t user_handler) { - if (reply_queue != mReplyQueue) - { - if (mReplyQueue) - { - mReplyQueue->release(); - } - - if (reply_queue) - { - reply_queue->addRef(); - } - - mReplyQueue = reply_queue; - } - - // Not refcounted - mUserHandler = user_handler; + mReplyQueue.swap(reply_queue); + mUserHandler.swap(user_handler); } diff --git a/indra/llcorehttp/_httpoperation.h b/indra/llcorehttp/_httpoperation.h index 937a61187d..f677e7aed8 100755 --- a/indra/llcorehttp/_httpoperation.h +++ b/indra/llcorehttp/_httpoperation.h @@ -72,6 +72,8 @@ class HttpService; class HttpOperation : public LLCoreInt::RefCounted { public: + typedef boost::shared_ptr HttpReplyQueuePtr_t; + /// Threading: called by consumer thread. HttpOperation(); @@ -110,8 +112,8 @@ public: /// /// Threading: called by consumer thread. /// - void setReplyPath(HttpReplyQueue * reply_queue, - HttpHandler * handler); + void setReplyPath(HttpReplyQueuePtr_t reply_queue, + HttpHandler::ptr_t handler); /// The three possible staging steps in an operation's lifecycle. /// Asynchronous requests like HTTP operations move from the @@ -163,8 +165,8 @@ protected: void addAsReply(); protected: - HttpReplyQueue * mReplyQueue; // Have refcount - HttpHandler * mUserHandler; // Naked pointer + HttpReplyQueuePtr_t mReplyQueue; + HttpHandler::ptr_t mUserHandler; public: // Request Data diff --git a/indra/llcorehttp/_httpreplyqueue.cpp b/indra/llcorehttp/_httpreplyqueue.cpp index 558b7bdee9..912655d328 100755 --- a/indra/llcorehttp/_httpreplyqueue.cpp +++ b/indra/llcorehttp/_httpreplyqueue.cpp @@ -39,7 +39,6 @@ namespace LLCore HttpReplyQueue::HttpReplyQueue() - : RefCounted(true) { } diff --git a/indra/llcorehttp/_httpreplyqueue.h b/indra/llcorehttp/_httpreplyqueue.h index 4220a09a3b..7ad65c581f 100755 --- a/indra/llcorehttp/_httpreplyqueue.h +++ b/indra/llcorehttp/_httpreplyqueue.h @@ -58,21 +58,17 @@ class HttpOperation; /// will be coded anyway so it shouldn't be too much of a /// burden. -class HttpReplyQueue : public LLCoreInt::RefCounted +class HttpReplyQueue : private boost::noncopyable { -public: - /// Caller acquires a Refcount on construction - HttpReplyQueue(); -protected: - virtual ~HttpReplyQueue(); // Use release() +public: + typedef boost::shared_ptr ptr_t; -private: - HttpReplyQueue(const HttpReplyQueue &); // Not defined - void operator=(const HttpReplyQueue &); // Not defined + HttpReplyQueue(); + virtual ~HttpReplyQueue(); public: - typedef std::vector OpContainer; + typedef std::vector OpContainer; /// Insert an object at the back of the reply queue. /// @@ -96,6 +92,7 @@ public: void fetchAll(OpContainer & ops); protected: + OpContainer mQueue; LLCoreInt::HttpMutex mQueueMutex; LLCoreInt::HttpConditionVariable mQueueCV; diff --git a/indra/llcorehttp/httphandler.h b/indra/llcorehttp/httphandler.h index 7bc9096703..65e043f5d3 100755 --- a/indra/llcorehttp/httphandler.h +++ b/indra/llcorehttp/httphandler.h @@ -58,6 +58,9 @@ class HttpResponse; class HttpHandler { public: + typedef boost::shared_ptr ptr_t; + typedef boost::weak_ptr wptr_t; + virtual ~HttpHandler() { } diff --git a/indra/llcorehttp/httprequest.cpp b/indra/llcorehttp/httprequest.cpp index 63233259fb..8380e48ddb 100755 --- a/indra/llcorehttp/httprequest.cpp +++ b/indra/llcorehttp/httprequest.cpp @@ -55,13 +55,13 @@ namespace LLCore HttpRequest::HttpRequest() - : mReplyQueue(NULL), + : mReplyQueue(), mRequestQueue(NULL) { mRequestQueue = HttpRequestQueue::instanceOf(); mRequestQueue->addRef(); - mReplyQueue = new HttpReplyQueue(); + mReplyQueue.reset( new HttpReplyQueue() ); } @@ -73,11 +73,7 @@ HttpRequest::~HttpRequest() mRequestQueue = NULL; } - if (mReplyQueue) - { - mReplyQueue->release(); - mReplyQueue = NULL; - } + mReplyQueue.reset(); } @@ -128,7 +124,7 @@ HttpStatus HttpRequest::setStaticPolicyOption(EPolicyOption opt, policy_t pclass } HttpHandle HttpRequest::setPolicyOption(EPolicyOption opt, policy_t pclass, - long value, HttpHandler * handler) + long value, HttpHandler::ptr_t handler) { HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -156,7 +152,7 @@ HttpHandle HttpRequest::setPolicyOption(EPolicyOption opt, policy_t pclass, HttpHandle HttpRequest::setPolicyOption(EPolicyOption opt, policy_t pclass, - const std::string & value, HttpHandler * handler) + const std::string & value, HttpHandler::ptr_t handler) { HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -199,7 +195,7 @@ HttpHandle HttpRequest::requestGet(policy_t policy_id, const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, - HttpHandler * user_handler) + HttpHandler::ptr_t user_handler) { HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -233,7 +229,7 @@ HttpHandle HttpRequest::requestGetByteRange(policy_t policy_id, size_t len, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, - HttpHandler * user_handler) + HttpHandler::ptr_t user_handler) { HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -266,7 +262,7 @@ HttpHandle HttpRequest::requestPost(policy_t policy_id, BufferArray * body, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, - HttpHandler * user_handler) + HttpHandler::ptr_t user_handler) { HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -299,7 +295,7 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id, BufferArray * body, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, - HttpHandler * user_handler) + HttpHandler::ptr_t user_handler) { HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -330,7 +326,7 @@ HttpHandle HttpRequest::requestDelete(policy_t policy_id, const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, - HttpHandler * user_handler) + HttpHandler::ptr_t user_handler) { HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -362,7 +358,7 @@ HttpHandle HttpRequest::requestPatch(policy_t policy_id, BufferArray * body, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, - HttpHandler * user_handler) + HttpHandler::ptr_t user_handler) { HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -393,7 +389,7 @@ HttpHandle HttpRequest::requestCopy(policy_t policy_id, const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, - HttpHandler * user_handler) + HttpHandler::ptr_t user_handler) { HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -424,7 +420,7 @@ HttpHandle HttpRequest::requestMove(policy_t policy_id, const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, - HttpHandler * user_handler) + HttpHandler::ptr_t user_handler) { HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -451,7 +447,7 @@ HttpHandle HttpRequest::requestMove(policy_t policy_id, } -HttpHandle HttpRequest::requestNoOp(HttpHandler * user_handler) +HttpHandle HttpRequest::requestNoOp(HttpHandler::ptr_t user_handler) { HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); @@ -521,7 +517,7 @@ HttpStatus HttpRequest::update(long usecs) // Request Management Methods // ==================================== -HttpHandle HttpRequest::requestCancel(HttpHandle request, HttpHandler * user_handler) +HttpHandle HttpRequest::requestCancel(HttpHandle request, HttpHandler::ptr_t user_handler) { HttpStatus status; HttpHandle ret_handle(LLCORE_HTTP_HANDLE_INVALID); @@ -543,7 +539,7 @@ HttpHandle HttpRequest::requestCancel(HttpHandle request, HttpHandler * user_han HttpHandle HttpRequest::requestSetPriority(HttpHandle request, priority_t priority, - HttpHandler * handler) + HttpHandler::ptr_t handler) { HttpStatus status; HttpHandle ret_handle(LLCORE_HTTP_HANDLE_INVALID); @@ -609,7 +605,7 @@ HttpStatus HttpRequest::startThread() } -HttpHandle HttpRequest::requestStopThread(HttpHandler * user_handler) +HttpHandle HttpRequest::requestStopThread(HttpHandler::ptr_t user_handler) { HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); diff --git a/indra/llcorehttp/httprequest.h b/indra/llcorehttp/httprequest.h index 6c2449266f..2eb3caa11e 100755 --- a/indra/llcorehttp/httprequest.h +++ b/indra/llcorehttp/httprequest.h @@ -238,7 +238,7 @@ public: /// Prototype for policy based callbacks. The callback methods will be executed /// on the worker thread so no modifications should be made to the HttpHandler object. - typedef boost::function policyCallback_t; + typedef boost::function policyCallback_t; /// Set a policy option for a global or class parameter at /// startup time (prior to thread start). @@ -270,9 +270,9 @@ public: /// @return Handle of dynamic request. Use @see getStatus() if /// the returned handle is invalid. HttpHandle setPolicyOption(EPolicyOption opt, policy_t pclass, long value, - HttpHandler * handler); + HttpHandler::ptr_t handler); HttpHandle setPolicyOption(EPolicyOption opt, policy_t pclass, const std::string & value, - HttpHandler * handler); + HttpHandler::ptr_t handler); /// @} @@ -350,7 +350,7 @@ public: const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, - HttpHandler * handler); + HttpHandler::ptr_t handler); /// Queue a full HTTP GET request to be issued with a 'Range' header. @@ -393,7 +393,7 @@ public: size_t len, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, - HttpHandler * handler); + HttpHandler::ptr_t handler); /// Queue a full HTTP POST. Query arguments and body may @@ -434,7 +434,7 @@ public: BufferArray * body, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, - HttpHandler * handler); + HttpHandler::ptr_t handler); /// Queue a full HTTP PUT. Query arguments and body may @@ -475,7 +475,7 @@ public: BufferArray * body, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, - HttpHandler * handler); + HttpHandler::ptr_t handler); /// Queue a full HTTP DELETE. Query arguments and body may @@ -495,7 +495,7 @@ public: const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, - HttpHandler * user_handler); + HttpHandler::ptr_t user_handler); /// Queue a full HTTP PATCH. Query arguments and body may /// be provided. Caller is responsible for escaping and @@ -518,7 +518,7 @@ public: BufferArray * body, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, - HttpHandler * user_handler); + HttpHandler::ptr_t user_handler); /// Queue a full HTTP COPY. Query arguments and body may /// be provided. Caller is responsible for escaping and @@ -537,7 +537,7 @@ public: const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, - HttpHandler * user_handler); + HttpHandler::ptr_t user_handler); /// Queue a full HTTP MOVE. Query arguments and body may /// be provided. Caller is responsible for escaping and @@ -556,7 +556,7 @@ public: const std::string & url, const HttpOptions::ptr_t & options, const HttpHeaders::ptr_t & headers, - HttpHandler * user_handler); + HttpHandler::ptr_t user_handler); /// Queue a NoOp request. /// The request is queued and serviced by the working thread which @@ -566,7 +566,7 @@ public: /// @param handler @see requestGet() /// @return " /// - HttpHandle requestNoOp(HttpHandler * handler); + HttpHandle requestNoOp(HttpHandler::ptr_t handler); /// While all the heavy work is done by the worker thread, notifications /// must be performed in the context of the application thread. These @@ -591,7 +591,7 @@ public: /// /// @{ - HttpHandle requestCancel(HttpHandle request, HttpHandler *); + HttpHandle requestCancel(HttpHandle request, HttpHandler::ptr_t); /// Request that a previously-issued request be reprioritized. /// The status of whether the change itself succeeded arrives @@ -603,7 +603,7 @@ public: /// @param handler @see requestGet() /// @return " /// - HttpHandle requestSetPriority(HttpHandle request, priority_t priority, HttpHandler * handler); + HttpHandle requestSetPriority(HttpHandle request, priority_t priority, HttpHandler::ptr_t handler); /// @} @@ -641,7 +641,7 @@ public: /// As the request cannot be cancelled, the handle /// is generally not useful. /// - HttpHandle requestStopThread(HttpHandler * handler); + HttpHandle requestStopThread(HttpHandler::ptr_t handler); /// Queue a Spin request. /// DEBUG/TESTING ONLY. This puts the worker into a CPU spin for @@ -658,11 +658,13 @@ protected: void generateNotification(HttpOperation * op); private: + typedef boost::shared_ptr HttpReplyQueuePtr_t; + /// @name InstanceData /// /// @{ HttpStatus mLastReqStatus; - HttpReplyQueue * mReplyQueue; + HttpReplyQueuePtr_t mReplyQueue; HttpRequestQueue * mRequestQueue; /// @} diff --git a/indra/llcrashlogger/llcrashlogger.cpp b/indra/llcrashlogger/llcrashlogger.cpp index 6fd4579876..f240784dc9 100755 --- a/indra/llcrashlogger/llcrashlogger.cpp +++ b/indra/llcrashlogger/llcrashlogger.cpp @@ -410,7 +410,7 @@ bool LLCrashLogger::runCrashLogPost(std::string host, LLSD data, std::string msg updateApplication(llformat("%s, try %d...", msg.c_str(), i+1)); LLCoreHttpUtil::requestPostWithLLSD(httpRequest.get(), LLCore::HttpRequest::DEFAULT_POLICY_ID, 0, - host, data, httpOpts, LLCore::HttpHeaders::ptr_t(), new LLCrashLoggerHandler); + host, data, httpOpts, LLCore::HttpHeaders::ptr_t(), LLCore::HttpHandler::ptr_t(new LLCrashLoggerHandler)); while(!gBreak) { 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 diff --git a/indra/newview/llappcorehttp.cpp b/indra/newview/llappcorehttp.cpp index 91a5148e4c..ee4b91f8f2 100755 --- a/indra/newview/llappcorehttp.cpp +++ b/indra/newview/llappcorehttp.cpp @@ -278,12 +278,19 @@ void setting_changed() LLAppViewer::instance()->getAppCoreHttp().refreshSettings(false); } +namespace +{ + void NoOpDeletor(LLCore::HttpHandler *) + { + + } +} void LLAppCoreHttp::requestStop() { llassert_always(mRequest); - mStopHandle = mRequest->requestStopThread(this); + mStopHandle = mRequest->requestStopThread(LLCore::HttpHandler::ptr_t(this, NoOpDeletor)); if (LLCORE_HTTP_HANDLE_INVALID != mStopHandle) { mStopRequested = LLTimer::getTotalSeconds(); @@ -486,7 +493,7 @@ void LLAppCoreHttp::refreshSettings(bool initial) } LLCore::HttpStatus LLAppCoreHttp::sslVerify(const std::string &url, - LLCore::HttpHandler const * const handler, void *appdata) + const LLCore::HttpHandler::ptr_t &handler, void *appdata) { X509_STORE_CTX *ctx = static_cast(appdata); LLCore::HttpStatus result; diff --git a/indra/newview/llappcorehttp.h b/indra/newview/llappcorehttp.h index 410d7c6b07..95c138d598 100755 --- a/indra/newview/llappcorehttp.h +++ b/indra/newview/llappcorehttp.h @@ -257,7 +257,7 @@ private: bool mPipelined; // Global setting boost::signals2::connection mPipelinedSignal; // Signal for 'HttpPipelining' setting - static LLCore::HttpStatus sslVerify(const std::string &uri, LLCore::HttpHandler const * const handler, void *appdata); + static LLCore::HttpStatus sslVerify(const std::string &uri, const LLCore::HttpHandler::ptr_t &handler, void *appdata); }; diff --git a/indra/newview/lleventpoll.cpp b/indra/newview/lleventpoll.cpp index 021d17251d..40eaba2bac 100755 --- a/indra/newview/lleventpoll.cpp +++ b/indra/newview/lleventpoll.cpp @@ -120,15 +120,19 @@ namespace Details void LLEventPollImpl::stop() { - LL_INFOS() << "requesting stop for event poll coroutine <" << mCounter << ">" << LL_ENDL; mDone = true; LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t adapter = mAdapter.lock(); if (adapter) { + LL_INFOS() << "requesting stop for event poll coroutine <" << mCounter << ">" << LL_ENDL; // cancel the yielding operation if any. adapter->cancelSuspendedOperation(); } + else + { + LL_INFOS() << "Coroutine for poll <" << mCounter << "> previously stopped. No action taken." << LL_ENDL; + } } void LLEventPollImpl::eventPollCoro(std::string url) @@ -179,6 +183,12 @@ namespace Details LL_WARNS() << "Canceling coroutine" << LL_ENDL; break; } + else if (!status.isHttpStatus()) + { + /// Some LLCore or LIBCurl error was returned. This is unlikely to be recoverable + LL_WARNS("LLEventPollImpl") << "Critical error from poll request returned from libraries. Canceling coroutine." << LL_ENDL; + break; + } LL_WARNS("LLEventPollImpl") << "<" << counter << "> Error result from LLCoreHttpUtil::HttpCoroHandler. Code " << status.toTerseString() << ": '" << httpResults["message"] << "'" << LL_ENDL; diff --git a/indra/newview/llinventorymodel.cpp b/indra/newview/llinventorymodel.cpp index 53a58aff4c..ab0df33051 100755 --- a/indra/newview/llinventorymodel.cpp +++ b/indra/newview/llinventorymodel.cpp @@ -2456,7 +2456,7 @@ void LLInventoryModel::handleResponses(bool foreground) LLCore::HttpHandle LLInventoryModel::requestPost(bool foreground, const std::string & url, const LLSD & body, - LLCore::HttpHandler * handler, + const LLCore::HttpHandler::ptr_t &handler, const char * const message) { if (! mHttpRequestFG) @@ -2485,7 +2485,6 @@ LLCore::HttpHandle LLInventoryModel::requestPost(bool foreground, << ", Status: " << status.toTerseString() << " Reason: '" << status.toString() << "'" << LL_ENDL; - delete handler; } return handle; } @@ -4051,9 +4050,6 @@ void LLInventoryModel::FetchItemHttpHandler::onCompleted(LLCore::HttpHandle hand processData(body_llsd, response); } while (false); - - // Must delete on completion. - delete this; } void LLInventoryModel::FetchItemHttpHandler::processData(LLSD & content, LLCore::HttpResponse * response) diff --git a/indra/newview/llinventorymodel.h b/indra/newview/llinventorymodel.h index a74e3b69f4..e1e6db19eb 100755 --- a/indra/newview/llinventorymodel.h +++ b/indra/newview/llinventorymodel.h @@ -80,6 +80,9 @@ public: typedef std::vector > item_array_t; typedef std::set changed_items_t; + // Rider: This is using the old responder patter. It should be refactored to + // take advantage of coroutines. + // HTTP handler for individual item requests (inventory or library). // Background item requests are derived from this in the background // inventory system. All folder requests are also located there @@ -563,7 +566,7 @@ public: LLCore::HttpHandle requestPost(bool foreground, const std::string & url, const LLSD & body, - LLCore::HttpHandler * handler, + const LLCore::HttpHandler::ptr_t &handler, const char * const message); private: diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp index 40edb13a80..4a77edc565 100755 --- a/indra/newview/llinventorymodelbackgroundfetch.cpp +++ b/indra/newview/llinventorymodelbackgroundfetch.cpp @@ -513,7 +513,7 @@ void LLInventoryModelBackgroundFetch::bulkFetch() if (! url.empty()) { - BGFolderHttpHandler * handler(new BGFolderHttpHandler(folder_request_body, recursive_cats)); + LLCore::HttpHandler::ptr_t handler(new BGFolderHttpHandler(folder_request_body, recursive_cats)); gInventory.requestPost(false, url, folder_request_body, handler, "Inventory Folder"); } } @@ -524,7 +524,7 @@ void LLInventoryModelBackgroundFetch::bulkFetch() if (! url.empty()) { - BGFolderHttpHandler * handler(new BGFolderHttpHandler(folder_request_body_lib, recursive_cats)); + LLCore::HttpHandler::ptr_t handler(new BGFolderHttpHandler(folder_request_body_lib, recursive_cats)); gInventory.requestPost(false, url, folder_request_body_lib, handler, "Library Folder"); } } @@ -540,7 +540,7 @@ void LLInventoryModelBackgroundFetch::bulkFetch() { LLSD body; body["items"] = item_request_body; - BGItemHttpHandler * handler(new BGItemHttpHandler(body)); + LLCore::HttpHandler::ptr_t handler(new BGItemHttpHandler(body)); gInventory.requestPost(false, url, body, handler, "Inventory Item"); } } @@ -553,7 +553,7 @@ void LLInventoryModelBackgroundFetch::bulkFetch() { LLSD body; body["items"] = item_request_body_lib; - BGItemHttpHandler * handler(new BGItemHttpHandler(body)); + LLCore::HttpHandler::ptr_t handler(new BGItemHttpHandler(body)); gInventory.requestPost(false, url, body, handler, "Library Item"); } } @@ -647,9 +647,6 @@ void BGFolderHttpHandler::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRes processData(body_llsd, response); } while (false); - - // Must delete on completion. - delete this; } diff --git a/indra/newview/llinventoryobserver.cpp b/indra/newview/llinventoryobserver.cpp index d81401b59b..6c81378622 100755 --- a/indra/newview/llinventoryobserver.cpp +++ b/indra/newview/llinventoryobserver.cpp @@ -237,7 +237,7 @@ void fetch_items_from_llsd(const LLSD& items_llsd) if (!url.empty()) { body[i]["agent_id"] = gAgent.getID(); - LLInventoryModel::FetchItemHttpHandler * handler(new LLInventoryModel::FetchItemHttpHandler(body[i])); + LLCore::HttpHandler::ptr_t handler(new LLInventoryModel::FetchItemHttpHandler(body[i])); gInventory.requestPost(true, url, body[i], handler, (i ? "Library Item" : "Inventory Item")); continue; } diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 1045def72e..6dc0525365 100755 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -579,46 +579,56 @@ void LLMaterialMgr::onIdle(void*) instancep->mHttpRequest->update(0L); } -void LLMaterialMgr::processGetQueue() +/*static*/ +void LLMaterialMgr::CapsRecvForRegion(const LLUUID& regionId, LLUUID regionTest, std::string pumpname) { - get_queue_t::iterator loopRegionQueue = mGetQueue.begin(); - while (mGetQueue.end() != loopRegionQueue) - { - get_queue_t::iterator itRegionQueue = loopRegionQueue++; - - const LLUUID& region_id = itRegionQueue->first; - if (isGetAllPending(region_id)) - { - continue; - } - - LLViewerRegion* regionp = LLWorld::instance().getRegionFromID(region_id); - if (!regionp) - { - LL_WARNS("Materials") << "Unknown region with id " << region_id.asString() << LL_ENDL; - mGetQueue.erase(itRegionQueue); - continue; - } - else if (!regionp->capabilitiesReceived() || regionp->materialsCapThrottled()) - { - continue; - } - else if (mGetAllRequested.end() == mGetAllRequested.find(region_id)) - { - LL_DEBUGS("Materials") << "calling getAll for " << regionp->getName() << LL_ENDL; - getAll(region_id); - continue; - } - - const std::string capURL = regionp->getCapability(MATERIALS_CAPABILITY_NAME); - if (capURL.empty()) - { - LL_WARNS("Materials") << "Capability '" << MATERIALS_CAPABILITY_NAME - << "' is not defined on region '" << regionp->getName() << "'" << LL_ENDL; - mGetQueue.erase(itRegionQueue); - continue; - } + if (regionId == regionTest) + { + LLEventPumps::instance().obtain(pumpname).post(LLSD()); + } +} +void LLMaterialMgr::processGetQueue() +{ + get_queue_t::iterator loopRegionQueue = mGetQueue.begin(); + while (mGetQueue.end() != loopRegionQueue) + { +#if 1 + get_queue_t::iterator itRegionQueue = loopRegionQueue++; + + const LLUUID& region_id = itRegionQueue->first; + if (isGetAllPending(region_id)) + { + continue; + } + + LLViewerRegion* regionp = LLWorld::instance().getRegionFromID(region_id); + if (!regionp) + { + LL_WARNS("Materials") << "Unknown region with id " << region_id.asString() << LL_ENDL; + mGetQueue.erase(itRegionQueue); + continue; + } + else if (!regionp->capabilitiesReceived() || regionp->materialsCapThrottled()) + { + continue; + } + else if (mGetAllRequested.end() == mGetAllRequested.find(region_id)) + { + LL_DEBUGS("Materials") << "calling getAll for " << regionp->getName() << LL_ENDL; + getAll(region_id); + continue; + } + + const std::string capURL = regionp->getCapability(MATERIALS_CAPABILITY_NAME); + if (capURL.empty()) + { + LL_WARNS("Materials") << "Capability '" << MATERIALS_CAPABILITY_NAME + << "' is not defined on region '" << regionp->getName() << "'" << LL_ENDL; + mGetQueue.erase(itRegionQueue); + continue; + } + LLSD materialsData = LLSD::emptyArray(); material_queue_t& materials = itRegionQueue->second; @@ -652,10 +662,9 @@ void LLMaterialMgr::processGetQueue() LLSD postData = LLSD::emptyMap(); postData[MATERIALS_CAP_ZIP_FIELD] = materialBinary; - LLMaterialHttpHandler * handler = - new LLMaterialHttpHandler("POST", + LLCore::HttpHandler::ptr_t handler(new LLMaterialHttpHandler("POST", boost::bind(&LLMaterialMgr::onGetResponse, this, _1, _2, region_id) - ); + )); LL_DEBUGS("Materials") << "POSTing to region '" << regionp->getName() << "' at '" << capURL << " for " << materialsData.size() << " materials." << "\ndata: " << ll_pretty_print_sd(materialsData) << LL_ENDL; @@ -666,7 +675,6 @@ void LLMaterialMgr::processGetQueue() if (handle == LLCORE_HTTP_HANDLE_INVALID) { - delete handler; LLCore::HttpStatus status = mHttpRequest->getStatus(); LL_ERRS("Meterials") << "Failed to execute material POST. Status = " << status.toULong() << "\"" << status.toString() << "\"" << LL_ENDL; @@ -674,6 +682,103 @@ void LLMaterialMgr::processGetQueue() regionp->resetMaterialsCapThrottle(); } +#endif +} + +void LLMaterialMgr::processGetQueueCoro() +{ +#if 0 + get_queue_t::iterator itRegionQueue = loopRegionQueue++; + + const LLUUID& region_id = itRegionQueue->first; + if (isGetAllPending(region_id)) + { + continue; + } + + LLViewerRegion* regionp = LLWorld::instance().getRegionFromID(region_id); + if (!regionp) + { + LL_WARNS("Materials") << "Unknown region with id " << region_id.asString() << LL_ENDL; + mGetQueue.erase(itRegionQueue); + continue; + } + else if (!regionp->capabilitiesReceived() || regionp->materialsCapThrottled()) + { + continue; + } + else if (mGetAllRequested.end() == mGetAllRequested.find(region_id)) + { + LL_DEBUGS("Materials") << "calling getAll for " << regionp->getName() << LL_ENDL; + getAll(region_id); + continue; + } + + const std::string capURL = regionp->getCapability(MATERIALS_CAPABILITY_NAME); + if (capURL.empty()) + { + LL_WARNS("Materials") << "Capability '" << MATERIALS_CAPABILITY_NAME + << "' is not defined on region '" << regionp->getName() << "'" << LL_ENDL; + mGetQueue.erase(itRegionQueue); + continue; + } + + LLSD materialsData = LLSD::emptyArray(); + + material_queue_t& materials = itRegionQueue->second; + U32 max_entries = regionp->getMaxMaterialsPerTransaction(); + material_queue_t::iterator loopMaterial = materials.begin(); + while ((materials.end() != loopMaterial) && (materialsData.size() < max_entries)) + { + material_queue_t::iterator itMaterial = loopMaterial++; + materialsData.append((*itMaterial).asLLSD()); + materials.erase(itMaterial); + markGetPending(region_id, *itMaterial); + } + if (materials.empty()) + { + mGetQueue.erase(itRegionQueue); + } + + std::string materialString = zip_llsd(materialsData); + + S32 materialSize = materialString.size(); + if (materialSize <= 0) + { + LL_ERRS("Materials") << "cannot zip LLSD binary content" << LL_ENDL; + return; + } + + LLSD::Binary materialBinary; + materialBinary.resize(materialSize); + memcpy(materialBinary.data(), materialString.data(), materialSize); + + LLSD postData = LLSD::emptyMap(); + postData[MATERIALS_CAP_ZIP_FIELD] = materialBinary; + + LLMaterialHttpHandler * handler = + new LLMaterialHttpHandler("POST", + boost::bind(&LLMaterialMgr::onGetResponse, this, _1, _2, region_id) + ); + + LL_DEBUGS("Materials") << "POSTing to region '" << regionp->getName() << "' at '" << capURL << " for " << materialsData.size() << " materials." + << "\ndata: " << ll_pretty_print_sd(materialsData) << LL_ENDL; + + LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, + mHttpPolicy, mHttpPriority, capURL, + postData, mHttpOptions, mHttpHeaders, handler); + + if (handle == LLCORE_HTTP_HANDLE_INVALID) + { + delete handler; + LLCore::HttpStatus status = mHttpRequest->getStatus(); + LL_ERRS("Meterials") << "Failed to execute material POST. Status = " << + status.toULong() << "\"" << status.toString() << "\"" << LL_ENDL; + } + + regionp->resetMaterialsCapThrottle(); +#endif + } void LLMaterialMgr::processGetAllQueue() @@ -684,6 +789,10 @@ void LLMaterialMgr::processGetAllQueue() getall_queue_t::iterator itRegion = loopRegion++; const LLUUID& region_id = *itRegion; +#if 1 + LLCoros::instance().launch("LLMaterialMgr::processGetAllQueueCoro", boost::bind(&LLMaterialMgr::processGetAllQueueCoro, + this, region_id)); +#else LLViewerRegion* regionp = LLWorld::instance().getRegionFromID(region_id); if (regionp == NULL) { @@ -723,11 +832,84 @@ void LLMaterialMgr::processGetAllQueue() } regionp->resetMaterialsCapThrottle(); - mGetAllPending.insert(std::pair(region_id, LLFrameTimer::getTotalSeconds())); +#endif + mGetAllPending.insert(std::pair(region_id, LLFrameTimer::getTotalSeconds())); mGetAllQueue.erase(itRegion); // Invalidates region_id } } +void LLMaterialMgr::processGetAllQueueCoro(LLUUID regionId) +{ + LLViewerRegion* regionp = LLWorld::instance().getRegionFromID(regionId); + if (regionp == NULL) + { + LL_WARNS("Materials") << "Unknown region with id " << regionId.asString() << LL_ENDL; + clearGetQueues(regionId); // Invalidates region_id + return; + } + else if (!regionp->capabilitiesReceived()) + { + LLEventStream capsRecv("waitForCaps", true); + + regionp->setCapabilitiesReceivedCallback( + boost::bind(&LLMaterialMgr::CapsRecvForRegion, + _1, regionId, capsRecv.getName())); + + llcoro::suspendUntilEventOn(capsRecv); + + // reget the region from the region ID since it may have gone away while waiting. + regionp = LLWorld::instance().getRegionFromID(regionId); + if (!regionp) + { + LL_WARNS("Materials") << "Region with ID " << regionId << " is no longer valid." << LL_ENDL; + return; + } + } + else if (regionp->materialsCapThrottled()) + { + // TODO: + // Figure out how to handle the throttle. + } + + std::string capURL = regionp->getCapability(MATERIALS_CAPABILITY_NAME); + if (capURL.empty()) + { + LL_WARNS("Materials") << "Capability '" << MATERIALS_CAPABILITY_NAME + << "' is not defined on the current region '" << regionp->getName() << "'" << LL_ENDL; + clearGetQueues(regionId); // Invalidates region_id + return; + } + + LL_DEBUGS("Materials") << "GET all for region " << regionId << "url " << capURL << LL_ENDL; + + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter( + new LLCoreHttpUtil::HttpCoroutineAdapter("processGetAllQueue", LLCore::HttpRequest::DEFAULT_POLICY_ID)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest()); + + LLSD result = httpAdapter->getAndSuspend(httpRequest, capURL); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + onGetAllResponse(false, LLSD(), regionId); + } + else + { + onGetAllResponse(true, result, regionId); + } + + // reget the region from the region ID since it may have gone away while waiting. + regionp = LLWorld::instance().getRegionFromID(regionId); + if (!regionp) + { + LL_WARNS("Materials") << "Region with ID " << regionId << " is no longer valid." << LL_ENDL; + return; + } + regionp->resetMaterialsCapThrottle(); +} + void LLMaterialMgr::processPutQueue() { typedef std::map regionput_request_map; @@ -749,34 +931,34 @@ void LLMaterialMgr::processPutQueue() { LLViewerRegion* regionp = objectp->getRegion(); if ( !regionp ) - { + { LL_WARNS("Materials") << "Object region is NULL" << LL_ENDL; mPutQueue.erase(itQueue); - } + } else if ( regionp->capabilitiesReceived() && !regionp->materialsCapThrottled()) { - LLSD& facesData = requests[regionp]; - - facematerial_map_t& face_map = itQueue->second; - U32 max_entries = regionp->getMaxMaterialsPerTransaction(); - facematerial_map_t::iterator itFace = face_map.begin(); - while ( (face_map.end() != itFace) && (facesData.size() < max_entries) ) - { - LLSD faceData = LLSD::emptyMap(); - faceData[MATERIALS_CAP_FACE_FIELD] = static_cast(itFace->first); - faceData[MATERIALS_CAP_OBJECT_ID_FIELD] = static_cast(objectp->getLocalID()); - if (!itFace->second.isNull()) - { - faceData[MATERIALS_CAP_MATERIAL_FIELD] = itFace->second.asLLSD(); - } - facesData.append(faceData); - face_map.erase(itFace++); - } - if (face_map.empty()) - { - mPutQueue.erase(itQueue); - } - } + LLSD& facesData = requests[regionp]; + + facematerial_map_t& face_map = itQueue->second; + U32 max_entries = regionp->getMaxMaterialsPerTransaction(); + facematerial_map_t::iterator itFace = face_map.begin(); + while ( (face_map.end() != itFace) && (facesData.size() < max_entries) ) + { + LLSD faceData = LLSD::emptyMap(); + faceData[MATERIALS_CAP_FACE_FIELD] = static_cast(itFace->first); + faceData[MATERIALS_CAP_OBJECT_ID_FIELD] = static_cast(objectp->getLocalID()); + if (!itFace->second.isNull()) + { + faceData[MATERIALS_CAP_MATERIAL_FIELD] = itFace->second.asLLSD(); + } + facesData.append(faceData); + face_map.erase(itFace++); + } + if (face_map.empty()) + { + mPutQueue.erase(itQueue); + } + } } } @@ -809,10 +991,9 @@ void LLMaterialMgr::processPutQueue() LL_DEBUGS("Materials") << "put for " << itRequest->second.size() << " faces to region " << itRequest->first->getName() << LL_ENDL; - LLMaterialHttpHandler * handler = - new LLMaterialHttpHandler("PUT", - boost::bind(&LLMaterialMgr::onPutResponse, this, _1, _2) - ); + LLCore::HttpHandler::ptr_t handler (new LLMaterialHttpHandler("PUT", + boost::bind(&LLMaterialMgr::onPutResponse, this, _1, _2) + )); LLCore::HttpHandle handle = LLCoreHttpUtil::requestPutWithLLSD( mHttpRequest, mHttpPolicy, mHttpPriority, capURL, @@ -820,7 +1001,6 @@ void LLMaterialMgr::processPutQueue() if (handle == LLCORE_HTTP_HANDLE_INVALID) { - delete handler; LLCore::HttpStatus status = mHttpRequest->getStatus(); LL_ERRS("Meterials") << "Failed to execute material PUT. Status = " << status.toULong() << "\"" << status.toString() << "\"" << LL_ENDL; @@ -838,6 +1018,7 @@ void LLMaterialMgr::processPutQueue() void LLMaterialMgr::clearGetQueues(const LLUUID& region_id) { mGetQueue.erase(region_id); + for (get_pending_map_t::iterator itPending = mGetPending.begin(); itPending != mGetPending.end();) { if (region_id == itPending->first.first) diff --git a/indra/newview/llmaterialmgr.h b/indra/newview/llmaterialmgr.h index ef202d24ba..36dd0904b6 100644 --- a/indra/newview/llmaterialmgr.h +++ b/indra/newview/llmaterialmgr.h @@ -67,9 +67,14 @@ private: const LLMaterialPtr setMaterial(const LLUUID& region_id, const LLMaterialID& material_id, const LLSD& material_data); static void onIdle(void*); + + static void CapsRecvForRegion(const LLUUID& regionId, LLUUID regionTest, std::string pumpname); + void processGetQueue(); + void processGetQueueCoro(); void onGetResponse(bool success, const LLSD& content, const LLUUID& region_id); void processGetAllQueue(); + void processGetAllQueueCoro(LLUUID regionId); void onGetAllResponse(bool success, const LLSD& content, const LLUUID& region_id); void processPutQueue(); void onPutResponse(bool success, const LLSD& content); @@ -116,7 +121,9 @@ private: typedef std::map facematerial_map_t; typedef std::map put_queue_t; + get_queue_t mGetQueue; + uuid_set_t mRegionGets; get_pending_map_t mGetPending; get_callback_map_t mGetCallbacks; diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp index bfd0700a2f..bd8f464acd 100755 --- a/indra/newview/llmediadataclient.cpp +++ b/indra/newview/llmediadataclient.cpp @@ -353,14 +353,12 @@ void LLMediaDataClient::serviceQueue() trackRequest(request); // and make the post - LLHttpSDHandler *handler = request->createHandler(); + LLCore::HttpHandler::ptr_t handler = request->createHandler(); LLCore::HttpHandle handle = LLCoreHttpUtil::requestPostWithLLSD(mHttpRequest, mHttpPolicy, 0, url, sd_payload, mHttpOpts, mHttpHeaders, handler); if (handle == LLCORE_HTTP_HANDLE_INVALID) { - // *TODO: Change this metaphore to use boost::shared_ptr<> for handlers. Requires change in LLCore::HTTP - delete handler; LLCore::HttpStatus status = mHttpRequest->getStatus(); LL_WARNS("LLMediaDataClient") << "'" << url << "' request POST failed. Reason " << status.toTerseString() << " \"" << status.toString() << "\"" << LL_ENDL; @@ -878,9 +876,9 @@ LLSD LLObjectMediaDataClient::RequestGet::getPayload() const return result; } -LLHttpSDHandler *LLObjectMediaDataClient::RequestGet::createHandler() +LLCore::HttpHandler::ptr_t LLObjectMediaDataClient::RequestGet::createHandler() { - return new LLObjectMediaDataClient::Handler(shared_from_this()); + return LLCore::HttpHandler::ptr_t(new LLObjectMediaDataClient::Handler(shared_from_this())); } @@ -914,10 +912,10 @@ LLSD LLObjectMediaDataClient::RequestUpdate::getPayload() const return result; } -LLHttpSDHandler *LLObjectMediaDataClient::RequestUpdate::createHandler() +LLCore::HttpHandler::ptr_t LLObjectMediaDataClient::RequestUpdate::createHandler() { // This just uses the base class's responder. - return new LLMediaDataClient::Handler(shared_from_this()); + return LLCore::HttpHandler::ptr_t(new LLMediaDataClient::Handler(shared_from_this())); } void LLObjectMediaDataClient::Handler::onSuccess(LLCore::HttpResponse * response, const LLSD &content) @@ -1049,9 +1047,9 @@ LLSD LLObjectMediaNavigateClient::RequestNavigate::getPayload() const return result; } -LLHttpSDHandler *LLObjectMediaNavigateClient::RequestNavigate::createHandler() +LLCore::HttpHandler::ptr_t LLObjectMediaNavigateClient::RequestNavigate::createHandler() { - return new LLObjectMediaNavigateClient::Handler(shared_from_this()); + return LLCore::HttpHandler::ptr_t(new LLObjectMediaNavigateClient::Handler(shared_from_this())); } void LLObjectMediaNavigateClient::Handler::onSuccess(LLCore::HttpResponse * response, const LLSD &content) diff --git a/indra/newview/llmediadataclient.h b/indra/newview/llmediadataclient.h index 9907897613..58f8bad3e4 100755 --- a/indra/newview/llmediadataclient.h +++ b/indra/newview/llmediadataclient.h @@ -124,7 +124,7 @@ protected: // Subclasses must implement this to build a payload for their request type. virtual LLSD getPayload() const = 0; // and must create the correct type of responder. - virtual LLHttpSDHandler *createHandler() = 0; + virtual LLCore::HttpHandler::ptr_t createHandler() = 0; virtual std::string getURL() { return ""; } @@ -324,7 +324,7 @@ public: public: RequestGet(LLMediaDataClientObject *obj, LLMediaDataClient *mdc); /*virtual*/ LLSD getPayload() const; - /*virtual*/ LLHttpSDHandler *createHandler(); + /*virtual*/ LLCore::HttpHandler::ptr_t createHandler(); }; class RequestUpdate: public Request @@ -332,7 +332,7 @@ public: public: RequestUpdate(LLMediaDataClientObject *obj, LLMediaDataClient *mdc); /*virtual*/ LLSD getPayload() const; - /*virtual*/ LLHttpSDHandler *createHandler(); + /*virtual*/ LLCore::HttpHandler::ptr_t createHandler(); }; // Returns true iff the queue is empty @@ -409,7 +409,7 @@ public: public: RequestNavigate(LLMediaDataClientObject *obj, LLMediaDataClient *mdc, U8 texture_index, const std::string &url); /*virtual*/ LLSD getPayload() const; - /*virtual*/ LLHttpSDHandler *createHandler(); + /*virtual*/ LLCore::HttpHandler::ptr_t createHandler(); /*virtual*/ std::string getURL() { return mURL; } private: std::string mURL; diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 457053f713..ad27f2e564 100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -1,3 +1,4 @@ +ptr_t /** * @file llmeshrepository.cpp * @brief Mesh repository implementation. @@ -392,6 +393,12 @@ U32 LLMeshRepository::sMaxLockHoldoffs = 0; LLDeadmanTimer LLMeshRepository::sQuiescentTimer(15.0, false); // true -> gather cpu metrics +namespace { + void NoOpDeletor(LLCore::HttpHandler *) + { + + } +} static S32 dump_num = 0; std::string make_dump_name(std::string prefix, S32 num) @@ -538,9 +545,12 @@ S32 LLMeshRepoThread::sRequestWaterLevel = 0; // LLMeshPhysicsShapeHandler // LLMeshUploadThread -class LLMeshHandlerBase : public LLCore::HttpHandler +class LLMeshHandlerBase : public LLCore::HttpHandler, + public boost::enable_shared_from_this { public: + typedef boost::shared_ptr ptr_t; + LOG_CLASS(LLMeshHandlerBase); LLMeshHandlerBase(U32 offset, U32 requested_bytes) : LLCore::HttpHandler(), @@ -824,12 +834,6 @@ LLMeshRepoThread::~LLMeshRepoThread() << ", Max Lock Holdoffs: " << LLMeshRepository::sMaxLockHoldoffs << LL_ENDL; - for (http_request_set::iterator iter(mHttpRequestSet.begin()); - iter != mHttpRequestSet.end(); - ++iter) - { - delete *iter; - } mHttpRequestSet.clear(); mHttpHeaders.reset(); @@ -1161,7 +1165,7 @@ void LLMeshRepoThread::constructUrl(LLUUID mesh_id, std::string * url, int * ver // Thread: repo LLCore::HttpHandle LLMeshRepoThread::getByteRange(const std::string & url, int cap_version, size_t offset, size_t len, - LLCore::HttpHandler * handler) + const LLCore::HttpHandler::ptr_t &handler) { // Also used in lltexturefetch.cpp static LLCachedControl disable_range_req(gSavedSettings, "HttpRangeRequestsDisable", false); @@ -1275,7 +1279,7 @@ bool LLMeshRepoThread::fetchMeshSkinInfo(const LLUUID& mesh_id) if (!http_url.empty()) { - LLMeshSkinInfoHandler * handler = new LLMeshSkinInfoHandler(mesh_id, offset, size); + LLMeshHandlerBase::ptr_t handler(new LLMeshSkinInfoHandler(mesh_id, offset, size)); LLCore::HttpHandle handle = getByteRange(http_url, cap_version, offset, size, handler); if (LLCORE_HTTP_HANDLE_INVALID == handle) { @@ -1283,7 +1287,6 @@ bool LLMeshRepoThread::fetchMeshSkinInfo(const LLUUID& mesh_id) << ". Reason: " << mHttpStatus.toString() << " (" << mHttpStatus.toTerseString() << ")" << LL_ENDL; - delete handler; ret = false; } else @@ -1369,7 +1372,7 @@ bool LLMeshRepoThread::fetchMeshDecomposition(const LLUUID& mesh_id) if (!http_url.empty()) { - LLMeshDecompositionHandler * handler = new LLMeshDecompositionHandler(mesh_id, offset, size); + LLMeshHandlerBase::ptr_t handler(new LLMeshDecompositionHandler(mesh_id, offset, size)); LLCore::HttpHandle handle = getByteRange(http_url, cap_version, offset, size, handler); if (LLCORE_HTTP_HANDLE_INVALID == handle) { @@ -1377,7 +1380,6 @@ bool LLMeshRepoThread::fetchMeshDecomposition(const LLUUID& mesh_id) << ". Reason: " << mHttpStatus.toString() << " (" << mHttpStatus.toTerseString() << ")" << LL_ENDL; - delete handler; ret = false; } else @@ -1462,7 +1464,7 @@ bool LLMeshRepoThread::fetchMeshPhysicsShape(const LLUUID& mesh_id) if (!http_url.empty()) { - LLMeshPhysicsShapeHandler * handler = new LLMeshPhysicsShapeHandler(mesh_id, offset, size); + LLMeshHandlerBase::ptr_t handler(new LLMeshPhysicsShapeHandler(mesh_id, offset, size)); LLCore::HttpHandle handle = getByteRange(http_url, cap_version, offset, size, handler); if (LLCORE_HTTP_HANDLE_INVALID == handle) { @@ -1470,7 +1472,6 @@ bool LLMeshRepoThread::fetchMeshPhysicsShape(const LLUUID& mesh_id) << ". Reason: " << mHttpStatus.toString() << " (" << mHttpStatus.toTerseString() << ")" << LL_ENDL; - delete handler; ret = false; } else @@ -1561,7 +1562,7 @@ bool LLMeshRepoThread::fetchMeshHeader(const LLVolumeParams& mesh_params) //within the first 4KB //NOTE -- this will break of headers ever exceed 4KB - LLMeshHeaderHandler * handler = new LLMeshHeaderHandler(mesh_params, 0, MESH_HEADER_SIZE); + LLMeshHandlerBase::ptr_t handler(new LLMeshHeaderHandler(mesh_params, 0, MESH_HEADER_SIZE)); LLCore::HttpHandle handle = getByteRange(http_url, cap_version, 0, MESH_HEADER_SIZE, handler); if (LLCORE_HTTP_HANDLE_INVALID == handle) { @@ -1569,7 +1570,6 @@ bool LLMeshRepoThread::fetchMeshHeader(const LLVolumeParams& mesh_params) << ". Reason: " << mHttpStatus.toString() << " (" << mHttpStatus.toTerseString() << ")" << LL_ENDL; - delete handler; retval = false; } else @@ -1645,7 +1645,7 @@ bool LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod) if (!http_url.empty()) { - LLMeshLODHandler * handler = new LLMeshLODHandler(mesh_params, lod, offset, size); + LLMeshHandlerBase::ptr_t handler(new LLMeshLODHandler(mesh_params, lod, offset, size)); LLCore::HttpHandle handle = getByteRange(http_url, cap_version, offset, size, handler); if (LLCORE_HTTP_HANDLE_INVALID == handle) { @@ -1653,7 +1653,6 @@ bool LLMeshRepoThread::fetchMeshLOD(const LLVolumeParams& mesh_params, S32 lod) << ". Reason: " << mHttpStatus.toString() << " (" << mHttpStatus.toTerseString() << ")" << LL_ENDL; - delete handler; retval = false; } else @@ -2456,7 +2455,7 @@ void LLMeshUploadThread::doWholeModelUpload() body, mHttpOptions, mHttpHeaders, - this); + LLCore::HttpHandler::ptr_t(this, &NoOpDeletor)); if (LLCORE_HTTP_HANDLE_INVALID == handle) { mHttpStatus = mHttpRequest->getStatus(); @@ -2507,7 +2506,7 @@ void LLMeshUploadThread::requestWholeModelFee() mModelData, mHttpOptions, mHttpHeaders, - this); + LLCore::HttpHandler::ptr_t(this, &NoOpDeletor)); if (LLCORE_HTTP_HANDLE_INVALID == handle) { mHttpStatus = mHttpRequest->getStatus(); @@ -2948,8 +2947,7 @@ void LLMeshHandlerBase::onCompleted(LLCore::HttpHandle handle, LLCore::HttpRespo // Release handler common_exit: - gMeshRepo.mThread->mHttpRequestSet.erase(this); - delete this; // Must be last statement + gMeshRepo.mThread->mHttpRequestSet.erase(this->shared_from_this()); } diff --git a/indra/newview/llmeshrepository.h b/indra/newview/llmeshrepository.h index b33497730e..d35c44397b 100755 --- a/indra/newview/llmeshrepository.h +++ b/indra/newview/llmeshrepository.h @@ -283,7 +283,7 @@ public: LLCore::HttpRequest::policy_t mHttpLargePolicyClass; LLCore::HttpRequest::priority_t mHttpPriority; - typedef std::set http_request_set; + typedef std::set http_request_set; http_request_set mHttpRequestSet; // Outstanding HTTP requests std::string mGetMeshCapability; @@ -351,7 +351,7 @@ private: // Threads: Repo thread only LLCore::HttpHandle getByteRange(const std::string & url, int cap_version, size_t offset, size_t len, - LLCore::HttpHandler * handler); + const LLCore::HttpHandler::ptr_t &handler); }; diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 30d90431ea..61747b606e 100755 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -254,6 +254,12 @@ static const S32 HTTP_NONPIPE_REQUESTS_LOW_WATER = 20; static const S32 HTTP_REQUESTS_RANGE_END_MAX = 20000000; ////////////////////////////////////////////////////////////////////////////// +namespace +{ + void NoOpDeletor(LLCore::HttpHandler *) + { + } +} static const char* e_state_name[] = { @@ -806,16 +812,10 @@ public: * ownership of the copy and disposes of it * when done. */ - TFReqSendMetrics(const std::string & caps_url, - const LLUUID & session_id, - const LLUUID & agent_id, - LLViewerAssetStats * main_stats) - : LLTextureFetch::TFRequest(), - mCapsURL(caps_url), - mSessionID(session_id), - mAgentID(agent_id), - mMainStats(main_stats) - {} + TFReqSendMetrics(const std::string & caps_url, + const LLUUID & session_id, + const LLUUID & agent_id, + LLViewerAssetStats * main_stats); TFReqSendMetrics & operator=(const TFReqSendMetrics &); // Not defined virtual ~TFReqSendMetrics(); @@ -827,6 +827,9 @@ public: const LLUUID mSessionID; const LLUUID mAgentID; LLViewerAssetStats * mMainStats; + +private: + LLCore::HttpHandler::ptr_t mHandler; }; /* @@ -1569,7 +1572,7 @@ bool LLTextureFetchWorker::doWork(S32 param) mUrl, options, mFetcher->mHttpHeaders, - this); + LLCore::HttpHandler::ptr_t(this, &NoOpDeletor)); } else { @@ -1582,7 +1585,7 @@ bool LLTextureFetchWorker::doWork(S32 param) : mRequestedSize, options, mFetcher->mHttpHeaders, - this); + LLCore::HttpHandler::ptr_t(this, &NoOpDeletor)); } if (LLCORE_HTTP_HANDLE_INVALID == mHttpHandle) { @@ -3937,9 +3940,6 @@ public: } }; // end class AssetReportHandler -AssetReportHandler stats_handler; - - /** * Implements the 'Set Region' command. * @@ -3953,6 +3953,18 @@ TFReqSetRegion::doWork(LLTextureFetch *) return true; } +TFReqSendMetrics::TFReqSendMetrics(const std::string & caps_url, + const LLUUID & session_id, + const LLUUID & agent_id, + LLViewerAssetStats * main_stats): + LLTextureFetch::TFRequest(), + mCapsURL(caps_url), + mSessionID(session_id), + mAgentID(agent_id), + mMainStats(main_stats), + mHandler(new AssetReportHandler) +{} + TFReqSendMetrics::~TFReqSendMetrics() { @@ -3971,7 +3983,6 @@ bool TFReqSendMetrics::doWork(LLTextureFetch * fetcher) { static const U32 report_priority(1); - static LLCore::HttpHandler * const handler(fetcher->isQAMode() || true ? &stats_handler : NULL); //if (! gViewerAssetStatsThread1) // return true; @@ -4021,7 +4032,7 @@ TFReqSendMetrics::doWork(LLTextureFetch * fetcher) sd, LLCore::HttpOptions::ptr_t(), fetcher->getMetricsHeaders(), - handler); + mHandler); LLTextureFetch::svMetricsDataBreak = false; } else @@ -4598,7 +4609,7 @@ S32 LLTextureFetchDebugger::fillCurlQueue() requestedSize, LLCore::HttpOptions::ptr_t(), mHttpHeaders, - this); + LLCore::HttpHandler::ptr_t(this, &NoOpDeletor)); if (LLCORE_HTTP_HANDLE_INVALID != handle) { mHandleToFetchIndex[handle] = i; diff --git a/indra/newview/llviewerinventory.cpp b/indra/newview/llviewerinventory.cpp index 573791aca3..0ee873d7a1 100755 --- a/indra/newview/llviewerinventory.cpp +++ b/indra/newview/llviewerinventory.cpp @@ -427,7 +427,7 @@ void LLViewerInventoryItem::fetchFromServer(void) const body["items"][0]["owner_id"] = mPermissions.getOwner(); body["items"][0]["item_id"] = mUUID; - LLInventoryModel::FetchItemHttpHandler * handler(new LLInventoryModel::FetchItemHttpHandler(body)); + LLCore::HttpHandler::ptr_t handler(new LLInventoryModel::FetchItemHttpHandler(body)); gInventory.requestPost(true, url, body, handler, "Inventory Item"); } else diff --git a/indra/newview/llxmlrpctransaction.cpp b/indra/newview/llxmlrpctransaction.cpp index 442ed73c2d..f8b38669b6 100755 --- a/indra/newview/llxmlrpctransaction.cpp +++ b/indra/newview/llxmlrpctransaction.cpp @@ -175,7 +175,7 @@ public: virtual void onCompleted(LLCore::HttpHandle handle, LLCore::HttpResponse * response); - typedef boost::unique_ptr ptr_t; + typedef boost::shared_ptr ptr_t; private: @@ -390,7 +390,7 @@ void LLXMLRPCTransaction::Impl::init(XMLRPC_REQUEST request, bool useGzip) mHandler = LLXMLRPCTransaction::Handler::ptr_t(new Handler( mHttpRequest, this )); mPostH = mHttpRequest->requestPost(LLCore::HttpRequest::DEFAULT_POLICY_ID, 0, - mURI, body.get(), httpOpts, httpHeaders, mHandler.get()); + mURI, body.get(), httpOpts, httpHeaders, mHandler); } -- cgit v1.3 From eca891e2618581e90c79f0c141b1c920f2577efe Mon Sep 17 00:00:00 2001 From: rider Date: Thu, 15 Oct 2015 09:32:19 -0700 Subject: MAINT-5732: Fixes for Mac build --- indra/llcorehttp/httprequest.cpp | 2 +- indra/newview/llappcorehttp.cpp | 6 +++--- indra/newview/llmeshrepository.cpp | 3 +-- indra/newview/lltexturefetch.cpp | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) (limited to 'indra/llcorehttp/httprequest.cpp') diff --git a/indra/llcorehttp/httprequest.cpp b/indra/llcorehttp/httprequest.cpp index 8380e48ddb..24e0f582e1 100755 --- a/indra/llcorehttp/httprequest.cpp +++ b/indra/llcorehttp/httprequest.cpp @@ -632,7 +632,7 @@ HttpHandle HttpRequest::requestSpin(int mode) HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); HttpOpSpin * op = new HttpOpSpin(mode); - op->setReplyPath(mReplyQueue, NULL); + op->setReplyPath(mReplyQueue, HttpHandler::ptr_t()); if (! (status = mRequestQueue->addOp(op))) // transfers refcount { op->release(); diff --git a/indra/newview/llappcorehttp.cpp b/indra/newview/llappcorehttp.cpp index ee4b91f8f2..5662334555 100755 --- a/indra/newview/llappcorehttp.cpp +++ b/indra/newview/llappcorehttp.cpp @@ -403,7 +403,7 @@ void LLAppCoreHttp::refreshSettings(bool initial) handle = mRequest->setPolicyOption(LLCore::HttpRequest::PO_PIPELINING_DEPTH, mHttpClasses[app_policy].mPolicy, new_depth, - NULL); + LLCore::HttpHandler::ptr_t()); if (LLCORE_HTTP_HANDLE_INVALID == handle) { status = mRequest->getStatus(); @@ -453,7 +453,7 @@ void LLAppCoreHttp::refreshSettings(bool initial) handle = mRequest->setPolicyOption(LLCore::HttpRequest::PO_CONNECTION_LIMIT, mHttpClasses[app_policy].mPolicy, (mHttpClasses[app_policy].mPipelined ? 2 * setting : setting), - NULL); + LLCore::HttpHandler::ptr_t()); if (LLCORE_HTTP_HANDLE_INVALID == handle) { status = mRequest->getStatus(); @@ -466,7 +466,7 @@ void LLAppCoreHttp::refreshSettings(bool initial) handle = mRequest->setPolicyOption(LLCore::HttpRequest::PO_PER_HOST_CONNECTION_LIMIT, mHttpClasses[app_policy].mPolicy, setting, - NULL); + LLCore::HttpHandler::ptr_t()); if (LLCORE_HTTP_HANDLE_INVALID == handle) { status = mRequest->getStatus(); diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index ad27f2e564..71f7f7394f 100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -1,5 +1,4 @@ -ptr_t -/** +/** * @file llmeshrepository.cpp * @brief Mesh repository implementation. * diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp index 61747b606e..d509f3e7c7 100755 --- a/indra/newview/lltexturefetch.cpp +++ b/indra/newview/lltexturefetch.cpp @@ -968,7 +968,7 @@ LLTextureFetchWorker::~LLTextureFetchWorker() if (mHttpActive) { // Issue a cancel on a live request... - mFetcher->getHttpRequest().requestCancel(mHttpHandle, NULL); + mFetcher->getHttpRequest().requestCancel(mHttpHandle, LLCore::HttpHandler::ptr_t()); } if (mCacheReadHandle != LLTextureCache::nullHandle() && mFetcher->mTextureCache) { -- cgit v1.3 From 8d334ca1bf51dc1a0020f53cdd7a3927bdb7740c Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Fri, 16 Oct 2015 11:40:48 -0700 Subject: MAINT-5271: Converted internal pointers to internal operation to managed shared pointers. Removed direct cast and dereference of handles. --- indra/llcorehttp/_httplibcurl.cpp | 35 ++--- indra/llcorehttp/_httplibcurl.h | 8 +- indra/llcorehttp/_httpopcancel.h | 5 - indra/llcorehttp/_httpoperation.cpp | 100 ++++++++++--- indra/llcorehttp/_httpoperation.h | 42 ++++-- indra/llcorehttp/_httpoprequest.cpp | 43 +++--- indra/llcorehttp/_httpoprequest.h | 3 +- indra/llcorehttp/_httpopsetget.h | 3 +- indra/llcorehttp/_httpopsetpriority.h | 1 - indra/llcorehttp/_httppolicy.cpp | 49 +++---- indra/llcorehttp/_httppolicy.h | 8 +- indra/llcorehttp/_httpreadyqueue.h | 6 +- indra/llcorehttp/_httpreplyqueue.cpp | 18 +-- indra/llcorehttp/_httpreplyqueue.h | 8 +- indra/llcorehttp/_httprequestqueue.cpp | 15 +- indra/llcorehttp/_httprequestqueue.h | 8 +- indra/llcorehttp/_httpretryqueue.h | 6 +- indra/llcorehttp/_httpservice.cpp | 19 ++- indra/llcorehttp/httpcommon.h | 1 + indra/llcorehttp/httprequest.cpp | 175 ++++++++--------------- indra/llcorehttp/httprequest.h | 1 - indra/llcorehttp/tests/test_httpoperation.hpp | 13 +- indra/llcorehttp/tests/test_httprequestqueue.hpp | 32 +++-- indra/newview/llmaterialmgr.cpp | 45 +----- 24 files changed, 311 insertions(+), 333 deletions(-) (limited to 'indra/llcorehttp/httprequest.cpp') diff --git a/indra/llcorehttp/_httplibcurl.cpp b/indra/llcorehttp/_httplibcurl.cpp index 17e997688f..4ebe14e740 100755 --- a/indra/llcorehttp/_httplibcurl.cpp +++ b/indra/llcorehttp/_httplibcurl.cpp @@ -71,11 +71,10 @@ void HttpLibcurl::shutdown() { while (! mActiveOps.empty()) { - HttpOpRequest * op(* mActiveOps.begin()); + HttpOpRequest::ptr_t op(* mActiveOps.begin()); mActiveOps.erase(mActiveOps.begin()); cancelRequest(op); - op->release(); } if (mMultiHandles) @@ -204,7 +203,7 @@ HttpService::ELoopSpeed HttpLibcurl::processTransport() // Caller has provided us with a ref count on op. -void HttpLibcurl::addOp(HttpOpRequest * op) +void HttpLibcurl::addOp(const HttpOpRequest::ptr_t &op) { llassert_always(op->mReqPolicy < mPolicyCount); llassert_always(mMultiHandles[op->mReqPolicy] != NULL); @@ -235,21 +234,21 @@ void HttpLibcurl::addOp(HttpOpRequest * op) HttpPolicy & policy(mService->getPolicy()); LL_INFOS(LOG_CORE) << "TRACE, ToActiveQueue, Handle: " - << static_cast(op) - << ", Actives: " << mActiveOps.size() - << ", Readies: " << policy.getReadyCount(op->mReqPolicy) - << LL_ENDL; + << op->getHandle() + << ", Actives: " << mActiveOps.size() + << ", Readies: " << policy.getReadyCount(op->mReqPolicy) + << LL_ENDL; } } // Implements the transport part of any cancel operation. // See if the handle is an active operation and if so, -// use the more complicated transport-based cancelation +// use the more complicated transport-based cancellation // method to kill the request. bool HttpLibcurl::cancel(HttpHandle handle) { - HttpOpRequest * op(static_cast(handle)); + HttpOpRequest::ptr_t op = HttpOpRequest::fromHandle(handle); active_set_t::iterator it(mActiveOps.find(op)); if (mActiveOps.end() == it) { @@ -262,7 +261,6 @@ bool HttpLibcurl::cancel(HttpHandle handle) // Drop references mActiveOps.erase(it); --mActiveHandles[op->mReqPolicy]; - op->release(); return true; } @@ -273,7 +271,7 @@ bool HttpLibcurl::cancel(HttpHandle handle) // remove the op from the active list and release the op *after* // calling this method. It must be called first to deliver the // op to the reply queue with refcount intact. -void HttpLibcurl::cancelRequest(HttpOpRequest * op) +void HttpLibcurl::cancelRequest(const HttpOpRequest::ptr_t &op) { // Deactivate request op->mCurlActive = false; @@ -287,7 +285,7 @@ void HttpLibcurl::cancelRequest(HttpOpRequest * op) if (op->mTracing > HTTP_TRACE_OFF) { LL_INFOS(LOG_CORE) << "TRACE, RequestCanceled, Handle: " - << static_cast(op) + << op->getHandle() << ", Status: " << op->mStatus.toTerseString() << LL_ENDL; } @@ -301,8 +299,11 @@ void HttpLibcurl::cancelRequest(HttpOpRequest * op) // Keep them synchronized as necessary. bool HttpLibcurl::completeRequest(CURLM * multi_handle, CURL * handle, CURLcode status) { - HttpOpRequest * op(NULL); - curl_easy_getinfo(handle, CURLINFO_PRIVATE, &op); + HttpHandle ophandle(NULL); + + curl_easy_getinfo(handle, CURLINFO_PRIVATE, &ophandle); + HttpOpRequest::ptr_t op(HttpOpRequest::fromHandle(ophandle)); + if (handle != op->mCurlHandle || ! op->mCurlActive) { @@ -364,9 +365,9 @@ bool HttpLibcurl::completeRequest(CURLM * multi_handle, CURL * handle, CURLcode if (op->mTracing > HTTP_TRACE_OFF) { LL_INFOS(LOG_CORE) << "TRACE, RequestComplete, Handle: " - << static_cast(op) - << ", Status: " << op->mStatus.toTerseString() - << LL_ENDL; + << op->getHandle() + << ", Status: " << op->mStatus.toTerseString() + << LL_ENDL; } // Dispatch to next stage diff --git a/indra/llcorehttp/_httplibcurl.h b/indra/llcorehttp/_httplibcurl.h index ffc24c63a8..a71eae59c0 100755 --- a/indra/llcorehttp/_httplibcurl.h +++ b/indra/llcorehttp/_httplibcurl.h @@ -65,6 +65,8 @@ private: void operator=(const HttpLibcurl &); // Not defined public: + typedef boost::shared_ptr opReqPtr_t; + /// Give cycles to libcurl to run active requests. Completed /// operations (successful or failed) will be retried or handed /// over to the reply queue as final responses. @@ -80,7 +82,7 @@ public: /// request. (No additional references will be added.) /// /// Threading: called by worker thread. - void addOp(HttpOpRequest * op); + void addOp(const opReqPtr_t & op); /// One-time call to set the number of policy classes to be /// serviced and to create the resources for each. Value @@ -148,10 +150,10 @@ protected: /// Invoked to cancel an active request, mainly during shutdown /// and destroy. - void cancelRequest(HttpOpRequest * op); + void cancelRequest(const opReqPtr_t &op); protected: - typedef std::set active_set_t; + typedef std::set active_set_t; /// Simple request handle cache for libcurl. /// diff --git a/indra/llcorehttp/_httpopcancel.h b/indra/llcorehttp/_httpopcancel.h index 336dfdc573..86944eb159 100755 --- a/indra/llcorehttp/_httpopcancel.h +++ b/indra/llcorehttp/_httpopcancel.h @@ -56,13 +56,8 @@ public: /// be canceled. HttpOpCancel(HttpHandle handle); -protected: virtual ~HttpOpCancel(); // Use release() -private: - HttpOpCancel(const HttpOpCancel &); // Not defined - void operator=(const HttpOpCancel &); // Not defined - public: virtual void stageFromRequest(HttpService *); diff --git a/indra/llcorehttp/_httpoperation.cpp b/indra/llcorehttp/_httpoperation.cpp index dc03b059a4..333f20d281 100755 --- a/indra/llcorehttp/_httpoperation.cpp +++ b/indra/llcorehttp/_httpoperation.cpp @@ -53,15 +53,18 @@ namespace LLCore // ================================== // HttpOperation // ================================== - - -HttpOperation::HttpOperation() - : LLCoreInt::RefCounted(true), - mReplyQueue(), - mUserHandler(), - mReqPolicy(HttpRequest::DEFAULT_POLICY_ID), - mReqPriority(0U), - mTracing(HTTP_TRACE_OFF) +/*static*/ +HttpOperation::handleMap_t HttpOperation::mHandleMap; +LLCoreInt::HttpMutex HttpOperation::mOpMutex; + +HttpOperation::HttpOperation(): + boost::enable_shared_from_this(), + mReplyQueue(), + mUserHandler(), + mReqPolicy(HttpRequest::DEFAULT_POLICY_ID), + mReqPriority(0U), + mTracing(HTTP_TRACE_OFF), + mMyHandle(LLCORE_HTTP_HANDLE_INVALID) { mMetricCreated = totalTime(); } @@ -69,7 +72,9 @@ HttpOperation::HttpOperation() HttpOperation::~HttpOperation() { - setReplyPath(HttpReplyQueue::ptr_t(), HttpHandler::ptr_t()); + destroyHandle(); + mReplyQueue.reset(); + mUserHandler.reset(); } @@ -119,7 +124,7 @@ void HttpOperation::visitNotifier(HttpRequest *) HttpResponse * response = new HttpResponse(); response->setStatus(mStatus); - mUserHandler->onCompleted(static_cast(this), response); + mUserHandler->onCompleted(getHandle(), response); response->release(); } @@ -133,20 +138,80 @@ HttpStatus HttpOperation::cancel() return status; } +// Handle methods +HttpHandle HttpOperation::getHandle() +{ + if (mMyHandle == LLCORE_HTTP_HANDLE_INVALID) + return createHandle(); + + return mMyHandle; +} + +HttpHandle HttpOperation::createHandle() +{ + HttpHandle handle = static_cast(this); + + { + LLCoreInt::HttpScopedLock lock(mOpMutex); + + mHandleMap[handle] = shared_from_this(); + mMyHandle = handle; + } + + return mMyHandle; +} + +void HttpOperation::destroyHandle() +{ + if (mMyHandle == LLCORE_HTTP_HANDLE_INVALID) + return; + { + LLCoreInt::HttpScopedLock lock(mOpMutex); + + handleMap_t::iterator it = mHandleMap.find(mMyHandle); + if (it != mHandleMap.end()) + mHandleMap.erase(it); + } +} + +/*static*/ +HttpOperation::ptr_t HttpOperation::findByHandle(HttpHandle handle) +{ + wptr_t weak; + + { + LLCoreInt::HttpScopedLock lock(mOpMutex); + + handleMap_t::iterator it = mHandleMap.find(handle); + if (it == mHandleMap.end()) + { + LL_WARNS("LLCore::HTTP") << "Could not find operation for handle " << handle << LL_ENDL; + return ptr_t(); + } + + weak = (*it).second; + } + + if (!weak.expired()) + return weak.lock(); + + return ptr_t(); +} + void HttpOperation::addAsReply() { if (mTracing > HTTP_TRACE_OFF) { LL_INFOS(LOG_CORE) << "TRACE, ToReplyQueue, Handle: " - << static_cast(this) + << getHandle() << LL_ENDL; } if (mReplyQueue) { - addRef(); - mReplyQueue->addOp(this); + HttpOperation::ptr_t op = shared_from_this(); + mReplyQueue->addOp(op); } } @@ -229,11 +294,8 @@ void HttpOpSpin::stageFromRequest(HttpService * service) else { ms_sleep(1); // backoff interlock plumbing a bit - this->addRef(); - if (! service->getRequestQueue().addOp(this)) - { - this->release(); - } + HttpOperation::ptr_t opptr = shared_from_this(); + service->getRequestQueue().addOp(opptr); } } diff --git a/indra/llcorehttp/_httpoperation.h b/indra/llcorehttp/_httpoperation.h index f677e7aed8..417bdc7c50 100755 --- a/indra/llcorehttp/_httpoperation.h +++ b/indra/llcorehttp/_httpoperation.h @@ -30,8 +30,7 @@ #include "httpcommon.h" #include "httprequest.h" -#include "_refcounted.h" - +#include "_mutex.h" namespace LLCore { @@ -69,21 +68,20 @@ class HttpService; /// via queue-like interfaces that are thread compatible /// and those interfaces establish the access rules. -class HttpOperation : public LLCoreInt::RefCounted +class HttpOperation : private boost::noncopyable, + public boost::enable_shared_from_this { public: + typedef boost::shared_ptr ptr_t; + typedef boost::weak_ptr wptr_t; typedef boost::shared_ptr HttpReplyQueuePtr_t; /// Threading: called by consumer thread. HttpOperation(); -protected: /// Threading: called by any thread. virtual ~HttpOperation(); // Use release() -private: - HttpOperation(const HttpOperation &); // Not defined - void operator=(const HttpOperation &); // Not defined public: /// Register a reply queue and a handler for completion notifications. @@ -154,6 +152,18 @@ public: /// Threading: called by worker thread. /// virtual HttpStatus cancel(); + + /// Retrieves a unique handle for this operation. + HttpHandle getHandle(); + + template< class OPT > + static boost::shared_ptr< OPT > fromHandle(HttpHandle handle) + { + ptr_t ptr = findByHandle(handle); + if (!ptr) + return boost::shared_ptr< OPT >(); + return boost::dynamic_pointer_cast(ptr); + } protected: /// Delivers request to reply queue on completion. After this @@ -179,6 +189,21 @@ public: // Tracing, debug and metrics HttpTime mMetricCreated; int mTracing; + +private: + typedef std::map handleMap_t; + + HttpHandle createHandle(); + void destroyHandle(); + HttpHandle mMyHandle; + + static handleMap_t mHandleMap; + static LLCoreInt::HttpMutex mOpMutex; + +protected: + static ptr_t findByHandle(HttpHandle handle); + + }; // end class HttpOperation @@ -197,7 +222,6 @@ class HttpOpStop : public HttpOperation public: HttpOpStop(); -protected: virtual ~HttpOpStop(); private: @@ -220,7 +244,6 @@ class HttpOpNull : public HttpOperation public: HttpOpNull(); -protected: virtual ~HttpOpNull(); private: @@ -243,7 +266,6 @@ public: // 1 does a soft spin continuously requeuing itself HttpOpSpin(int mode); -protected: virtual ~HttpOpSpin(); private: diff --git a/indra/llcorehttp/_httpoprequest.cpp b/indra/llcorehttp/_httpoprequest.cpp index 86110f5b46..557f6207b5 100755 --- a/indra/llcorehttp/_httpoprequest.cpp +++ b/indra/llcorehttp/_httpoprequest.cpp @@ -187,15 +187,15 @@ HttpOpRequest::~HttpOpRequest() void HttpOpRequest::stageFromRequest(HttpService * service) { - addRef(); - service->getPolicy().addOp(this); // transfers refcount + HttpOpRequest::ptr_t self(boost::dynamic_pointer_cast(shared_from_this())); + service->getPolicy().addOp(self); // transfers refcount } void HttpOpRequest::stageFromReady(HttpService * service) { - addRef(); - service->getTransport().addOp(this); // transfers refcount + HttpOpRequest::ptr_t self(boost::dynamic_pointer_cast(shared_from_this())); + service->getTransport().addOp(self); // transfers refcount } @@ -261,12 +261,19 @@ void HttpOpRequest::visitNotifier(HttpRequest * request) response->setTransferStats(stats); - mUserHandler->onCompleted(static_cast(this), response); + mUserHandler->onCompleted(this->getHandle(), response); response->release(); } } +// /*static*/ +// HttpOpRequest::ptr_t HttpOpRequest::fromHandle(HttpHandle handle) +// { +// +// return boost::dynamic_pointer_cast((static_cast(handle))->shared_from_this()); +// } + HttpStatus HttpOpRequest::cancel() { @@ -488,7 +495,7 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) check_curl_easy_code(code, CURLOPT_NOPROGRESS); code = curl_easy_setopt(mCurlHandle, CURLOPT_URL, mReqURL.c_str()); check_curl_easy_code(code, CURLOPT_URL); - code = curl_easy_setopt(mCurlHandle, CURLOPT_PRIVATE, this); + code = curl_easy_setopt(mCurlHandle, CURLOPT_PRIVATE, getHandle()); check_curl_easy_code(code, CURLOPT_PRIVATE); code = curl_easy_setopt(mCurlHandle, CURLOPT_ENCODING, ""); check_curl_easy_code(code, CURLOPT_ENCODING); @@ -499,15 +506,15 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) check_curl_easy_code(code, CURLOPT_MAXREDIRS); code = curl_easy_setopt(mCurlHandle, CURLOPT_WRITEFUNCTION, writeCallback); check_curl_easy_code(code, CURLOPT_WRITEFUNCTION); - code = curl_easy_setopt(mCurlHandle, CURLOPT_WRITEDATA, this); + code = curl_easy_setopt(mCurlHandle, CURLOPT_WRITEDATA, getHandle()); check_curl_easy_code(code, CURLOPT_WRITEDATA); code = curl_easy_setopt(mCurlHandle, CURLOPT_READFUNCTION, readCallback); check_curl_easy_code(code, CURLOPT_READFUNCTION); - code = curl_easy_setopt(mCurlHandle, CURLOPT_READDATA, this); + code = curl_easy_setopt(mCurlHandle, CURLOPT_READDATA, getHandle()); check_curl_easy_code(code, CURLOPT_READDATA); code = curl_easy_setopt(mCurlHandle, CURLOPT_SEEKFUNCTION, seekCallback); check_curl_easy_code(code, CURLOPT_SEEKFUNCTION); - code = curl_easy_setopt(mCurlHandle, CURLOPT_SEEKDATA, this); + code = curl_easy_setopt(mCurlHandle, CURLOPT_SEEKDATA, getHandle()); check_curl_easy_code(code, CURLOPT_SEEKDATA); code = curl_easy_setopt(mCurlHandle, CURLOPT_COOKIEFILE, ""); @@ -517,7 +524,7 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) { code = curl_easy_setopt(mCurlHandle, CURLOPT_SSL_CTX_FUNCTION, curlSslCtxCallback); check_curl_easy_code(code, CURLOPT_SSL_CTX_FUNCTION); - code = curl_easy_setopt(mCurlHandle, CURLOPT_SSL_CTX_DATA, this); + code = curl_easy_setopt(mCurlHandle, CURLOPT_SSL_CTX_DATA, getHandle()); check_curl_easy_code(code, CURLOPT_SSL_CTX_DATA); mCallbackSSLVerify = gpolicy.mSslCtxCallback; } @@ -776,7 +783,7 @@ HttpStatus HttpOpRequest::prepareRequest(HttpService * service) size_t HttpOpRequest::writeCallback(void * data, size_t size, size_t nmemb, void * userdata) { - HttpOpRequest * op(static_cast(userdata)); + HttpOpRequest::ptr_t op(HttpOpRequest::fromHandle(userdata)); if (! op->mReplyBody) { @@ -790,7 +797,7 @@ size_t HttpOpRequest::writeCallback(void * data, size_t size, size_t nmemb, void size_t HttpOpRequest::readCallback(void * data, size_t size, size_t nmemb, void * userdata) { - HttpOpRequest * op(static_cast(userdata)); + HttpOpRequest::ptr_t op(HttpOpRequest::fromHandle(userdata)); if (! op->mReqBody) { @@ -819,7 +826,7 @@ size_t HttpOpRequest::readCallback(void * data, size_t size, size_t nmemb, void int HttpOpRequest::seekCallback(void *userdata, curl_off_t offset, int origin) { - HttpOpRequest * op(static_cast(userdata)); + HttpOpRequest::ptr_t op(HttpOpRequest::fromHandle(userdata)); if (!op->mReqBody) { @@ -855,7 +862,7 @@ size_t HttpOpRequest::headerCallback(void * data, size_t size, size_t nmemb, voi static const char con_ran_line[] = "content-range"; static const char con_retry_line[] = "retry-after"; - HttpOpRequest * op(static_cast(userdata)); + HttpOpRequest::ptr_t op(HttpOpRequest::fromHandle(userdata)); const size_t hdr_size(size * nmemb); const char * hdr_data(static_cast(data)); // Not null terminated @@ -999,7 +1006,7 @@ size_t HttpOpRequest::headerCallback(void * data, size_t size, size_t nmemb, voi CURLcode HttpOpRequest::curlSslCtxCallback(CURL *curl, void *sslctx, void *userdata) { - HttpOpRequest * op(static_cast(userdata)); + HttpOpRequest::ptr_t op(HttpOpRequest::fromHandle(userdata)); if (op->mCallbackSSLVerify) { @@ -1016,7 +1023,7 @@ CURLcode HttpOpRequest::curlSslCtxCallback(CURL *curl, void *sslctx, void *userd int HttpOpRequest::sslCertVerifyCallback(X509_STORE_CTX *ctx, void *param) { - HttpOpRequest * op(static_cast(param)); + HttpOpRequest::ptr_t op(HttpOpRequest::fromHandle(param)); if (op->mCallbackSSLVerify) { @@ -1028,7 +1035,7 @@ int HttpOpRequest::sslCertVerifyCallback(X509_STORE_CTX *ctx, void *param) int HttpOpRequest::debugCallback(CURL * handle, curl_infotype info, char * buffer, size_t len, void * userdata) { - HttpOpRequest * op(static_cast(userdata)); + HttpOpRequest::ptr_t op(HttpOpRequest::fromHandle(userdata)); std::string safe_line; std::string tag; @@ -1108,7 +1115,7 @@ int HttpOpRequest::debugCallback(CURL * handle, curl_infotype info, char * buffe if (logit) { LL_INFOS(LOG_CORE) << "TRACE, LibcurlDebug, Handle: " - << static_cast(op) + << op->getHandle() << ", Type: " << tag << ", Data: " << safe_line << LL_ENDL; diff --git a/indra/llcorehttp/_httpoprequest.h b/indra/llcorehttp/_httpoprequest.h index 1b449a5abc..dbcc57d0fd 100755 --- a/indra/llcorehttp/_httpoprequest.h +++ b/indra/llcorehttp/_httpoprequest.h @@ -66,9 +66,10 @@ class BufferArray; class HttpOpRequest : public HttpOperation { public: + typedef boost::shared_ptr ptr_t; + HttpOpRequest(); -protected: virtual ~HttpOpRequest(); // Use release() private: diff --git a/indra/llcorehttp/_httpopsetget.h b/indra/llcorehttp/_httpopsetget.h index a1e76dd429..eabd41e79f 100755 --- a/indra/llcorehttp/_httpopsetget.h +++ b/indra/llcorehttp/_httpopsetget.h @@ -53,9 +53,10 @@ namespace LLCore class HttpOpSetGet : public HttpOperation { public: + typedef boost::shared_ptr ptr_t; + HttpOpSetGet(); -protected: virtual ~HttpOpSetGet(); // Use release() private: diff --git a/indra/llcorehttp/_httpopsetpriority.h b/indra/llcorehttp/_httpopsetpriority.h index 31706b737c..43e2aa081b 100755 --- a/indra/llcorehttp/_httpopsetpriority.h +++ b/indra/llcorehttp/_httpopsetpriority.h @@ -51,7 +51,6 @@ class HttpOpSetPriority : public HttpOperation public: HttpOpSetPriority(HttpHandle handle, HttpRequest::priority_t priority); -protected: virtual ~HttpOpSetPriority(); private: diff --git a/indra/llcorehttp/_httppolicy.cpp b/indra/llcorehttp/_httppolicy.cpp index e5d6321401..fd78a5dadc 100755 --- a/indra/llcorehttp/_httppolicy.cpp +++ b/indra/llcorehttp/_httppolicy.cpp @@ -116,21 +116,19 @@ void HttpPolicy::shutdown() HttpRetryQueue & retryq(state.mRetryQueue); while (! retryq.empty()) { - HttpOpRequest * op(retryq.top()); + HttpOpRequest::ptr_t op(retryq.top()); retryq.pop(); op->cancel(); - op->release(); } HttpReadyQueue & readyq(state.mReadyQueue); while (! readyq.empty()) { - HttpOpRequest * op(readyq.top()); + HttpOpRequest::ptr_t op(readyq.top()); readyq.pop(); op->cancel(); - op->release(); } } } @@ -141,7 +139,7 @@ void HttpPolicy::start() } -void HttpPolicy::addOp(HttpOpRequest * op) +void HttpPolicy::addOp(const HttpOpRequest::ptr_t &op) { const int policy_class(op->mReqPolicy); @@ -151,7 +149,7 @@ void HttpPolicy::addOp(HttpOpRequest * op) } -void HttpPolicy::retryOp(HttpOpRequest * op) +void HttpPolicy::retryOp(const HttpOpRequest::ptr_t &op) { static const HttpTime retry_deltas[] = { @@ -180,7 +178,7 @@ void HttpPolicy::retryOp(HttpOpRequest * op) { ++op->mPolicy503Retries; } - LL_DEBUGS(LOG_CORE) << "HTTP request " << static_cast(op) + LL_DEBUGS(LOG_CORE) << "HTTP request " << op->getHandle() << " retry " << op->mPolicyRetries << " scheduled in " << (delta / HttpTime(1000)) << " mS (" << (external_delta ? "external" : "internal") @@ -189,10 +187,10 @@ void HttpPolicy::retryOp(HttpOpRequest * op) if (op->mTracing > HTTP_TRACE_OFF) { LL_INFOS(LOG_CORE) << "TRACE, ToRetryQueue, Handle: " - << static_cast(op) - << ", Delta: " << (delta / HttpTime(1000)) - << ", Retries: " << op->mPolicyRetries - << LL_ENDL; + << op->getHandle() + << ", Delta: " << (delta / HttpTime(1000)) + << ", Retries: " << op->mPolicyRetries + << LL_ENDL; } mClasses[policy_class]->mRetryQueue.push(op); } @@ -264,14 +262,14 @@ HttpService::ELoopSpeed HttpPolicy::processReadyQueue() // First see if we have any retries... while (needed > 0 && ! retryq.empty()) { - HttpOpRequest * op(retryq.top()); + HttpOpRequest::ptr_t op(retryq.top()); if (op->mPolicyRetryAt > now) break; retryq.pop(); op->stageFromReady(mService); - op->release(); + op.reset(); ++state.mRequestCount; --needed; @@ -296,11 +294,11 @@ HttpService::ELoopSpeed HttpPolicy::processReadyQueue() // Now go on to the new requests... while (needed > 0 && ! readyq.empty()) { - HttpOpRequest * op(readyq.top()); + HttpOpRequest::ptr_t op(readyq.top()); readyq.pop(); op->stageFromReady(mService); - op->release(); + op.reset(); ++state.mRequestCount; --needed; @@ -351,9 +349,9 @@ bool HttpPolicy::changePriority(HttpHandle handle, HttpRequest::priority_t prior { HttpReadyQueue::container_type::iterator cur(iter++); - if (static_cast(*cur) == handle) + if ((*cur)->getHandle() == handle) { - HttpOpRequest * op(*cur); + HttpOpRequest::ptr_t op(*cur); c.erase(cur); // All iterators are now invalidated op->mReqPriority = priority; state.mReadyQueue.push(op); // Re-insert using adapter class @@ -378,12 +376,11 @@ bool HttpPolicy::cancel(HttpHandle handle) { HttpRetryQueue::container_type::iterator cur(iter++); - if (static_cast(*cur) == handle) + if ((*cur)->getHandle() == handle) { - HttpOpRequest * op(*cur); + HttpOpRequest::ptr_t op(*cur); c1.erase(cur); // All iterators are now invalidated op->cancel(); - op->release(); return true; } } @@ -394,12 +391,11 @@ bool HttpPolicy::cancel(HttpHandle handle) { HttpReadyQueue::container_type::iterator cur(iter++); - if (static_cast(*cur) == handle) + if ((*cur)->getHandle() == handle) { - HttpOpRequest * op(*cur); + HttpOpRequest::ptr_t op(*cur); c2.erase(cur); // All iterators are now invalidated op->cancel(); - op->release(); return true; } } @@ -409,7 +405,7 @@ bool HttpPolicy::cancel(HttpHandle handle) } -bool HttpPolicy::stageAfterCompletion(HttpOpRequest * op) +bool HttpPolicy::stageAfterCompletion(const HttpOpRequest::ptr_t &op) { // Retry or finalize if (! op->mStatus) @@ -438,7 +434,7 @@ bool HttpPolicy::stageAfterCompletion(HttpOpRequest * op) // This op is done, finalize it delivering it to the reply queue... if (! op->mStatus) { - LL_WARNS(LOG_CORE) << "HTTP request " << static_cast(op) + LL_WARNS(LOG_CORE) << "HTTP request " << op->getHandle() << " failed after " << op->mPolicyRetries << " retries. Reason: " << op->mStatus.toString() << " (" << op->mStatus.toTerseString() << ")" @@ -446,13 +442,12 @@ bool HttpPolicy::stageAfterCompletion(HttpOpRequest * op) } else if (op->mPolicyRetries) { - LL_DEBUGS(LOG_CORE) << "HTTP request " << static_cast(op) + LL_DEBUGS(LOG_CORE) << "HTTP request " << op->getHandle() << " succeeded on retry " << op->mPolicyRetries << "." << LL_ENDL; } op->stageFromActive(mService); - op->release(); return false; // not active } diff --git a/indra/llcorehttp/_httppolicy.h b/indra/llcorehttp/_httppolicy.h index 11cd89bbd1..3c4126e14b 100755 --- a/indra/llcorehttp/_httppolicy.h +++ b/indra/llcorehttp/_httppolicy.h @@ -60,6 +60,8 @@ private: void operator=(const HttpPolicy &); // Not defined public: + typedef boost::shared_ptr opReqPtr_t; + /// Threading: called by init thread. HttpRequest::policy_t createPolicyClass(); @@ -96,7 +98,7 @@ public: /// from queue. /// /// Threading: called by worker thread - void addOp(HttpOpRequest *); + void addOp(const opReqPtr_t &); /// Similar to addOp, used when a caller wants to retry a /// request that has failed. It's placed on a special retry @@ -106,7 +108,7 @@ public: /// order. /// /// Threading: called by worker thread - void retryOp(HttpOpRequest *); + void retryOp(const opReqPtr_t &); /// Attempt to change the priority of an earlier request. /// Request that Shadows HttpService's method @@ -130,7 +132,7 @@ public: /// sent on to the reply queue. /// /// Threading: called by worker thread - bool stageAfterCompletion(HttpOpRequest * op); + bool stageAfterCompletion(const opReqPtr_t &op); /// Get a reference to global policy options. Caller is expected /// to do context checks like no setting once running. These diff --git a/indra/llcorehttp/_httpreadyqueue.h b/indra/llcorehttp/_httpreadyqueue.h index 5f19a9c5f9..7418988ec1 100755 --- a/indra/llcorehttp/_httpreadyqueue.h +++ b/indra/llcorehttp/_httpreadyqueue.h @@ -56,12 +56,12 @@ namespace LLCore #if LLCORE_HTTP_READY_QUEUE_IGNORES_PRIORITY -typedef std::deque HttpReadyQueueBase; +typedef std::deque HttpReadyQueueBase; #else -typedef std::priority_queue, +typedef std::priority_queue, LLCore::HttpOpRequestCompare> HttpReadyQueueBase; #endif // LLCORE_HTTP_READY_QUEUE_IGNORES_PRIORITY diff --git a/indra/llcorehttp/_httpreplyqueue.cpp b/indra/llcorehttp/_httpreplyqueue.cpp index 912655d328..2b138f3ad5 100755 --- a/indra/llcorehttp/_httpreplyqueue.cpp +++ b/indra/llcorehttp/_httpreplyqueue.cpp @@ -45,16 +45,11 @@ HttpReplyQueue::HttpReplyQueue() HttpReplyQueue::~HttpReplyQueue() { - while (! mQueue.empty()) - { - HttpOperation * op = mQueue.back(); - mQueue.pop_back(); - op->release(); - } + mQueue.clear(); } -void HttpReplyQueue::addOp(HttpOperation * op) +void HttpReplyQueue::addOp(const HttpReplyQueue::opPtr_t &op) { { HttpScopedLock lock(mQueueMutex); @@ -65,15 +60,15 @@ void HttpReplyQueue::addOp(HttpOperation * op) } -HttpOperation * HttpReplyQueue::fetchOp() +HttpReplyQueue::opPtr_t HttpReplyQueue::fetchOp() { - HttpOperation * result(NULL); + HttpOperation::ptr_t result; { HttpScopedLock lock(mQueueMutex); if (mQueue.empty()) - return NULL; + return opPtr_t(); result = mQueue.front(); mQueue.erase(mQueue.begin()); @@ -97,9 +92,6 @@ void HttpReplyQueue::fetchAll(OpContainer & ops) mQueue.swap(ops); } } - - // Caller also acquires the reference counts on each op. - return; } diff --git a/indra/llcorehttp/_httpreplyqueue.h b/indra/llcorehttp/_httpreplyqueue.h index 7ad65c581f..0e39e22dde 100755 --- a/indra/llcorehttp/_httpreplyqueue.h +++ b/indra/llcorehttp/_httpreplyqueue.h @@ -62,13 +62,15 @@ class HttpReplyQueue : private boost::noncopyable { public: + typedef boost::shared_ptr opPtr_t; typedef boost::shared_ptr ptr_t; HttpReplyQueue(); virtual ~HttpReplyQueue(); public: - typedef std::vector OpContainer; + + typedef std::vector< opPtr_t > OpContainer; /// Insert an object at the back of the reply queue. /// @@ -76,7 +78,7 @@ public: /// through the queue. /// /// Threading: callable by any thread. - void addOp(HttpOperation * op); + void addOp(const opPtr_t &op); /// Fetch an operation from the head of the queue. Returns /// NULL if none exists. @@ -84,7 +86,7 @@ public: /// Caller acquires reference count on returned operation. /// /// Threading: callable by any thread. - HttpOperation * fetchOp(); + opPtr_t fetchOp(); /// Caller acquires reference count on each returned operation /// diff --git a/indra/llcorehttp/_httprequestqueue.cpp b/indra/llcorehttp/_httprequestqueue.cpp index c16966d078..c6f4ad789f 100755 --- a/indra/llcorehttp/_httprequestqueue.cpp +++ b/indra/llcorehttp/_httprequestqueue.cpp @@ -47,12 +47,7 @@ HttpRequestQueue::HttpRequestQueue() HttpRequestQueue::~HttpRequestQueue() { - while (! mQueue.empty()) - { - HttpOperation * op = mQueue.back(); - mQueue.pop_back(); - op->release(); - } + mQueue.clear(); } @@ -73,7 +68,7 @@ void HttpRequestQueue::term() } -HttpStatus HttpRequestQueue::addOp(HttpOperation * op) +HttpStatus HttpRequestQueue::addOp(const HttpRequestQueue::opPtr_t &op) { bool wake(false); { @@ -95,9 +90,9 @@ HttpStatus HttpRequestQueue::addOp(HttpOperation * op) } -HttpOperation * HttpRequestQueue::fetchOp(bool wait) +HttpRequestQueue::opPtr_t HttpRequestQueue::fetchOp(bool wait) { - HttpOperation * result(NULL); + HttpOperation::ptr_t result; { HttpScopedLock lock(mQueueMutex); @@ -105,7 +100,7 @@ HttpOperation * HttpRequestQueue::fetchOp(bool wait) while (mQueue.empty()) { if (! wait || mQueueStopped) - return NULL; + return HttpOperation::ptr_t(); mQueueCV.wait(lock); } diff --git a/indra/llcorehttp/_httprequestqueue.h b/indra/llcorehttp/_httprequestqueue.h index c9c52b7233..3c3d134b07 100755 --- a/indra/llcorehttp/_httprequestqueue.h +++ b/indra/llcorehttp/_httprequestqueue.h @@ -61,6 +61,8 @@ private: void operator=(const HttpRequestQueue &); // Not defined public: + typedef boost::shared_ptr opPtr_t; + static void init(); static void term(); @@ -71,7 +73,7 @@ public: } public: - typedef std::vector OpContainer; + typedef std::vector OpContainer; /// Insert an object at the back of the request queue. /// @@ -83,7 +85,7 @@ public: /// an explicit release() call. /// /// Threading: callable by any thread. - HttpStatus addOp(HttpOperation * op); + HttpStatus addOp(const opPtr_t &op); /// Return the operation on the front of the queue. If /// the queue is empty and @wait is false, call returns @@ -95,7 +97,7 @@ public: /// Caller acquires reference count any returned operation /// /// Threading: callable by any thread. - HttpOperation * fetchOp(bool wait); + opPtr_t fetchOp(bool wait); /// Return all queued requests to caller. The @ops argument /// should be empty when called and will be swap()'d with diff --git a/indra/llcorehttp/_httpretryqueue.h b/indra/llcorehttp/_httpretryqueue.h index 745adec09d..5d8c529cff 100755 --- a/indra/llcorehttp/_httpretryqueue.h +++ b/indra/llcorehttp/_httpretryqueue.h @@ -49,15 +49,15 @@ namespace LLCore struct HttpOpRetryCompare { - bool operator()(const HttpOpRequest * lhs, const HttpOpRequest * rhs) + bool operator()(const HttpOpRequest::ptr_t &lhs, const HttpOpRequest::ptr_t &rhs) { return lhs->mPolicyRetryAt < rhs->mPolicyRetryAt; } }; -typedef std::priority_queue, +typedef std::priority_queue, LLCore::HttpOpRetryCompare> HttpRetryQueueBase; class HttpRetryQueue : public HttpRetryQueueBase diff --git a/indra/llcorehttp/_httpservice.cpp b/indra/llcorehttp/_httpservice.cpp index 252db78c89..6c39fdc61b 100755 --- a/indra/llcorehttp/_httpservice.cpp +++ b/indra/llcorehttp/_httpservice.cpp @@ -263,14 +263,13 @@ void HttpService::shutdown() // Cancel requests already on the request queue HttpRequestQueue::OpContainer ops; mRequestQueue->fetchAll(false, ops); - while (! ops.empty()) - { - HttpOperation * op(ops.front()); - ops.erase(ops.begin()); - op->cancel(); - op->release(); - } + for (HttpRequestQueue::OpContainer::iterator it = ops.begin(); + it != ops.end(); ++it) + { + (*it)->cancel(); + } + ops.clear(); // Shutdown transport canceling requests, freeing resources mTransport->shutdown(); @@ -324,7 +323,7 @@ HttpService::ELoopSpeed HttpService::processRequestQueue(ELoopSpeed loop) mRequestQueue->fetchAll(wait_for_req, ops); while (! ops.empty()) { - HttpOperation * op(ops.front()); + HttpOperation::ptr_t op(ops.front()); ops.erase(ops.begin()); // Process operation @@ -338,7 +337,7 @@ HttpService::ELoopSpeed HttpService::processRequestQueue(ELoopSpeed loop) if (op->mTracing > HTTP_TRACE_OFF) { LL_INFOS(LOG_CORE) << "TRACE, FromRequestQueue, Handle: " - << static_cast(op) + << op->getHandle() << LL_ENDL; } @@ -347,7 +346,7 @@ HttpService::ELoopSpeed HttpService::processRequestQueue(ELoopSpeed loop) } // Done with operation - op->release(); + op.reset(); } // Queue emptied, allow polling loop to sleep diff --git a/indra/llcorehttp/httpcommon.h b/indra/llcorehttp/httpcommon.h index 1bc20fe6b5..b2db01d038 100755 --- a/indra/llcorehttp/httpcommon.h +++ b/indra/llcorehttp/httpcommon.h @@ -209,6 +209,7 @@ namespace LLCore /// becomes invalid and may be recycled for other queued requests. typedef void * HttpHandle; + #define LLCORE_HTTP_HANDLE_INVALID (NULL) /// For internal scheduling and metrics, we use a microsecond diff --git a/indra/llcorehttp/httprequest.cpp b/indra/llcorehttp/httprequest.cpp index 24e0f582e1..1c7994927b 100755 --- a/indra/llcorehttp/httprequest.cpp +++ b/indra/llcorehttp/httprequest.cpp @@ -127,27 +127,22 @@ HttpHandle HttpRequest::setPolicyOption(EPolicyOption opt, policy_t pclass, long value, HttpHandler::ptr_t handler) { HttpStatus status; - HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpSetGet * op = new HttpOpSetGet(); + HttpOpSetGet::ptr_t op(new HttpOpSetGet()); if (! (status = op->setupSet(opt, pclass, value))) { - op->release(); mLastReqStatus = status; - return handle; + return LLCORE_HTTP_HANDLE_INVALID; } op->setReplyPath(mReplyQueue, handler); if (! (status = mRequestQueue->addOp(op))) // transfers refcount { - op->release(); mLastReqStatus = status; - return handle; + return LLCORE_HTTP_HANDLE_INVALID; } mLastReqStatus = status; - handle = static_cast(op); - - return handle; + return op->getHandle(); } @@ -155,27 +150,22 @@ HttpHandle HttpRequest::setPolicyOption(EPolicyOption opt, policy_t pclass, const std::string & value, HttpHandler::ptr_t handler) { HttpStatus status; - HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpSetGet * op = new HttpOpSetGet(); + HttpOpSetGet::ptr_t op (new HttpOpSetGet()); if (! (status = op->setupSet(opt, pclass, value))) { - op->release(); mLastReqStatus = status; - return handle; + return LLCORE_HTTP_HANDLE_INVALID; } op->setReplyPath(mReplyQueue, handler); if (! (status = mRequestQueue->addOp(op))) // transfers refcount { - op->release(); mLastReqStatus = status; - return handle; + return LLCORE_HTTP_HANDLE_INVALID; } mLastReqStatus = status; - handle = static_cast(op); - - return handle; + return op->getHandle(); } @@ -198,27 +188,22 @@ HttpHandle HttpRequest::requestGet(policy_t policy_id, HttpHandler::ptr_t user_handler) { HttpStatus status; - HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(); + HttpOpRequest::ptr_t op(new HttpOpRequest()); if (! (status = op->setupGet(policy_id, priority, url, options, headers))) { - op->release(); mLastReqStatus = status; - return handle; + return LLCORE_HTTP_HANDLE_INVALID; } op->setReplyPath(mReplyQueue, user_handler); if (! (status = mRequestQueue->addOp(op))) // transfers refcount { - op->release(); mLastReqStatus = status; - return handle; + return LLCORE_HTTP_HANDLE_INVALID; } mLastReqStatus = status; - handle = static_cast(op); - - return handle; + return op->getHandle(); } @@ -232,27 +217,22 @@ HttpHandle HttpRequest::requestGetByteRange(policy_t policy_id, HttpHandler::ptr_t user_handler) { HttpStatus status; - HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(); + HttpOpRequest::ptr_t op(new HttpOpRequest()); if (! (status = op->setupGetByteRange(policy_id, priority, url, offset, len, options, headers))) { - op->release(); mLastReqStatus = status; - return handle; + return LLCORE_HTTP_HANDLE_INVALID; } op->setReplyPath(mReplyQueue, user_handler); if (! (status = mRequestQueue->addOp(op))) // transfers refcount { - op->release(); mLastReqStatus = status; - return handle; + return LLCORE_HTTP_HANDLE_INVALID; } mLastReqStatus = status; - handle = static_cast(op); - - return handle; + return op->getHandle(); } @@ -265,27 +245,22 @@ HttpHandle HttpRequest::requestPost(policy_t policy_id, HttpHandler::ptr_t user_handler) { HttpStatus status; - HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(); + HttpOpRequest::ptr_t op(new HttpOpRequest()); if (! (status = op->setupPost(policy_id, priority, url, body, options, headers))) { - op->release(); mLastReqStatus = status; - return handle; + return LLCORE_HTTP_HANDLE_INVALID; } op->setReplyPath(mReplyQueue, user_handler); if (! (status = mRequestQueue->addOp(op))) // transfers refcount { - op->release(); mLastReqStatus = status; - return handle; + return LLCORE_HTTP_HANDLE_INVALID; } mLastReqStatus = status; - handle = static_cast(op); - - return handle; + return op->getHandle(); } @@ -298,27 +273,22 @@ HttpHandle HttpRequest::requestPut(policy_t policy_id, HttpHandler::ptr_t user_handler) { HttpStatus status; - HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(); + HttpOpRequest::ptr_t op (new HttpOpRequest()); if (! (status = op->setupPut(policy_id, priority, url, body, options, headers))) { - op->release(); mLastReqStatus = status; - return handle; + return LLCORE_HTTP_HANDLE_INVALID; } op->setReplyPath(mReplyQueue, user_handler); if (! (status = mRequestQueue->addOp(op))) // transfers refcount { - op->release(); mLastReqStatus = status; - return handle; + return LLCORE_HTTP_HANDLE_INVALID; } mLastReqStatus = status; - handle = static_cast(op); - - return handle; + return op->getHandle(); } HttpHandle HttpRequest::requestDelete(policy_t policy_id, @@ -329,27 +299,22 @@ HttpHandle HttpRequest::requestDelete(policy_t policy_id, HttpHandler::ptr_t user_handler) { HttpStatus status; - HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(); + HttpOpRequest::ptr_t op(new HttpOpRequest()); if (!(status = op->setupDelete(policy_id, priority, url, options, headers))) { - op->release(); mLastReqStatus = status; - return handle; + return LLCORE_HTTP_HANDLE_INVALID; } op->setReplyPath(mReplyQueue, user_handler); if (!(status = mRequestQueue->addOp(op))) // transfers refcount { - op->release(); mLastReqStatus = status; - return handle; + return LLCORE_HTTP_HANDLE_INVALID; } mLastReqStatus = status; - handle = static_cast(op); - - return handle; + return op->getHandle(); } HttpHandle HttpRequest::requestPatch(policy_t policy_id, @@ -361,27 +326,22 @@ HttpHandle HttpRequest::requestPatch(policy_t policy_id, HttpHandler::ptr_t user_handler) { HttpStatus status; - HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(); + HttpOpRequest::ptr_t op (new HttpOpRequest()); if (!(status = op->setupPatch(policy_id, priority, url, body, options, headers))) { - op->release(); mLastReqStatus = status; - return handle; + return LLCORE_HTTP_HANDLE_INVALID; } op->setReplyPath(mReplyQueue, user_handler); if (!(status = mRequestQueue->addOp(op))) // transfers refcount { - op->release(); mLastReqStatus = status; - return handle; + return LLCORE_HTTP_HANDLE_INVALID; } mLastReqStatus = status; - handle = static_cast(op); - - return handle; + return op->getHandle(); } HttpHandle HttpRequest::requestCopy(policy_t policy_id, @@ -392,27 +352,23 @@ HttpHandle HttpRequest::requestCopy(policy_t policy_id, HttpHandler::ptr_t user_handler) { HttpStatus status; - HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(); + HttpOpRequest::ptr_t op(new HttpOpRequest()); if (!(status = op->setupCopy(policy_id, priority, url, options, headers))) { - op->release(); mLastReqStatus = status; - return handle; + return LLCORE_HTTP_HANDLE_INVALID; } op->setReplyPath(mReplyQueue, user_handler); if (!(status = mRequestQueue->addOp(op))) // transfers refcount { - op->release(); mLastReqStatus = status; - return handle; + return LLCORE_HTTP_HANDLE_INVALID; } mLastReqStatus = status; - handle = static_cast(op); + return op->getHandle(); - return handle; } HttpHandle HttpRequest::requestMove(policy_t policy_id, @@ -423,54 +379,45 @@ HttpHandle HttpRequest::requestMove(policy_t policy_id, HttpHandler::ptr_t user_handler) { HttpStatus status; - HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpRequest * op = new HttpOpRequest(); + HttpOpRequest::ptr_t op (new HttpOpRequest()); if (!(status = op->setupMove(policy_id, priority, url, options, headers))) { - op->release(); mLastReqStatus = status; - return handle; + return LLCORE_HTTP_HANDLE_INVALID; } op->setReplyPath(mReplyQueue, user_handler); if (!(status = mRequestQueue->addOp(op))) // transfers refcount { - op->release(); mLastReqStatus = status; - return handle; + return LLCORE_HTTP_HANDLE_INVALID; } mLastReqStatus = status; - handle = static_cast(op); - - return handle; + return op->getHandle(); } HttpHandle HttpRequest::requestNoOp(HttpHandler::ptr_t user_handler) { HttpStatus status; - HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpNull * op = new HttpOpNull(); + HttpOperation::ptr_t op (new HttpOpNull()); op->setReplyPath(mReplyQueue, user_handler); if (! (status = mRequestQueue->addOp(op))) // transfers refcount { - op->release(); mLastReqStatus = status; - return handle; + return LLCORE_HTTP_HANDLE_INVALID; } mLastReqStatus = status; - handle = static_cast(op); - - return handle; + return op->getHandle(); } HttpStatus HttpRequest::update(long usecs) { - HttpOperation * op(NULL); + HttpOperation::ptr_t op; if (usecs) { @@ -481,7 +428,7 @@ HttpStatus HttpRequest::update(long usecs) op->visitNotifier(this); // We're done with the operation - op->release(); + op.reset(); } } else @@ -502,7 +449,7 @@ HttpStatus HttpRequest::update(long usecs) op->visitNotifier(this); // We're done with the operation - op->release(); + op.reset(); } } } @@ -520,21 +467,17 @@ HttpStatus HttpRequest::update(long usecs) HttpHandle HttpRequest::requestCancel(HttpHandle request, HttpHandler::ptr_t user_handler) { HttpStatus status; - HttpHandle ret_handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpCancel * op = new HttpOpCancel(request); + HttpOperation::ptr_t op(new HttpOpCancel(request)); op->setReplyPath(mReplyQueue, user_handler); if (! (status = mRequestQueue->addOp(op))) // transfers refcount { - op->release(); mLastReqStatus = status; - return ret_handle; + return LLCORE_HTTP_HANDLE_INVALID; } mLastReqStatus = status; - ret_handle = static_cast(op); - - return ret_handle; + return op->getHandle(); } @@ -542,21 +485,17 @@ HttpHandle HttpRequest::requestSetPriority(HttpHandle request, priority_t priori HttpHandler::ptr_t handler) { HttpStatus status; - HttpHandle ret_handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpSetPriority * op = new HttpOpSetPriority(request, priority); + HttpOperation::ptr_t op (new HttpOpSetPriority(request, priority)); op->setReplyPath(mReplyQueue, handler); if (! (status = mRequestQueue->addOp(op))) // transfers refcount { - op->release(); mLastReqStatus = status; - return ret_handle; + return LLCORE_HTTP_HANDLE_INVALID; } mLastReqStatus = status; - ret_handle = static_cast(op); - - return ret_handle; + return op->getHandle(); } @@ -610,17 +549,16 @@ HttpHandle HttpRequest::requestStopThread(HttpHandler::ptr_t user_handler) HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpStop * op = new HttpOpStop(); + HttpOperation::ptr_t op(new HttpOpStop()); op->setReplyPath(mReplyQueue, user_handler); if (! (status = mRequestQueue->addOp(op))) // transfers refcount { - op->release(); mLastReqStatus = status; return handle; } mLastReqStatus = status; - handle = static_cast(op); + handle = op->getHandle(); return handle; } @@ -631,17 +569,16 @@ HttpHandle HttpRequest::requestSpin(int mode) HttpStatus status; HttpHandle handle(LLCORE_HTTP_HANDLE_INVALID); - HttpOpSpin * op = new HttpOpSpin(mode); + HttpOperation::ptr_t op(new HttpOpSpin(mode)); op->setReplyPath(mReplyQueue, HttpHandler::ptr_t()); if (! (status = mRequestQueue->addOp(op))) // transfers refcount { - op->release(); mLastReqStatus = status; return handle; } mLastReqStatus = status; - handle = static_cast(op); + handle = op->getHandle(); return handle; } diff --git a/indra/llcorehttp/httprequest.h b/indra/llcorehttp/httprequest.h index 2eb3caa11e..17cfdcd7b6 100755 --- a/indra/llcorehttp/httprequest.h +++ b/indra/llcorehttp/httprequest.h @@ -655,7 +655,6 @@ public: /// @} protected: - void generateNotification(HttpOperation * op); private: typedef boost::shared_ptr HttpReplyQueuePtr_t; diff --git a/indra/llcorehttp/tests/test_httpoperation.hpp b/indra/llcorehttp/tests/test_httpoperation.hpp index 890e5fdd9c..e7df2337de 100755 --- a/indra/llcorehttp/tests/test_httpoperation.hpp +++ b/indra/llcorehttp/tests/test_httpoperation.hpp @@ -76,12 +76,12 @@ namespace tut mMemTotal = GetMemTotal(); // create a new ref counted object with an implicit reference - HttpOpNull * op = new HttpOpNull(); - ensure(op->getRefCount() == 1); + HttpOperation::ptr_t op (new HttpOpNull()); + ensure(op.use_count() == 1); ensure(mMemTotal < GetMemTotal()); // release the implicit reference, causing the object to be released - op->release(); + op.reset(); // make sure we didn't leak any memory ensure(mMemTotal == GetMemTotal()); @@ -99,18 +99,17 @@ namespace tut LLCore::HttpHandler::ptr_t h1 (new TestHandler()); // create a new ref counted object with an implicit reference - HttpOpNull * op = new HttpOpNull(); + HttpOperation::ptr_t op (new HttpOpNull()); // Add the handlers op->setReplyPath(LLCore::HttpOperation::HttpReplyQueuePtr_t(), h1); // Check ref count - ensure(op->getRefCount() == 1); + ensure(op.unique() == 1); // release the reference, releasing the operation but // not the handlers. - op->release(); - op = NULL; + op.reset(); ensure(mMemTotal != GetMemTotal()); // release the handlers diff --git a/indra/llcorehttp/tests/test_httprequestqueue.hpp b/indra/llcorehttp/tests/test_httprequestqueue.hpp index 1de2d8f9ab..ef4ce0479b 100755 --- a/indra/llcorehttp/tests/test_httprequestqueue.hpp +++ b/indra/llcorehttp/tests/test_httprequestqueue.hpp @@ -113,16 +113,16 @@ void HttpRequestqueueTestObjectType::test<3>() HttpRequestQueue * rq = HttpRequestQueue::instanceOf(); - HttpOperation * op = new HttpOpNull(); + HttpOperation::ptr_t op(new HttpOpNull()); rq->addOp(op); // transfer my refcount op = rq->fetchOp(true); // Potentially hangs the test on failure - ensure("One goes in, one comes out", NULL != op); - op->release(); + ensure("One goes in, one comes out", static_cast(op)); + op.reset(); op = rq->fetchOp(false); - ensure("Better not be two of them", NULL == op); + ensure("Better not be two of them", !op); // release the singleton, hold on to the object HttpRequestQueue::term(); @@ -144,13 +144,13 @@ void HttpRequestqueueTestObjectType::test<4>() HttpRequestQueue * rq = HttpRequestQueue::instanceOf(); - HttpOperation * op = new HttpOpNull(); + HttpOperation::ptr_t op (new HttpOpNull()); rq->addOp(op); // transfer my refcount - op = new HttpOpNull(); + op.reset(new HttpOpNull()); rq->addOp(op); // transfer my refcount - op = new HttpOpNull(); + op.reset(new HttpOpNull()); rq->addOp(op); // transfer my refcount { @@ -159,8 +159,9 @@ void HttpRequestqueueTestObjectType::test<4>() ensure("Three go in, three come out", 3 == ops.size()); op = rq->fetchOp(false); - ensure("Better not be any more of them", NULL == op); - + ensure("Better not be any more of them", !op); + op.reset(); + // release the singleton, hold on to the object HttpRequestQueue::term(); @@ -168,12 +169,13 @@ void HttpRequestqueueTestObjectType::test<4>() ensure(mMemTotal < GetMemTotal()); // Release them - while (! ops.empty()) - { - HttpOperation * op = ops.front(); - ops.erase(ops.begin()); - op->release(); - } + ops.clear(); +// while (! ops.empty()) +// { +// HttpOperation * op = ops.front(); +// ops.erase(ops.begin()); +// op->release(); +// } } // Should be clean diff --git a/indra/newview/llmaterialmgr.cpp b/indra/newview/llmaterialmgr.cpp index 6dc0525365..9ac560c217 100755 --- a/indra/newview/llmaterialmgr.cpp +++ b/indra/newview/llmaterialmgr.cpp @@ -594,6 +594,9 @@ void LLMaterialMgr::processGetQueue() while (mGetQueue.end() != loopRegionQueue) { #if 1 + //* $TODO: This block is screaming to be turned into a coroutine. + // see processGetQueueCoro() below. + // get_queue_t::iterator itRegionQueue = loopRegionQueue++; const LLUUID& region_id = itRegionQueue->first; @@ -789,50 +792,10 @@ void LLMaterialMgr::processGetAllQueue() getall_queue_t::iterator itRegion = loopRegion++; const LLUUID& region_id = *itRegion; -#if 1 + LLCoros::instance().launch("LLMaterialMgr::processGetAllQueueCoro", boost::bind(&LLMaterialMgr::processGetAllQueueCoro, this, region_id)); -#else - LLViewerRegion* regionp = LLWorld::instance().getRegionFromID(region_id); - if (regionp == NULL) - { - LL_WARNS("Materials") << "Unknown region with id " << region_id.asString() << LL_ENDL; - clearGetQueues(region_id); // Invalidates region_id - continue; - } - else if (!regionp->capabilitiesReceived() || regionp->materialsCapThrottled()) - { - continue; - } - std::string capURL = regionp->getCapability(MATERIALS_CAPABILITY_NAME); - if (capURL.empty()) - { - LL_WARNS("Materials") << "Capability '" << MATERIALS_CAPABILITY_NAME - << "' is not defined on the current region '" << regionp->getName() << "'" << LL_ENDL; - clearGetQueues(region_id); // Invalidates region_id - continue; - } - - LL_DEBUGS("Materials") << "GET all for region " << region_id << "url " << capURL << LL_ENDL; - LLMaterialHttpHandler *handler = - new LLMaterialHttpHandler("GET", - boost::bind(&LLMaterialMgr::onGetAllResponse, this, _1, _2, *itRegion) - ); - - LLCore::HttpHandle handle = mHttpRequest->requestGet(mHttpPolicy, mHttpPriority, capURL, - mHttpOptions, mHttpHeaders, handler); - - if (handle == LLCORE_HTTP_HANDLE_INVALID) - { - delete handler; - LLCore::HttpStatus status = mHttpRequest->getStatus(); - LL_ERRS("Meterials") << "Failed to execute material GET. Status = " << - status.toULong() << "\"" << status.toString() << "\"" << LL_ENDL; - } - - regionp->resetMaterialsCapThrottle(); -#endif mGetAllPending.insert(std::pair(region_id, LLFrameTimer::getTotalSeconds())); mGetAllQueue.erase(itRegion); // Invalidates region_id } -- cgit v1.3 From 7c5643025804d94ce3efa92abf77e4965295072d Mon Sep 17 00:00:00 2001 From: rider Date: Fri, 16 Oct 2015 12:15:33 -0700 Subject: MAINT-5271: Microsoft is just too permissive. --- indra/llcorehttp/_httpoperation.h | 2 +- indra/llcorehttp/httprequest.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/llcorehttp/httprequest.cpp') diff --git a/indra/llcorehttp/_httpoperation.h b/indra/llcorehttp/_httpoperation.h index 417bdc7c50..1a75921c09 100755 --- a/indra/llcorehttp/_httpoperation.h +++ b/indra/llcorehttp/_httpoperation.h @@ -162,7 +162,7 @@ public: ptr_t ptr = findByHandle(handle); if (!ptr) return boost::shared_ptr< OPT >(); - return boost::dynamic_pointer_cast(ptr); + return boost::dynamic_pointer_cast< OPT >(ptr); } protected: diff --git a/indra/llcorehttp/httprequest.cpp b/indra/llcorehttp/httprequest.cpp index 1c7994927b..e09f0c3b18 100755 --- a/indra/llcorehttp/httprequest.cpp +++ b/indra/llcorehttp/httprequest.cpp @@ -443,13 +443,13 @@ HttpStatus HttpRequest::update(long usecs) ++iter) { // Swap op pointer for NULL; - op = *iter; *iter = NULL; + op.reset(); + op.swap(*iter); // Process operation op->visitNotifier(this); // We're done with the operation - op.reset(); } } } -- cgit v1.3