diff options
Diffstat (limited to 'indra/llmessage/message.cpp')
-rwxr-xr-x | indra/llmessage/message.cpp | 128 |
1 files changed, 53 insertions, 75 deletions
diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp index e9ce94ab3b..2f4b47286d 100755 --- a/indra/llmessage/message.cpp +++ b/indra/llmessage/message.cpp @@ -50,9 +50,7 @@ #include "lldir.h" #include "llerror.h" #include "llfasttimer.h" -#include "llhttpclient.h" #include "llhttpnodeadapter.h" -#include "llhttpsender.h" #include "llmd5.h" #include "llmessagebuilder.h" #include "llmessageconfig.h" @@ -77,6 +75,7 @@ #include "v3math.h" #include "v4math.h" #include "lltransfertargetvfile.h" +#include "llcorehttputil.h" // Constants //const char* MESSAGE_LOG_FILENAME = "message.log"; @@ -97,45 +96,6 @@ public: apr_pollfd_t mPollFD; }; -namespace -{ - class LLFnPtrResponder : public LLHTTPClient::Responder - { - LOG_CLASS(LLFnPtrResponder); - public: - LLFnPtrResponder(void (*callback)(void **,S32), void **callbackData, const std::string& name) : - mCallback(callback), - mCallbackData(callbackData), - mMessageName(name) - { - } - - protected: - virtual void httpFailure() - { - // don't spam when agent communication disconnected already - if (HTTP_GONE != getStatus()) - { - LL_WARNS("Messaging") << "error for message " << mMessageName - << " " << dumpResponse() << LL_ENDL; - } - // TODO: Map status in to useful error code. - if(NULL != mCallback) mCallback(mCallbackData, LL_ERR_TCP_TIMEOUT); - } - - virtual void httpSuccess() - { - if(NULL != mCallback) mCallback(mCallbackData, LL_ERR_NOERR); - } - - private: - - void (*mCallback)(void **,S32); - void **mCallbackData; - std::string mMessageName; - }; -} - class LLMessageHandlerBridge : public LLHTTPNode { virtual bool validate(const std::string& name, LLSD& context) const @@ -1129,29 +1089,6 @@ S32 LLMessageSystem::flushReliable(const LLHost &host) return send_bytes; } -LLHTTPClient::ResponderPtr LLMessageSystem::createResponder(const std::string& name) -{ - if(mSendReliable) - { - return new LLFnPtrResponder( - mReliablePacketParams.mCallback, - mReliablePacketParams.mCallbackData, - name); - } - else - { - // These messages aren't really unreliable, they just weren't - // explicitly sent as reliable, so they don't have a callback -// LL_WARNS("Messaging") << "LLMessageSystem::sendMessage: Sending unreliable " -// << mMessageBuilder->getMessageName() << " message via HTTP" -// << LL_ENDL; - return new LLFnPtrResponder( - NULL, - NULL, - name); - } -} - // This can be called from signal handlers, // so should should not use LL_INFOS(). S32 LLMessageSystem::sendMessage(const LLHost &host) @@ -1216,13 +1153,17 @@ S32 LLMessageSystem::sendMessage(const LLHost &host) if(mMessageBuilder == mLLSDMessageBuilder) { LLSD message = mLLSDMessageBuilder->getMessage(); - - const LLHTTPSender& sender = LLHTTPSender::getSender(host); - sender.send( - host, - mLLSDMessageBuilder->getMessageName(), - message, - createResponder(mLLSDMessageBuilder->getMessageName())); + + UntrustedCallback_t cb = NULL; + if ((mSendReliable) && (mReliablePacketParams.mCallback)) + { + cb = boost::bind(mReliablePacketParams.mCallback, mReliablePacketParams.mCallbackData, _1); + } + + LLCoros::instance().launch("LLMessageSystem::sendUntrustedSimulatorMessageCoro", + boost::bind(&LLMessageSystem::sendUntrustedSimulatorMessageCoro, this, + host.getUntrustedSimulatorCap(), + mLLSDMessageBuilder->getMessageName(), message, cb)); mSendReliable = FALSE; mReliablePacketParams.clear(); @@ -1410,9 +1351,16 @@ S32 LLMessageSystem::sendMessage( return 0; } - const LLHTTPSender& sender = LLHTTPSender::getSender(host); - sender.send(host, name, message, createResponder(name)); - return 1; + UntrustedCallback_t cb = NULL; + if ((mSendReliable) && (mReliablePacketParams.mCallback)) + { + cb = boost::bind(mReliablePacketParams.mCallback, mReliablePacketParams.mCallbackData, _1); + } + + LLCoros::instance().launch("LLMessageSystem::sendUntrustedSimulatorMessageCoro", + boost::bind(&LLMessageSystem::sendUntrustedSimulatorMessageCoro, this, + host.getUntrustedSimulatorCap(), name, message, cb)); + return 1; } void LLMessageSystem::logTrustedMsgFromUntrustedCircuit( const LLHost& host ) @@ -1725,7 +1673,7 @@ LLHost LLMessageSystem::findHost(const U32 circuit_code) } else { - return LLHost::invalid; + return LLHost(); } } @@ -4055,6 +4003,36 @@ const LLHost& LLMessageSystem::getSender() const return mLastSender; } +void LLMessageSystem::sendUntrustedSimulatorMessageCoro(std::string url, std::string message, LLSD body, UntrustedCallback_t callback) +{ + LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t + httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("groupMembersRequest", httpPolicy)); + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); + LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions); + + + if (url.empty()) + { + LL_WARNS() << "sendUntrustedSimulatorMessageCoro called with empty capability!" << LL_ENDL; + return; + } + + LL_INFOS() << "sendUntrustedSimulatorMessageCoro: message " << message << " to cap " << url << LL_ENDL; + LLSD postData; + postData["message"] = message; + postData["body"] = body; + + LLSD result = httpAdapter->postAndSuspend(httpRequest, url, postData, httpOpts); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if ((callback) && (!callback.empty())) + callback((status) ? LL_ERR_NOERR : LL_ERR_TCP_TIMEOUT); +} + + LLHTTPRegistration<LLHTTPNodeAdapter<LLTrustedMessageService> > gHTTPRegistrationTrustedMessageWildcard("/trusted-message/<message-name>"); |