From 1658d77b865a9e139381a60c7a912ee3b949e69b Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Mon, 5 Oct 2009 17:56:33 -0700 Subject: DEV-40853: don't bring up a dialog on HTTP errors in the media service --- indra/newview/llmediadataclient.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'indra/newview/llmediadataclient.cpp') diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp index 6a932d76bf..54521ccb84 100644 --- a/indra/newview/llmediadataclient.cpp +++ b/indra/newview/llmediadataclient.cpp @@ -37,7 +37,6 @@ #include #include "llhttpstatuscodes.h" -#include "llnotifications.h" #include "llsdutil.h" #include "llmediaentry.h" #include "lltextureentry.h" @@ -216,10 +215,7 @@ void LLMediaDataClient::Responder::error(U32 status, const std::string& reason) } else { std::string msg = boost::lexical_cast(status) + ": " + reason; - LL_INFOS("LLMediaDataClient") << *mRequest << " error(" << msg << ")" << LL_ENDL; - LLSD args; - args["ERROR"] = msg; - LLNotifications::instance().add("ObjectMediaFailure", args); + LL_WARNS("LLMediaDataClient") << *mRequest << " http error(" << msg << ")" << LL_ENDL; } } -- cgit v1.2.3 From aba67da38b8b983f043b536b9743f80abfb6e33a Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Mon, 5 Oct 2009 18:14:27 -0700 Subject: FIX DEV-40877: ignore changes from "bad" objects which have an invalid media URL --- indra/newview/llmediadataclient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llmediadataclient.cpp') diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp index 54521ccb84..c356f55315 100644 --- a/indra/newview/llmediadataclient.cpp +++ b/indra/newview/llmediadataclient.cpp @@ -618,6 +618,6 @@ void LLObjectMediaNavigateClient::Responder::bounceBack() if (mep && impl) { -// impl->navigateTo(mep->getCurrentURL()); + impl->navigateTo(mep->getCurrentURL(), "", false, true); } } -- cgit v1.2.3 From f0dd8c460362c78e4d17be16c153ad618d4dd60e Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Mon, 5 Oct 2009 18:15:43 -0700 Subject: Back out changes accidentally checked in with last commit --- indra/newview/llmediadataclient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llmediadataclient.cpp') diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp index c356f55315..7ef26fd0e2 100644 --- a/indra/newview/llmediadataclient.cpp +++ b/indra/newview/llmediadataclient.cpp @@ -618,6 +618,6 @@ void LLObjectMediaNavigateClient::Responder::bounceBack() if (mep && impl) { - impl->navigateTo(mep->getCurrentURL(), "", false, true); +// impl->navigateTo(mep->getCurrentURL(), "", false, true); } } -- cgit v1.2.3 From d2464757c6fa86caa30a13071cb43047de2dd2ff Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Tue, 6 Oct 2009 13:20:30 -0700 Subject: DEV-40896: Don't iteratively pop() the request queue on destroy(). This just logs now and deletes the queue. --- indra/newview/llmediadataclient.cpp | 215 ++++++++++++++++++------------------ 1 file changed, 107 insertions(+), 108 deletions(-) (limited to 'indra/newview/llmediadataclient.cpp') diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp index 7ef26fd0e2..da5e68af71 100644 --- a/indra/newview/llmediadataclient.cpp +++ b/indra/newview/llmediadataclient.cpp @@ -79,7 +79,7 @@ LLMediaDataClient::Request::Request(const std::string &cap_name, LLMediaDataClient::Request::~Request() { mMDC = NULL; - mObject = NULL; + mObject = NULL; } @@ -92,24 +92,24 @@ std::string LLMediaDataClient::Request::getCapability() const // discover it. LLMediaDataClient::Request::Type LLMediaDataClient::Request::getType() const { - if (mCapName == "ObjectMediaNavigate") - { - return NAVIGATE; - } - else if (mCapName == "ObjectMedia") - { - const std::string &verb = mPayload["verb"]; - if (verb == "GET") - { - return GET; - } - else if (verb == "UPDATE") - { - return UPDATE; - } - } - llassert(false); - return GET; + if (mCapName == "ObjectMediaNavigate") + { + return NAVIGATE; + } + else if (mCapName == "ObjectMedia") + { + const std::string &verb = mPayload["verb"]; + if (verb == "GET") + { + return GET; + } + else if (verb == "UPDATE") + { + return UPDATE; + } + } + llassert(false); + return GET; } const char *LLMediaDataClient::Request::getTypeAsString() const @@ -190,7 +190,7 @@ LLMediaDataClient::Responder::Responder(const request_ptr_t &request) LLMediaDataClient::Responder::~Responder() { - mRequest = NULL; + mRequest = NULL; } /*virtual*/ @@ -418,8 +418,8 @@ void LLMediaDataClient::request(LLVOVolume *object, const LLSD &payload) void LLMediaDataClient::enqueue(const Request *request) { LL_INFOS("LLMediaDataClient") << "Queuing request for " << *request << LL_ENDL; - // Push the request on the priority queue - // Sadly, we have to const-cast because items put into the queue are not const + // Push the request on the priority queue + // Sadly, we have to const-cast because items put into the queue are not const pRequestQueue->push(const_cast(request)); LL_DEBUGS("LLMediaDataClient") << "Queue:" << (*pRequestQueue) << LL_ENDL; // Start the timer if not already running @@ -437,16 +437,15 @@ LLMediaDataClient::LLMediaDataClient() pRequestQueue = new PriorityQueue(); } - LLMediaDataClient::~LLMediaDataClient() { stopQueueTimer(); - + // This should clear the queue, and hopefully call all the destructors. - while (! pRequestQueue->empty()) pRequestQueue->pop(); - + LL_DEBUGS("LLMediaDataClient") << "destructor: queue: " << + (pRequestQueue->empty() ? " " : " ") << (*pRequestQueue) << LL_ENDL; delete pRequestQueue; - pRequestQueue = NULL; + pRequestQueue = NULL; } ////////////////////////////////////////////////////////////////////////////////////// @@ -458,79 +457,79 @@ LLMediaDataClient::~LLMediaDataClient() LLMediaDataClient::Responder *LLObjectMediaDataClient::createResponder(const request_ptr_t &request) const { - return new LLObjectMediaDataClient::Responder(request); + return new LLObjectMediaDataClient::Responder(request); } const char *LLObjectMediaDataClient::getCapabilityName() const { - return "ObjectMedia"; + return "ObjectMedia"; } void LLObjectMediaDataClient::fetchMedia(LLVOVolume *object) { - LLSD sd_payload; - sd_payload["verb"] = "GET"; - sd_payload[LLTextureEntry::OBJECT_ID_KEY] = object->getID(); - request(object, sd_payload); + LLSD sd_payload; + sd_payload["verb"] = "GET"; + sd_payload[LLTextureEntry::OBJECT_ID_KEY] = object->getID(); + request(object, sd_payload); } void LLObjectMediaDataClient::updateMedia(LLVOVolume *object) { - LLSD sd_payload; - sd_payload["verb"] = "UPDATE"; - sd_payload[LLTextureEntry::OBJECT_ID_KEY] = object->getID(); - LLSD object_media_data; - for (int i=0; i < object->getNumTEs(); i++) { - LLTextureEntry *texture_entry = object->getTE(i); - llassert((texture_entry->getMediaData() != NULL) == texture_entry->hasMedia()); - const LLSD &media_data = - (texture_entry->getMediaData() == NULL) ? LLSD() : texture_entry->getMediaData()->asLLSD(); - object_media_data.append(media_data); - } - sd_payload[LLTextureEntry::OBJECT_MEDIA_DATA_KEY] = object_media_data; - + LLSD sd_payload; + sd_payload["verb"] = "UPDATE"; + sd_payload[LLTextureEntry::OBJECT_ID_KEY] = object->getID(); + LLSD object_media_data; + for (int i=0; i < object->getNumTEs(); i++) { + LLTextureEntry *texture_entry = object->getTE(i); + llassert((texture_entry->getMediaData() != NULL) == texture_entry->hasMedia()); + const LLSD &media_data = + (texture_entry->getMediaData() == NULL) ? LLSD() : texture_entry->getMediaData()->asLLSD(); + object_media_data.append(media_data); + } + sd_payload[LLTextureEntry::OBJECT_MEDIA_DATA_KEY] = object_media_data; + LL_INFOS("LLMediaDataClient") << "update media data: " << object->getID() << " " << ll_pretty_print_sd(sd_payload) << LL_ENDL; - - request(object, sd_payload); + + request(object, sd_payload); } /*virtual*/ void LLObjectMediaDataClient::Responder::result(const LLSD& content) { - const LLMediaDataClient::Request::Type type = getRequest()->getType(); - llassert(type == LLMediaDataClient::Request::GET || type == LLMediaDataClient::Request::UPDATE) - if (type == LLMediaDataClient::Request::GET) - { - LL_INFOS("LLMediaDataClient") << *(getRequest()) << "GET returned: " << ll_pretty_print_sd(content) << LL_ENDL; - - // Look for an error - if (content.has("error")) - { - const LLSD &error = content["error"]; - LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error getting media data for object: code=" << + const LLMediaDataClient::Request::Type type = getRequest()->getType(); + llassert(type == LLMediaDataClient::Request::GET || type == LLMediaDataClient::Request::UPDATE) + if (type == LLMediaDataClient::Request::GET) + { + LL_INFOS("LLMediaDataClient") << *(getRequest()) << "GET returned: " << ll_pretty_print_sd(content) << LL_ENDL; + + // Look for an error + if (content.has("error")) + { + const LLSD &error = content["error"]; + LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error getting media data for object: code=" << error["code"].asString() << ": " << error["message"].asString() << LL_ENDL; - - // XXX Warn user? - } - else { - // Check the data - const LLUUID &object_id = content[LLTextureEntry::OBJECT_ID_KEY]; - if (object_id != getRequest()->getObject()->getID()) - { - // NOT good, wrong object id!! - LL_WARNS("LLMediaDataClient") << *(getRequest()) << "DROPPING response with wrong object id (" << object_id << ")" << LL_ENDL; - return; - } - - // Otherwise, update with object media data - getRequest()->getObject()->updateObjectMediaData(content[LLTextureEntry::OBJECT_MEDIA_DATA_KEY]); - } - } - else if (type == LLMediaDataClient::Request::UPDATE) - { - // just do what our superclass does - LLMediaDataClient::Responder::result(content); - } + + // XXX Warn user? + } + else { + // Check the data + const LLUUID &object_id = content[LLTextureEntry::OBJECT_ID_KEY]; + if (object_id != getRequest()->getObject()->getID()) + { + // NOT good, wrong object id!! + LL_WARNS("LLMediaDataClient") << *(getRequest()) << "DROPPING response with wrong object id (" << object_id << ")" << LL_ENDL; + return; + } + + // Otherwise, update with object media data + getRequest()->getObject()->updateObjectMediaData(content[LLTextureEntry::OBJECT_MEDIA_DATA_KEY]); + } + } + else if (type == LLMediaDataClient::Request::UPDATE) + { + // just do what our superclass does + LLMediaDataClient::Responder::result(content); + } } ////////////////////////////////////////////////////////////////////////////////////// @@ -541,21 +540,21 @@ void LLObjectMediaDataClient::Responder::result(const LLSD& content) ////////////////////////////////////////////////////////////////////////////////////// LLMediaDataClient::Responder *LLObjectMediaNavigateClient::createResponder(const request_ptr_t &request) const { - return new LLObjectMediaNavigateClient::Responder(request); + return new LLObjectMediaNavigateClient::Responder(request); } const char *LLObjectMediaNavigateClient::getCapabilityName() const { - return "ObjectMediaNavigate"; + return "ObjectMediaNavigate"; } void LLObjectMediaNavigateClient::navigate(LLVOVolume *object, U8 texture_index, const std::string &url) { - LLSD sd_payload; - sd_payload[LLTextureEntry::OBJECT_ID_KEY] = object->getID(); + LLSD sd_payload; + sd_payload[LLTextureEntry::OBJECT_ID_KEY] = object->getID(); sd_payload[LLMediaEntry::CURRENT_URL_KEY] = url; sd_payload[LLTextureEntry::TEXTURE_INDEX_KEY] = (LLSD::Integer)texture_index; - request(object, sd_payload); + request(object, sd_payload); } /*virtual*/ @@ -577,8 +576,8 @@ void LLObjectMediaNavigateClient::Responder::error(U32 status, const std::string /*virtual*/ void LLObjectMediaNavigateClient::Responder::result(const LLSD& content) { - LL_DEBUGS("LLMediaDataClient") << *(getRequest()) << " NAVIGATE returned " << ll_pretty_print_sd(content) << LL_ENDL; - + LL_DEBUGS("LLMediaDataClient") << *(getRequest()) << " NAVIGATE returned " << ll_pretty_print_sd(content) << LL_ENDL; + if (content.has("error")) { const LLSD &error = content["error"]; @@ -586,20 +585,20 @@ void LLObjectMediaNavigateClient::Responder::result(const LLSD& content) if (ERROR_PERMISSION_DENIED_CODE == error_code) { - LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Navigation denied: bounce back" << LL_ENDL; + LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Navigation denied: bounce back" << LL_ENDL; // bounce the face back bounceBack(); } else { - LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error navigating: code=" << + LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error navigating: code=" << error["code"].asString() << ": " << error["message"].asString() << LL_ENDL; - } + } // XXX Warn user? } - else { - // just do what our superclass does - LLMediaDataClient::Responder::result(content); - } + else { + // just do what our superclass does + LLMediaDataClient::Responder::result(content); + } } @@ -607,17 +606,17 @@ void LLObjectMediaNavigateClient::Responder::bounceBack() { const LLSD &payload = getRequest()->getPayload(); U8 texture_index = (U8)(LLSD::Integer)payload[LLTextureEntry::TEXTURE_INDEX_KEY]; - viewer_media_t impl = getRequest()->getObject()->getMediaImpl(texture_index); - // Find the media entry for this navigate - LLMediaEntry* mep = NULL; - LLTextureEntry *te = getRequest()->getObject()->getTE(texture_index); - if(te) - { - mep = te->getMediaData(); - } - - if (mep && impl) - { -// impl->navigateTo(mep->getCurrentURL(), "", false, true); - } + viewer_media_t impl = getRequest()->getObject()->getMediaImpl(texture_index); + // Find the media entry for this navigate + LLMediaEntry* mep = NULL; + LLTextureEntry *te = getRequest()->getObject()->getTE(texture_index); + if(te) + { + mep = te->getMediaData(); + } + + if (mep && impl) + { +// impl->navigateTo(mep->getCurrentURL(), "", false, true); + } } -- cgit v1.2.3 From df48e66f7cc6711f1738e3a2817cf3b9a810c088 Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Wed, 7 Oct 2009 12:26:42 -0700 Subject: DEV-39168 - bounce back to the current URL (or, the home URL if current URL is "") if the server denies navigation This refactors some of the bounceBack code into LLVOVolume. It also changes an important rule: the edit panel now *will* send the current URL to the server when you hit "OK". This change was done so that if autoplay is on, we make sure the server gets the right data. --- indra/newview/llmediadataclient.cpp | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) (limited to 'indra/newview/llmediadataclient.cpp') diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp index da5e68af71..4dde381e97 100644 --- a/indra/newview/llmediadataclient.cpp +++ b/indra/newview/llmediadataclient.cpp @@ -568,8 +568,10 @@ void LLObjectMediaNavigateClient::Responder::error(U32 status, const std::string } else { // bounce the face back - bounceBack(); LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error navigating: http code=" << status << LL_ENDL; + const LLSD &payload = getRequest()->getPayload(); + // bounce the face back + getRequest()->getObject()->mediaNavigateBounceBack((LLSD::Integer)payload[LLTextureEntry::TEXTURE_INDEX_KEY]); } } @@ -586,8 +588,9 @@ void LLObjectMediaNavigateClient::Responder::result(const LLSD& content) if (ERROR_PERMISSION_DENIED_CODE == error_code) { LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Navigation denied: bounce back" << LL_ENDL; + const LLSD &payload = getRequest()->getPayload(); // bounce the face back - bounceBack(); + getRequest()->getObject()->mediaNavigateBounceBack((LLSD::Integer)payload[LLTextureEntry::TEXTURE_INDEX_KEY]); } else { LL_WARNS("LLMediaDataClient") << *(getRequest()) << " Error navigating: code=" << @@ -600,23 +603,3 @@ void LLObjectMediaNavigateClient::Responder::result(const LLSD& content) LLMediaDataClient::Responder::result(content); } } - - -void LLObjectMediaNavigateClient::Responder::bounceBack() -{ - const LLSD &payload = getRequest()->getPayload(); - U8 texture_index = (U8)(LLSD::Integer)payload[LLTextureEntry::TEXTURE_INDEX_KEY]; - viewer_media_t impl = getRequest()->getObject()->getMediaImpl(texture_index); - // Find the media entry for this navigate - LLMediaEntry* mep = NULL; - LLTextureEntry *te = getRequest()->getObject()->getTE(texture_index); - if(te) - { - mep = te->getMediaData(); - } - - if (mep && impl) - { -// impl->navigateTo(mep->getCurrentURL(), "", false, true); - } -} -- cgit v1.2.3 From 902d6676c653ce2ca34b3645576e59bcc93dc2cd Mon Sep 17 00:00:00 2001 From: brad kittenbrink Date: Wed, 7 Oct 2009 19:26:04 -0700 Subject: Post-merge cleanup to get things building again. --- indra/newview/llmediadataclient.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'indra/newview/llmediadataclient.cpp') diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp index da5e68af71..2f2be0561d 100644 --- a/indra/newview/llmediadataclient.cpp +++ b/indra/newview/llmediadataclient.cpp @@ -34,6 +34,11 @@ #include "llmediadataclient.h" +#if LL_MSVC +// disable boost::lexical_cast warning +#pragma warning (disable:4702) +#endif + #include #include "llhttpstatuscodes.h" -- cgit v1.2.3 From d4b2897700c66354413af42ab055bd1aaa47f91c Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Fri, 9 Oct 2009 18:56:36 -0700 Subject: Unit tests for LLMediaDataClient This required a bit of refactoring of LLMediaDataClient: - Created LLMediaDataClientObject ABC, which now has a concrete impl in LLVOVolume - Created unit test with 6 tests (for now), testing - LLObjectMediaDataClient::fetchMedia() - LLObjectMediaDataClient::updateMedia() - LLObjectMediaNavigateClient::navigate() - queue ordering - retries - nav bounce back - Also ensures that ref counting works properly (this is important, because ownership is tricky with smart pointers put into queues, peeled off into timers that fire and auto destruct, and HTTP responders that also auto-destruct) - Had to fix LLCurl::Responder's stub, which was not initializing the ref count to 0, causing the ref counting tests to fail (boy, that was hard to find!). Reviewed by Callum --- indra/newview/llmediadataclient.cpp | 135 ++++++++++++++++++++---------------- 1 file changed, 77 insertions(+), 58 deletions(-) (limited to 'indra/newview/llmediadataclient.cpp') diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp index 4dde381e97..e69c85f245 100644 --- a/indra/newview/llmediadataclient.cpp +++ b/indra/newview/llmediadataclient.cpp @@ -41,7 +41,6 @@ #include "llmediaentry.h" #include "lltextureentry.h" #include "llviewerregion.h" -#include "llvovolume.h" // // When making a request @@ -54,7 +53,9 @@ // - Any request that gets a 503 still goes through the retry logic // -// Some helpful logging macros +const F32 LLMediaDataClient::QUEUE_TIMER_DELAY = 1.0; // seconds(s) +const F32 LLMediaDataClient::UNAVAILABLE_RETRY_TIMER_DELAY = 5.0; // secs +const U32 LLMediaDataClient::MAX_RETRIES = 4; ////////////////////////////////////////////////////////////////////////////////////// // @@ -65,7 +66,7 @@ LLMediaDataClient::Request::Request(const std::string &cap_name, const LLSD& sd_payload, - LLVOVolume *obj, + LLMediaDataClientObject *obj, LLMediaDataClient *mdc) : mCapName(cap_name), mPayload(sd_payload), @@ -78,6 +79,7 @@ LLMediaDataClient::Request::Request(const std::string &cap_name, LLMediaDataClient::Request::~Request() { + LL_DEBUGS("LLMediaDataClient") << "~Request" << (*this) << LL_ENDL; mMDC = NULL; mObject = NULL; } @@ -85,7 +87,7 @@ LLMediaDataClient::Request::~Request() std::string LLMediaDataClient::Request::getCapability() const { - return getObject()->getRegion()->getCapability(getCapName()); + return getObject()->getCapabilityUrl(getCapName()); } // Helper function to get the "type" of request, which just pokes around to @@ -137,6 +139,17 @@ void LLMediaDataClient::Request::reEnqueue() const mMDC->enqueue(this); } +F32 LLMediaDataClient::Request::getRetryTimerDelay() const +{ + return (mMDC == NULL) ? LLMediaDataClient::UNAVAILABLE_RETRY_TIMER_DELAY : + mMDC->mRetryTimerDelay; +} + +U32 LLMediaDataClient::Request::getMaxNumRetries() const +{ + return (mMDC == NULL) ? LLMediaDataClient::MAX_RETRIES : mMDC->mMaxNumRetries; +} + std::ostream& operator<<(std::ostream &s, const LLMediaDataClient::Request &r) { s << "" @@ -163,6 +176,7 @@ LLMediaDataClient::Responder::RetryTimer::RetryTimer(F32 time, Responder *mdr) // virtual LLMediaDataClient::Responder::RetryTimer::~RetryTimer() { + LL_DEBUGS("LLMediaDataClient") << "~RetryTimer" << *(mResponder->getRequest()) << LL_ENDL; mResponder = NULL; } @@ -190,28 +204,31 @@ LLMediaDataClient::Responder::Responder(const request_ptr_t &request) LLMediaDataClient::Responder::~Responder() { + LL_DEBUGS("LLMediaDataClient") << "~Responder" << *(getRequest()) << LL_ENDL; mRequest = NULL; } /*virtual*/ void LLMediaDataClient::Responder::error(U32 status, const std::string& reason) { - extern LLControlGroup gSavedSettings; - if (status == HTTP_SERVICE_UNAVAILABLE) { - F32 retry_timeout = gSavedSettings.getF32("PrimMediaRetryTimerDelay"); - if (retry_timeout <= 0.0) - { - retry_timeout = (F32)UNAVAILABLE_RETRY_TIMER_DELAY; - } - LL_INFOS("LLMediaDataClient") << *mRequest << "got SERVICE_UNAVAILABLE...retrying in " << retry_timeout << " seconds" << LL_ENDL; + F32 retry_timeout = mRequest->getRetryTimerDelay(); mRequest->incRetryCount(); - // Start timer (instances are automagically tracked by - // InstanceTracker<> and LLEventTimer) - new RetryTimer(F32(retry_timeout/*secs*/), this); + if (mRequest->getRetryCount() < mRequest->getMaxNumRetries()) + { + LL_INFOS("LLMediaDataClient") << *mRequest << "got SERVICE_UNAVAILABLE...retrying in " << retry_timeout << " seconds" << LL_ENDL; + + // Start timer (instances are automagically tracked by + // InstanceTracker<> and LLEventTimer) + new RetryTimer(F32(retry_timeout/*secs*/), this); + } + else { + LL_INFOS("LLMediaDataClient") << *mRequest << "got SERVICE_UNAVAILABLE...retry count " << + mRequest->getRetryCount() << " exceeds " << mRequest->getMaxNumRetries() << ", not retrying" << LL_ENDL; + } } else { std::string msg = boost::lexical_cast(status) + ": " + reason; @@ -252,29 +269,25 @@ bool LLMediaDataClient::Comparator::operator() (const request_ptr_t &o1, const r // Calculate the scores for each. F64 o1_score = Comparator::getObjectScore(o1->getObject()); F64 o2_score = Comparator::getObjectScore(o2->getObject()); - - return ( o1_score > o2_score ); + + // XXX Weird: a higher score should go earlier, but by observation I notice + // that this causes further-away objects load first. This is counterintuitive + // to the priority_queue Comparator, which states that this function should + // return 'true' if o1 should be *before* o2. + // In other words, I'd have expected that the following should return + // ( o1_score > o2_score). + return ( o1_score < o2_score ); } // static -F64 LLMediaDataClient::Comparator::getObjectScore(const ll_vo_volume_ptr_t &obj) +F64 LLMediaDataClient::Comparator::getObjectScore(const LLMediaDataClientObject::ptr_t &obj) { // *TODO: make this less expensive? - F32 dist = obj->getRenderPosition().length() + 0.1; // avoids div by 0 + F64 dist = obj->getDistanceFromAvatar() + 0.1; // avoids div by 0 // square the distance so that they are in the same "unit magnitude" as // the interest (which is an area) dist *= dist; - F64 interest = (F64)1; - int i = 0; - int end = obj->getNumTEs(); - for ( ; i < end; ++i) - { - const viewer_media_t &impl = obj->getMediaImpl(i); - if (!impl.isNull()) - { - interest += impl->getInterest(); - } - } + F64 interest = obj->getTotalMediaInterest() + 1.0; return interest/dist; } @@ -282,7 +295,7 @@ F64 LLMediaDataClient::Comparator::getObjectScore(const ll_vo_volume_ptr_t &obj) ////////////////////////////////////////////////////////////////////////////////////// // // LLMediaDataClient::PriorityQueue -// Queue of LLVOVolume smart pointers to request media for. +// Queue of LLMediaDataClientObject smart pointers to request media for. // ////////////////////////////////////////////////////////////////////////////////////// @@ -304,7 +317,7 @@ std::ostream& operator<<(std::ostream &s, const LLMediaDataClient::PriorityQueue ////////////////////////////////////////////////////////////////////////////////////// // // LLMediaDataClient::QueueTimer -// Queue of LLVOVolume smart pointers to request media for. +// Queue of LLMediaDataClientObject smart pointers to request media for. // ////////////////////////////////////////////////////////////////////////////////////// @@ -316,6 +329,7 @@ LLMediaDataClient::QueueTimer::QueueTimer(F32 time, LLMediaDataClient *mdc) LLMediaDataClient::QueueTimer::~QueueTimer() { + LL_DEBUGS("LLMediaDataClient") << "~QueueTimer" << LL_ENDL; mMDC->setIsRunning(false); mMDC = NULL; } @@ -343,10 +357,10 @@ BOOL LLMediaDataClient::QueueTimer::tick() // Peel one off of the items from the queue, and execute request request_ptr_t request = queue.top(); llassert(!request.isNull()); - const ll_vo_volume_ptr_t &object = request->getObject(); + const LLMediaDataClientObject *object = request->getObject(); bool performed_request = false; - llassert(!object.isNull()); - if (!object.isNull() && object->hasMedia()) + llassert(NULL != object); + if (NULL != object && object->hasMedia()) { std::string url = request->getCapability(); if (!url.empty()) @@ -368,12 +382,13 @@ BOOL LLMediaDataClient::QueueTimer::tick() LL_INFOS("LLMediaDataClient") << "Not Sending request for " << *request << " hasMedia() is false!" << LL_ENDL; } } - bool exceeded_retries = request->getRetryCount() > LLMediaDataClient::MAX_RETRIES; + bool exceeded_retries = request->getRetryCount() > mMDC->mMaxNumRetries; if (performed_request || exceeded_retries) // Try N times before giving up { if (exceeded_retries) { - LL_WARNS("LLMediaDataClient") << "Could not send request " << *request << " for " << LLMediaDataClient::MAX_RETRIES << " tries...popping object id " << object->getID() << LL_ENDL; + LL_WARNS("LLMediaDataClient") << "Could not send request " << *request << " for " + << mMDC->mMaxNumRetries << " tries...popping object id " << object->getID() << LL_ENDL; // XXX Should we bring up a warning dialog?? } queue.pop(); @@ -390,15 +405,9 @@ void LLMediaDataClient::startQueueTimer() { if (! mQueueTimerIsRunning) { - extern LLControlGroup gSavedSettings; - F32 queue_timer_delay = gSavedSettings.getF32("PrimMediaRequestQueueDelay"); - if (queue_timer_delay <= 0.0f) - { - queue_timer_delay = (F32)LLMediaDataClient::QUEUE_TIMER_DELAY; - } - LL_INFOS("LLMediaDataClient") << "starting queue timer (delay=" << queue_timer_delay << " seconds)" << LL_ENDL; + LL_INFOS("LLMediaDataClient") << "starting queue timer (delay=" << mQueueTimerDelay << " seconds)" << LL_ENDL; // LLEventTimer automagically takes care of the lifetime of this object - new QueueTimer(queue_timer_delay, this); + new QueueTimer(mQueueTimerDelay, this); } } @@ -407,9 +416,9 @@ void LLMediaDataClient::stopQueueTimer() mQueueTimerIsRunning = false; } -void LLMediaDataClient::request(LLVOVolume *object, const LLSD &payload) +void LLMediaDataClient::request(const LLMediaDataClientObject::ptr_t &object, const LLSD &payload) { - if (NULL == object || ! object->hasMedia()) return; + if (object.isNull() || ! object->hasMedia()) return; // Push the object on the priority queue enqueue(new Request(getCapabilityName(), payload, object, this)); @@ -432,7 +441,13 @@ void LLMediaDataClient::enqueue(const Request *request) // ////////////////////////////////////////////////////////////////////////////////////// -LLMediaDataClient::LLMediaDataClient() +LLMediaDataClient::LLMediaDataClient(F32 queue_timer_delay, + F32 retry_timer_delay, + U32 max_retries) + : mQueueTimerDelay(queue_timer_delay), + mRetryTimerDelay(retry_timer_delay), + mMaxNumRetries(max_retries), + mQueueTimerIsRunning(false) { pRequestQueue = new PriorityQueue(); } @@ -442,12 +457,17 @@ LLMediaDataClient::~LLMediaDataClient() stopQueueTimer(); // This should clear the queue, and hopefully call all the destructors. - LL_DEBUGS("LLMediaDataClient") << "destructor: queue: " << + LL_DEBUGS("LLMediaDataClient") << "~LLMediaDataClient destructor: queue: " << (pRequestQueue->empty() ? " " : " ") << (*pRequestQueue) << LL_ENDL; delete pRequestQueue; pRequestQueue = NULL; } +bool LLMediaDataClient::isEmpty() const +{ + return (NULL == pRequestQueue) ? true : pRequestQueue->empty(); +} + ////////////////////////////////////////////////////////////////////////////////////// // // LLObjectMediaDataClient @@ -465,7 +485,7 @@ const char *LLObjectMediaDataClient::getCapabilityName() const return "ObjectMedia"; } -void LLObjectMediaDataClient::fetchMedia(LLVOVolume *object) +void LLObjectMediaDataClient::fetchMedia(LLMediaDataClientObject *object) { LLSD sd_payload; sd_payload["verb"] = "GET"; @@ -473,18 +493,17 @@ void LLObjectMediaDataClient::fetchMedia(LLVOVolume *object) request(object, sd_payload); } -void LLObjectMediaDataClient::updateMedia(LLVOVolume *object) +void LLObjectMediaDataClient::updateMedia(LLMediaDataClientObject *object) { LLSD sd_payload; sd_payload["verb"] = "UPDATE"; sd_payload[LLTextureEntry::OBJECT_ID_KEY] = object->getID(); LLSD object_media_data; - for (int i=0; i < object->getNumTEs(); i++) { - LLTextureEntry *texture_entry = object->getTE(i); - llassert((texture_entry->getMediaData() != NULL) == texture_entry->hasMedia()); - const LLSD &media_data = - (texture_entry->getMediaData() == NULL) ? LLSD() : texture_entry->getMediaData()->asLLSD(); - object_media_data.append(media_data); + int i = 0; + int end = object->getMediaDataCount(); + for ( ; i < end ; ++i) + { + object_media_data.append(object->getMediaDataLLSD(i)); } sd_payload[LLTextureEntry::OBJECT_MEDIA_DATA_KEY] = object_media_data; @@ -548,7 +567,7 @@ const char *LLObjectMediaNavigateClient::getCapabilityName() const return "ObjectMediaNavigate"; } -void LLObjectMediaNavigateClient::navigate(LLVOVolume *object, U8 texture_index, const std::string &url) +void LLObjectMediaNavigateClient::navigate(LLMediaDataClientObject *object, U8 texture_index, const std::string &url) { LLSD sd_payload; sd_payload[LLTextureEntry::OBJECT_ID_KEY] = object->getID(); -- cgit v1.2.3 From 780719c14c6c2921eaf0a6021a4082b5486efafb Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Mon, 12 Oct 2009 17:52:33 -0700 Subject: Add some more logging to help triage media client problems --- indra/newview/llmediadataclient.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'indra/newview/llmediadataclient.cpp') diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp index 3a1b47554c..255f6d1f84 100644 --- a/indra/newview/llmediadataclient.cpp +++ b/indra/newview/llmediadataclient.cpp @@ -357,7 +357,7 @@ BOOL LLMediaDataClient::QueueTimer::tick() return TRUE; } - LL_DEBUGS("LLMediaDataClient") << "QueueTimer::tick() started, queue is: " << queue << LL_ENDL; + LL_INFOS("LLMediaDataClient") << "QueueTimer::tick() started, queue is: " << queue << LL_ENDL; // Peel one off of the items from the queue, and execute request request_ptr_t request = queue.top(); @@ -382,9 +382,13 @@ BOOL LLMediaDataClient::QueueTimer::tick() } } else { - if (!object->hasMedia()) + if (NULL == object) { - LL_INFOS("LLMediaDataClient") << "Not Sending request for " << *request << " hasMedia() is false!" << LL_ENDL; + LL_WARNS("LLMediaDataClient") << "Not Sending request for " << *request << " NULL object!" << LL_ENDL; + } + else if (!object->hasMedia()) + { + LL_WARNS("LLMediaDataClient") << "Not Sending request for " << *request << " hasMedia() is false!" << LL_ENDL; } } bool exceeded_retries = request->getRetryCount() > mMDC->mMaxNumRetries; @@ -414,6 +418,9 @@ void LLMediaDataClient::startQueueTimer() // LLEventTimer automagically takes care of the lifetime of this object new QueueTimer(mQueueTimerDelay, this); } + else { + LL_DEBUGS("LLMediaDataClient") << "not starting queue timer (it's already running, right???)" << LL_ENDL; + } } void LLMediaDataClient::stopQueueTimer() -- cgit v1.2.3 From 4598a4a621635be9d507534f613d3768edcb62ec Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Tue, 13 Oct 2009 20:52:04 -0700 Subject: Another attempt at fixing unit test, this one is weirder. Don't schedule the queue timer in the tick() of the retry timer. Instead, schedule it in the RetryTimer's destructor. This is an artifact of how the LLEventTimer's loop is handled. --- indra/newview/llmediadataclient.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'indra/newview/llmediadataclient.cpp') diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp index 255f6d1f84..f797f15865 100644 --- a/indra/newview/llmediadataclient.cpp +++ b/indra/newview/llmediadataclient.cpp @@ -182,15 +182,20 @@ LLMediaDataClient::Responder::RetryTimer::RetryTimer(F32 time, Responder *mdr) LLMediaDataClient::Responder::RetryTimer::~RetryTimer() { LL_DEBUGS("LLMediaDataClient") << "~RetryTimer" << *(mResponder->getRequest()) << LL_ENDL; + + // XXX This is weird: Instead of doing the work in tick() (which re-schedules + // a timer, which might be risky), do it here, in the destructor. Yes, it is very odd. + // Instead of retrying, we just put the request back onto the queue + LL_INFOS("LLMediaDataClient") << "RetryTimer fired for: " << *(mResponder->getRequest()) << "retrying" << LL_ENDL; + mResponder->getRequest()->reEnqueue(); + + // Release the ref to the responder. mResponder = NULL; } // virtual BOOL LLMediaDataClient::Responder::RetryTimer::tick() { - // Instead of retrying, we just put the request back onto the queue - LL_INFOS("LLMediaDataClient") << "RetryTimer fired for: " << *(mResponder->getRequest()) << "retrying" << LL_ENDL; - mResponder->getRequest()->reEnqueue(); // Don't fire again return TRUE; } -- cgit v1.2.3 From d78520f6b7fd4a20bbb1d1291a34761efc1fd740 Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Mon, 19 Oct 2009 17:08:45 -0700 Subject: Compress logging of media data (but still have it) --- indra/newview/llmediadataclient.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'indra/newview/llmediadataclient.cpp') diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp index f797f15865..6ae42d23d3 100755 --- a/indra/newview/llmediadataclient.cpp +++ b/indra/newview/llmediadataclient.cpp @@ -250,7 +250,7 @@ void LLMediaDataClient::Responder::error(U32 status, const std::string& reason) /*virtual*/ void LLMediaDataClient::Responder::result(const LLSD& content) { - LL_INFOS("LLMediaDataClient") << *mRequest << "result : " << ll_pretty_print_sd(content) << LL_ENDL; + LL_INFOS("LLMediaDataClient") << *mRequest << "result : " << ll_print_sd(content) << LL_ENDL; } @@ -524,7 +524,7 @@ void LLObjectMediaDataClient::updateMedia(LLMediaDataClientObject *object) } sd_payload[LLTextureEntry::OBJECT_MEDIA_DATA_KEY] = object_media_data; - LL_INFOS("LLMediaDataClient") << "update media data: " << object->getID() << " " << ll_pretty_print_sd(sd_payload) << LL_ENDL; + LL_INFOS("LLMediaDataClient") << "update media data: " << object->getID() << " " << ll_print_sd(sd_payload) << LL_ENDL; request(object, sd_payload); } @@ -536,7 +536,7 @@ void LLObjectMediaDataClient::Responder::result(const LLSD& content) llassert(type == LLMediaDataClient::Request::GET || type == LLMediaDataClient::Request::UPDATE) if (type == LLMediaDataClient::Request::GET) { - LL_INFOS("LLMediaDataClient") << *(getRequest()) << "GET returned: " << ll_pretty_print_sd(content) << LL_ENDL; + LL_INFOS("LLMediaDataClient") << *(getRequest()) << "GET returned: " << ll_print_sd(content) << LL_ENDL; // Look for an error if (content.has("error")) @@ -614,7 +614,7 @@ void LLObjectMediaNavigateClient::Responder::error(U32 status, const std::string /*virtual*/ void LLObjectMediaNavigateClient::Responder::result(const LLSD& content) { - LL_DEBUGS("LLMediaDataClient") << *(getRequest()) << " NAVIGATE returned " << ll_pretty_print_sd(content) << LL_ENDL; + LL_INFOS("LLMediaDataClient") << *(getRequest()) << " NAVIGATE returned " << ll_print_sd(content) << LL_ENDL; if (content.has("error")) { -- cgit v1.2.3