diff options
-rwxr-xr-x | indra/newview/llagentwearables.cpp | 1 | ||||
-rwxr-xr-x | indra/newview/llappearancemgr.cpp | 1 | ||||
-rwxr-xr-x | indra/newview/llattachmentsmgr.cpp | 95 | ||||
-rwxr-xr-x | indra/newview/llattachmentsmgr.h | 26 |
4 files changed, 92 insertions, 31 deletions
diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp index 4d46a331c8..d772e1c7f8 100755 --- a/indra/newview/llagentwearables.cpp +++ b/indra/newview/llagentwearables.cpp @@ -1362,6 +1362,7 @@ void LLAgentWearables::userRemoveMultipleAttachments(llvo_vec_t& objects_to_remo const LLUUID& item_id = objectp->getAttachmentItemID(); LLViewerInventoryItem *item = gInventory.getItem(item_id); LL_DEBUGS("Avatar") << "ATT removing object, item is " << (item ? item->getName() : "UNKNOWN") << " " << item_id << LL_ENDL; + LLAttachmentsMgr::instance().onDetachRequested(item_id); } gMessageSystem->sendReliable(gAgent.getRegionHost()); } diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 5e51758ac6..a94aa37ab7 100755 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -3935,6 +3935,7 @@ void LLAppearanceMgr::unregisterAttachment(const LLUUID& item_id) << (item ? item->getName() : "UNKNOWN") << " " << item_id << LL_ENDL; gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); + LLAttachmentsMgr::instance().onDetachCompleted(item_id); if (mAttachmentInvLinkEnabled && isLinkedInCOF(item_id)) { LL_DEBUGS("Avatar") << "ATT removing COF link for attachment " diff --git a/indra/newview/llattachmentsmgr.cpp b/indra/newview/llattachmentsmgr.cpp index 285824f261..6b8f7044cd 100755 --- a/indra/newview/llattachmentsmgr.cpp +++ b/indra/newview/llattachmentsmgr.cpp @@ -40,7 +40,9 @@ const F32 COF_LINK_BATCH_TIME = 5.0F; const F32 MAX_ATTACHMENT_REQUEST_LIFETIME = 30.0F; const F32 MIN_RETRY_REQUEST_TIME = 5.0F; -LLAttachmentsMgr::LLAttachmentsMgr() +LLAttachmentsMgr::LLAttachmentsMgr(): + mAttachmentRequests("attach",MIN_RETRY_REQUEST_TIME), + mDetachRequests("detach",MIN_RETRY_REQUEST_TIME) { } @@ -54,7 +56,7 @@ void LLAttachmentsMgr::addAttachmentRequest(const LLUUID& item_id, { LLViewerInventoryItem *item = gInventory.getItem(item_id); - if (attachmentWasRequestedRecently(item_id)) + if (mAttachmentRequests.wasRequestedRecently(item_id)) { LL_DEBUGS("Avatar") << "ATT not adding attachment to mPendingAttachments, recent request is already pending: " << (item ? item->getName() : "UNKNOWN") << " id " << item_id << LL_ENDL; @@ -70,7 +72,7 @@ void LLAttachmentsMgr::addAttachmentRequest(const LLUUID& item_id, attachment.mAdd = add; mPendingAttachments.push_back(attachment); - addAttachmentRequestTime(item_id); + mAttachmentRequests.addTime(item_id); } // static @@ -212,7 +214,8 @@ void LLAttachmentsMgr::linkRecentlyArrivedAttachments() return; } - LL_DEBUGS("Avatar") << "ATT checking COF linkability for " << mRecentlyArrivedAttachments.size() << " recently arrived items" << LL_ENDL; + LL_DEBUGS("Avatar") << "ATT checking COF linkability for " << mRecentlyArrivedAttachments.size() + << " recently arrived items" << LL_ENDL; LLInventoryObject::const_object_list_t inv_items_to_link; for (std::set<LLUUID>::iterator it = mRecentlyArrivedAttachments.begin(); it != mRecentlyArrivedAttachments.end(); ++it) @@ -236,44 +239,57 @@ void LLAttachmentsMgr::linkRecentlyArrivedAttachments() } } -void LLAttachmentsMgr::addAttachmentRequestTime(const LLUUID& inv_item_id) +LLAttachmentsMgr::LLItemRequestTimes::LLItemRequestTimes(const std::string& op_name, F32 timeout): + mOpName(op_name), + mTimeout(timeout) +{ +} + +void LLAttachmentsMgr::LLItemRequestTimes::addTime(const LLUUID& inv_item_id) { LLInventoryItem *item = gInventory.getItem(inv_item_id); - LL_DEBUGS("Avatar") << "ATT add request time " << (item ? item->getName() : "UNKNOWN") << " " << inv_item_id << LL_ENDL; + LL_DEBUGS("Avatar") << "ATT " << mOpName << " adding request time " << (item ? item->getName() : "UNKNOWN") << " " << inv_item_id << LL_ENDL; LLTimer current_time; - mAttachmentRequests[inv_item_id] = current_time; + (*this)[inv_item_id] = current_time; } -void LLAttachmentsMgr::removeAttachmentRequestTime(const LLUUID& inv_item_id) +void LLAttachmentsMgr::LLItemRequestTimes::removeTime(const LLUUID& inv_item_id) { LLInventoryItem *item = gInventory.getItem(inv_item_id); - LL_DEBUGS("Avatar") << "ATT remove request time " << (item ? item->getName() : "UNKNOWN") << " " << inv_item_id << LL_ENDL; - mAttachmentRequests.erase(inv_item_id); + LL_DEBUGS("Avatar") << "ATT " << mOpName << " removing request time " + << (item ? item->getName() : "UNKNOWN") << " " << inv_item_id << LL_ENDL; + (*this).erase(inv_item_id); } -BOOL LLAttachmentsMgr::attachmentWasRequestedRecently(const LLUUID& inv_item_id) const +BOOL LLAttachmentsMgr::LLItemRequestTimes::getTime(const LLUUID& inv_item_id, LLTimer& timer) const { - std::map<LLUUID,LLTimer>::const_iterator it = mAttachmentRequests.find(inv_item_id); - if (it != mAttachmentRequests.end()) + std::map<LLUUID,LLTimer>::const_iterator it = (*this).find(inv_item_id); + if (it != (*this).end()) { - const LLTimer& request_time = it->second; + timer = it->second; + return TRUE; + } + return FALSE; +} + +BOOL LLAttachmentsMgr::LLItemRequestTimes::wasRequestedRecently(const LLUUID& inv_item_id) const +{ + LLTimer request_time; + if (getTime(inv_item_id, request_time)) + { F32 request_time_elapsed = request_time.getElapsedTimeF32(); - if (request_time_elapsed > MIN_RETRY_REQUEST_TIME) + if (request_time_elapsed >= mTimeout) { LLInventoryItem *item = gInventory.getItem(inv_item_id); - LL_DEBUGS("Avatar") << "ATT time ignored, exceeded " << MIN_RETRY_REQUEST_TIME + LL_DEBUGS("Avatar") << "ATT " << mOpName << " request time ignored, exceeded " << mTimeout << " " << (item ? item->getName() : "UNKNOWN") << " " << inv_item_id << LL_ENDL; - return FALSE; - } - else - { - return TRUE; - } - } - else - { - return FALSE; - } + } + return request_time_elapsed < mTimeout; + } + else + { + return FALSE; + } } // If we've been waiting for an attachment a long time, we want to @@ -305,7 +321,7 @@ void LLAttachmentsMgr::expireOldAttachmentRequests() // it to the set of recently arrived items. void LLAttachmentsMgr::onAttachmentArrived(const LLUUID& inv_item_id) { - removeAttachmentRequestTime(inv_item_id); + mAttachmentRequests.removeTime(inv_item_id); if (mRecentlyArrivedAttachments.empty()) { // Start the timer for sending off a COF link batch. @@ -313,3 +329,26 @@ void LLAttachmentsMgr::onAttachmentArrived(const LLUUID& inv_item_id) } mRecentlyArrivedAttachments.insert(inv_item_id); } + +void LLAttachmentsMgr::onDetachRequested(const LLUUID& inv_item_id) +{ + mDetachRequests.addTime(inv_item_id); +} + +void LLAttachmentsMgr::onDetachCompleted(const LLUUID& inv_item_id) +{ + LLTimer timer; + LLInventoryItem *item = gInventory.getItem(inv_item_id); + if (mDetachRequests.getTime(inv_item_id, timer)) + { + LL_DEBUGS("Avatar") << "ATT detach completed after " << timer.getElapsedTimeF32() + << " seconds for " << (item ? item->getName() : "UNKNOWN") << " " << inv_item_id << LL_ENDL; + mDetachRequests.removeTime(inv_item_id); + } + else + { + LL_WARNS("Avatar") << "ATT unexpected detach for " + << (item ? item->getName() : "UNKNOWN") << " id " << inv_item_id << LL_ENDL; + } + +} diff --git a/indra/newview/llattachmentsmgr.h b/indra/newview/llattachmentsmgr.h index 4f9efb272f..2834c10a2f 100755 --- a/indra/newview/llattachmentsmgr.h +++ b/indra/newview/llattachmentsmgr.h @@ -81,11 +81,27 @@ public: void requestAttachments(const attachments_vec_t& attachment_requests); static void onIdle(void *); - BOOL attachmentWasRequestedRecently(const LLUUID& inv_item_id) const; - void addAttachmentRequestTime(const LLUUID& inv_item_id); void onAttachmentArrived(const LLUUID& inv_item_id); + void onDetachRequested(const LLUUID& inv_item_id); + void onDetachCompleted(const LLUUID& inv_item_id); + private: + + class LLItemRequestTimes: public std::map<LLUUID,LLTimer> + { + public: + LLItemRequestTimes(const std::string& op_name, F32 timeout); + void addTime(const LLUUID& inv_item_id); + void removeTime(const LLUUID& inv_item_id); + BOOL wasRequestedRecently(const LLUUID& item_id) const; + BOOL getTime(const LLUUID& inv_item_id, LLTimer& timer) const; + + private: + F32 mTimeout; + std::string mOpName; + }; + void removeAttachmentRequestTime(const LLUUID& inv_item_id); void onIdle(); void requestPendingAttachments(); @@ -96,11 +112,15 @@ private: attachments_vec_t mPendingAttachments; // Attachments that have been requested from server but have not arrived yet. - std::map<LLUUID,LLTimer> mAttachmentRequests; + LLItemRequestTimes mAttachmentRequests; + + // Attachments that have been requested to detach but have not gone away yet. + LLItemRequestTimes mDetachRequests; // Attachments that have arrived but have not been linked in the COF yet. std::set<LLUUID> mRecentlyArrivedAttachments; LLTimer mCOFLinkBatchTimer; + }; #endif |