aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/llcachename.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:56 -0500
committerJacek Antonelli2008-08-15 23:44:56 -0500
commitc07901e29ed545bbb02e3bddf148fe1104b94e9f (patch)
treef1ada64ce834acd7d92a425efb96c4b86bcf16b1 /linden/indra/llmessage/llcachename.cpp
parentSecond Life viewer sources 1.15.0.2 (diff)
downloadmeta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.zip
meta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.tar.gz
meta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.tar.bz2
meta-impy-c07901e29ed545bbb02e3bddf148fe1104b94e9f.tar.xz
Second Life viewer sources 1.15.1.3
Diffstat (limited to '')
-rw-r--r--linden/indra/llmessage/llcachename.cpp95
1 files changed, 79 insertions, 16 deletions
diff --git a/linden/indra/llmessage/llcachename.cpp b/linden/indra/llmessage/llcachename.cpp
index 5df62b3..1cc7e09 100644
--- a/linden/indra/llmessage/llcachename.cpp
+++ b/linden/indra/llmessage/llcachename.cpp
@@ -52,6 +52,10 @@ const char* CN_NONE = "(none)";
52const char* CN_HIPPOS = "(hippos)"; 52const char* CN_HIPPOS = "(hippos)";
53const F32 HIPPO_PROBABILITY = 0.01f; 53const F32 HIPPO_PROBABILITY = 0.01f;
54 54
55// We track name requests in flight for up to this long.
56// We won't re-request a name during this time
57const U32 PENDING_TIMEOUT_SECS = 5 * 60;
58
55// File version number 59// File version number
56const S32 CN_FILE_VERSION = 2; 60const S32 CN_FILE_VERSION = 2;
57 61
@@ -182,8 +186,9 @@ namespace {
182 } 186 }
183 187
184 188
185 typedef std::vector<LLUUID> AskQueue; 189 typedef std::set<LLUUID> AskQueue;
186 typedef std::vector<PendingReply> ReplyQueue; 190 typedef std::vector<PendingReply> ReplyQueue;
191 typedef std::map<LLUUID,U32> PendingQueue;
187 typedef std::map<LLUUID, LLCacheNameEntry*> Cache; 192 typedef std::map<LLUUID, LLCacheNameEntry*> Cache;
188 typedef std::vector<LLCacheNameCallback> Observers; 193 typedef std::vector<LLCacheNameCallback> Observers;
189}; 194};
@@ -200,6 +205,9 @@ public:
200 AskQueue mAskNameQueue; 205 AskQueue mAskNameQueue;
201 AskQueue mAskGroupQueue; 206 AskQueue mAskGroupQueue;
202 // UUIDs to ask our upstream host about 207 // UUIDs to ask our upstream host about
208
209 PendingQueue mPendingQueue;
210 // UUIDs that have been requested but are not in cache yet.
203 211
204 ReplyQueue mReplyQueue; 212 ReplyQueue mReplyQueue;
205 // requests awaiting replies from us 213 // requests awaiting replies from us
@@ -214,6 +222,7 @@ public:
214 void processPendingAsks(); 222 void processPendingAsks();
215 void processPendingReplies(); 223 void processPendingReplies();
216 void sendRequest(const char* msg_name, const AskQueue& queue); 224 void sendRequest(const char* msg_name, const AskQueue& queue);
225 bool isRequestPending(const LLUUID& id);
217 226
218 // Message system callbacks. 227 // Message system callbacks.
219 void processUUIDRequest(LLMessageSystem* msg, bool isGroup); 228 void processUUIDRequest(LLMessageSystem* msg, bool isGroup);
@@ -456,7 +465,10 @@ BOOL LLCacheName::getName(const LLUUID& id, char* first, char* last)
456 : CN_WAITING); 465 : CN_WAITING);
457 strcpy(last, ""); /*Flawfinder: ignore*/ 466 strcpy(last, ""); /*Flawfinder: ignore*/
458 467
459 impl.mAskNameQueue.push_back(id); 468 if (!impl.isRequestPending(id))
469 {
470 impl.mAskNameQueue.insert(id);
471 }
460 return FALSE; 472 return FALSE;
461 } 473 }
462 474
@@ -496,8 +508,10 @@ BOOL LLCacheName::getGroupName(const LLUUID& id, char* group)
496 // The function signature needs to change to pass in the length 508 // The function signature needs to change to pass in the length
497 // of first and last. 509 // of first and last.
498 strcpy(group, CN_WAITING); /*Flawfinder: ignore*/ 510 strcpy(group, CN_WAITING); /*Flawfinder: ignore*/
499 511 if (!impl.isRequestPending(id))
500 impl.mAskGroupQueue.push_back(id); 512 {
513 impl.mAskGroupQueue.insert(id);
514 }
501 return FALSE; 515 return FALSE;
502 } 516 }
503} 517}
@@ -525,13 +539,16 @@ void LLCacheName::get(const LLUUID& id, BOOL is_group, LLCacheNameCallback callb
525 } 539 }
526 else 540 else
527 { 541 {
528 if (!is_group) 542 if (!impl.isRequestPending(id))
529 {
530 impl.mAskNameQueue.push_back(id);
531 }
532 else
533 { 543 {
534 impl.mAskGroupQueue.push_back(id); 544 if (!is_group)
545 {
546 impl.mAskNameQueue.insert(id);
547 }
548 else
549 {
550 impl.mAskGroupQueue.insert(id);
551 }
535 } 552 }
536 impl.mReplyQueue.push_back(PendingReply(id, callback, user_data)); 553 impl.mReplyQueue.push_back(PendingReply(id, callback, user_data));
537 } 554 }
@@ -570,6 +587,19 @@ void LLCacheName::deleteEntriesOlderThan(S32 secs)
570 impl.mCache.erase(curiter); 587 impl.mCache.erase(curiter);
571 } 588 }
572 } 589 }
590
591 // These are pending requests that we never heard back from.
592 U32 pending_expire_time = now - PENDING_TIMEOUT_SECS;
593 for(PendingQueue::iterator p_iter = impl.mPendingQueue.begin();
594 p_iter != impl.mPendingQueue.end(); )
595 {
596 PendingQueue::iterator p_curitor = p_iter++;
597
598 if (p_curitor->second < pending_expire_time)
599 {
600 impl.mPendingQueue.erase(p_curitor);
601 }
602 }
573} 603}
574 604
575 605
@@ -599,6 +629,18 @@ void LLCacheName::dump()
599 } 629 }
600} 630}
601 631
632void LLCacheName::dumpStats()
633{
634 llinfos << "Queue sizes: "
635 << " Cache=" << impl.mCache.size()
636 << " AskName=" << impl.mAskNameQueue.size()
637 << " AskGroup=" << impl.mAskGroupQueue.size()
638 << " Pending=" << impl.mPendingQueue.size()
639 << " Reply=" << impl.mReplyQueue.size()
640 << " Observers=" << impl.mObservers.size()
641 << llendl;
642}
643
602void LLCacheName::Impl::processPendingAsks() 644void LLCacheName::Impl::processPendingAsks()
603{ 645{
604 sendRequest(_PREHASH_UUIDNameRequest, mAskNameQueue); 646 sendRequest(_PREHASH_UUIDNameRequest, mAskNameQueue);
@@ -702,7 +744,23 @@ void LLCacheName::Impl::notifyObservers(const LLUUID& id,
702 } 744 }
703} 745}
704 746
747bool LLCacheName::Impl::isRequestPending(const LLUUID& id)
748{
749 U32 now = (U32)time(NULL);
750 U32 expire_time = now - PENDING_TIMEOUT_SECS;
705 751
752 PendingQueue::iterator iter = mPendingQueue.find(id);
753
754 if (iter == mPendingQueue.end()
755 || (iter->second < expire_time) )
756 {
757 mPendingQueue[id] = now;
758 return false;
759 }
760
761 return true;
762}
763
706void LLCacheName::Impl::processUUIDRequest(LLMessageSystem* msg, bool isGroup) 764void LLCacheName::Impl::processUUIDRequest(LLMessageSystem* msg, bool isGroup)
707{ 765{
708 // You should only get this message if the cache is at the simulator 766 // You should only get this message if the cache is at the simulator
@@ -740,13 +798,16 @@ void LLCacheName::Impl::processUUIDRequest(LLMessageSystem* msg, bool isGroup)
740 } 798 }
741 else 799 else
742 { 800 {
743 if (isGroup) 801 if (!isRequestPending(id))
744 { 802 {
745 mAskGroupQueue.push_back(id); 803 if (isGroup)
746 } 804 {
747 else 805 mAskGroupQueue.insert(id);
748 { 806 }
749 mAskNameQueue.push_back(id); 807 else
808 {
809 mAskNameQueue.insert(id);
810 }
750 } 811 }
751 812
752 mReplyQueue.push_back(PendingReply(id, fromHost)); 813 mReplyQueue.push_back(PendingReply(id, fromHost));
@@ -770,6 +831,8 @@ void LLCacheName::Impl::processUUIDReply(LLMessageSystem* msg, bool isGroup)
770 mCache[id] = entry; 831 mCache[id] = entry;
771 } 832 }
772 833
834 mPendingQueue.erase(id);
835
773 entry->mIsGroup = isGroup; 836 entry->mIsGroup = isGroup;
774 entry->mCreateTime = (U32)time(NULL); 837 entry->mCreateTime = (U32)time(NULL);
775 if (!isGroup) 838 if (!isGroup)