summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Cook <james@lindenlab.com>2010-04-22 10:24:17 -0700
committerJames Cook <james@lindenlab.com>2010-04-22 10:24:17 -0700
commit61d79980d888a7bbac96df9955582f835b169a97 (patch)
treee7acef0a953864e5e962cdca1f6ddd644d0a538c
parent71ce49239adc1abec26d73ddd97cfd0c17677c2b (diff)
Starting to implement running switch and 503 error handling
-rw-r--r--indra/llmessage/llavatarnamecache.cpp39
-rw-r--r--indra/llmessage/llavatarnamecache.h13
2 files changed, 45 insertions, 7 deletions
diff --git a/indra/llmessage/llavatarnamecache.cpp b/indra/llmessage/llavatarnamecache.cpp
index d10958d09d..6455286770 100644
--- a/indra/llmessage/llavatarnamecache.cpp
+++ b/indra/llmessage/llavatarnamecache.cpp
@@ -44,9 +44,12 @@
namespace LLAvatarNameCache
{
- // *TODO: Defaulted to true for demo, probably want false for initial
- // release and turn it on based on data from login.cgi
+ // Will be turned on and off based on service availability, sometimes
+ // in the middle of a session.
bool sUseDisplayNames = true;
+
+ // While false, buffer requests for later. Used during viewer startup.
+ bool sRunning = false;
// Base lookup URL for name service.
// On simulator, loaded from indra.xml
@@ -130,7 +133,16 @@ namespace LLAvatarNameCache
class LLAvatarNameResponder : public LLHTTPClient::Responder
{
+private:
+ // need to store agent ids that are part of this request in case of
+ // an error, so we can flag them as unavailable
+ std::vector<LLUUID> mAgentIDs;
+
public:
+ LLAvatarNameResponder(const std::vector<LLUUID>& agent_ids)
+ : mAgentIDs(agent_ids)
+ { }
+
/*virtual*/ void result(const LLSD& content)
{
LLSD agents = content["agents"];
@@ -202,6 +214,9 @@ void LLAvatarNameCache::requestNames()
std::string url;
url.reserve(NAME_URL_MAX);
+ std::vector<LLUUID> agent_ids;
+ agent_ids.reserve(128);
+
ask_queue_t::const_iterator it = sAskQueue.begin();
for ( ; it != sAskQueue.end(); ++it)
{
@@ -217,25 +232,29 @@ void LLAvatarNameCache::requestNames()
url += "&ids=";
}
url += it->asString();
+ agent_ids.push_back(*it);
if (url.size() > NAME_URL_SEND_THRESHOLD)
{
//llinfos << "requestNames " << url << llendl;
- LLHTTPClient::get(url, new LLAvatarNameResponder());
+ LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids));
url.clear();
+ agent_ids.clear();
}
}
if (!url.empty())
{
//llinfos << "requestNames " << url << llendl;
- LLHTTPClient::get(url, new LLAvatarNameResponder());
+ LLHTTPClient::get(url, new LLAvatarNameResponder(agent_ids));
url.clear();
+ agent_ids.clear();
}
}
-void LLAvatarNameCache::initClass()
+void LLAvatarNameCache::initClass(bool running)
{
+ sRunning = running;
}
void LLAvatarNameCache::cleanupClass()
@@ -288,8 +307,18 @@ void LLAvatarNameCache::setNameLookupURL(const std::string& name_lookup_url)
sNameLookupURL = name_lookup_url;
}
+void LLAvatarNameCache::setRunning(bool running)
+{
+ sRunning = running;
+}
+
void LLAvatarNameCache::idle()
{
+ if (!sRunning)
+ {
+ return;
+ }
+
// 100 ms is the threshold for "user speed" operations, so we can
// stall for about that long to batch up requests.
const F32 SECS_BETWEEN_REQUESTS = 0.1f;
diff --git a/indra/llmessage/llavatarnamecache.h b/indra/llmessage/llavatarnamecache.h
index ad5ecc896e..4aabacd1f3 100644
--- a/indra/llmessage/llavatarnamecache.h
+++ b/indra/llmessage/llavatarnamecache.h
@@ -42,7 +42,10 @@ class LLUUID;
namespace LLAvatarNameCache
{
- void initClass();
+ // On the viewer, name cache starts in a non-running state until we
+ // know if we have the name lookup capability for the agent's region.
+ // In that state it buffers requests for later.
+ void initClass(bool running);
void cleanupClass();
void importFile(std::istream& istr);
@@ -51,6 +54,10 @@ namespace LLAvatarNameCache
// On the viewer, usually a simulator capabilitity
void setNameLookupURL(const std::string& name_lookup_url);
+ // Once we know if the lookup service is available we can start
+ // requesting names.
+ void setRunning(bool running);
+
// Periodically makes a batch request for display names not already in
// cache. Call once per frame.
void idle();
@@ -69,7 +76,9 @@ namespace LLAvatarNameCache
// If name information is in cache, callback will be called immediately.
void get(const LLUUID& agent_id, callback_slot_t slot);
- // Not all grids support display names
+ // JAMESDEBUG TODO: collapse this with setNameLookupUrl?
+ // Not all grids support display names. If display names are disabled,
+ // fall back to old name lookup system.
void setUseDisplayNames(bool use);
bool useDisplayNames();