diff options
Diffstat (limited to 'indra/newview/llappearancemgr.cpp')
-rwxr-xr-x | indra/newview/llappearancemgr.cpp | 301 |
1 files changed, 206 insertions, 95 deletions
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index d15c3dd13d..f56ae7caf1 100755 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -49,6 +49,8 @@ #include "llvoavatarself.h" #include "llviewerregion.h" #include "llwearablelist.h" +#include "llsdutil.h" +#include "llsdserialize.h" std::string self_av_string() { @@ -155,6 +157,16 @@ LLUUID findDescendentCategoryIDByName(const LLUUID& parent_id, const std::string } } +// We want this to be much lower (e.g. 15.0 is usually fine), bumping +// up for now until we can diagnose some cases of very slow response +// to requests. +const F32 DEFAULT_RETRY_AFTER_INTERVAL = 300.0; + +// Given the current back-end problems, retrying is causing too many +// duplicate items. Bump this back to 2 once they are resolved (or can +// leave at 0 if the operations become actually reliable). +const S32 DEFAULT_MAX_RETRIES = 0; + class LLCallAfterInventoryBatchMgr: public LLEventTimer { public: @@ -162,8 +174,8 @@ public: const std::string& phase_name, nullary_func_t on_completion_func, nullary_func_t on_failure_func = no_op, - F32 retry_after = 15.0, - S32 max_retries = 2 + F32 retry_after = DEFAULT_RETRY_AFTER_INTERVAL, + S32 max_retries = DEFAULT_MAX_RETRIES ): mDstCatID(dst_cat_id), mTrackingPhase(phase_name), @@ -175,7 +187,7 @@ public: mFailCount(0), mCompletionOrFailureCalled(false), mRetryCount(0), - LLEventTimer(retry_after) + LLEventTimer(5.0) { if (!mTrackingPhase.empty()) { @@ -198,52 +210,38 @@ public: // Request or re-request operation for specified item. void addItem(const LLUUID& item_id) { - LLUUID linked_id; - if (gInventory.getItem(item_id)) - { - linked_id = gInventory.getItem(item_id)->getLinkedUUID(); - } - else if (gInventory.getCategory(item_id)) - { - linked_id = item_id; - } - else - { - llwarns << "no referent found for item_id " << item_id << llendl; - return; - } - LL_DEBUGS("Avatar") << "item_id " << item_id << " -> linked_id " << linked_id << llendl; - - if (ll_frand()<gSavedSettings.getF32("InventoryDebugSimulateOpFailureRate")) - { - // simulate server failure by not sending the request. - return; - } + LL_DEBUGS("Avatar") << "item_id " << item_id << llendl; - if (!requestOperation(linked_id)) + if (!requestOperation(item_id)) { - LL_DEBUGS("Avatar") << "item_id " << item_id << " linked_id " << linked_id << " not requested" << llendl; + LL_DEBUGS("Avatar") << "item_id " << item_id << " requestOperation false, skipping" << llendl; return; } mPendingRequests++; // On a re-request, this will reset the timer. - mWaitTimes[linked_id] = LLTimer(); - if (mRetryCounts.find(linked_id) == mRetryCounts.end()) + mWaitTimes[item_id] = LLTimer(); + if (mRetryCounts.find(item_id) == mRetryCounts.end()) { - mRetryCounts[linked_id] = 0; + mRetryCounts[item_id] = 0; } else { - mRetryCounts[linked_id]++; + mRetryCounts[item_id]++; } - } virtual bool requestOperation(const LLUUID& item_id) = 0; void onOp(const LLUUID& src_id, const LLUUID& dst_id, LLTimer timestamp) { + if (ll_frand() < gSavedSettings.getF32("InventoryDebugSimulateLateOpRate")) + { + llwarns << "Simulating late operation by punting handling to later" << llendl; + doAfterInterval(boost::bind(&LLCallAfterInventoryBatchMgr::onOp,this,src_id,dst_id,timestamp), + mRetryAfter); + return; + } mPendingRequests--; F32 elapsed = timestamp.getElapsedTimeF32(); LL_DEBUGS("Avatar") << "op done, src_id " << src_id << " dst_id " << dst_id << " after " << elapsed << " seconds" << llendl; @@ -386,8 +384,8 @@ public: const std::string& phase_name, nullary_func_t on_completion_func, nullary_func_t on_failure_func = no_op, - F32 retry_after = 15.0, - S32 max_retries = 2 + F32 retry_after = DEFAULT_RETRY_AFTER_INTERVAL, + S32 max_retries = DEFAULT_MAX_RETRIES ): LLCallAfterInventoryBatchMgr(dst_cat_id, phase_name, on_completion_func, on_failure_func, retry_after, max_retries) { @@ -399,6 +397,11 @@ public: LLViewerInventoryItem *item = gInventory.getItem(item_id); llassert(item); LL_DEBUGS("Avatar") << "copying item " << item_id << llendl; + if (ll_frand() < gSavedSettings.getF32("InventoryDebugSimulateOpFailureRate")) + { + LL_DEBUGS("Avatar") << "simulating failure by not sending request for item " << item_id << llendl; + return true; + } copy_inventory_item( gAgent.getID(), item->getPermissions().getOwner(), @@ -419,8 +422,8 @@ public: const std::string& phase_name, nullary_func_t on_completion_func, nullary_func_t on_failure_func = no_op, - F32 retry_after = 15.0, - S32 max_retries = 2 + F32 retry_after = DEFAULT_RETRY_AFTER_INTERVAL, + S32 max_retries = DEFAULT_MAX_RETRIES ): LLCallAfterInventoryBatchMgr(dst_cat_id, phase_name, on_completion_func, on_failure_func, retry_after, max_retries) { @@ -433,17 +436,27 @@ public: LLViewerInventoryItem *item = gInventory.getItem(item_id); if (item) { + if (item->getParentUUID() == mDstCatID) + { + LL_DEBUGS("Avatar") << "item " << item_id << " name " << item->getName() << " is already a child of " << mDstCatID << llendl; + return false; + } LL_DEBUGS("Avatar") << "linking item " << item_id << " name " << item->getName() << " to " << mDstCatID << llendl; // create an inventory item link. + if (ll_frand() < gSavedSettings.getF32("InventoryDebugSimulateOpFailureRate")) + { + LL_DEBUGS("Avatar") << "simulating failure by not sending request for item " << item_id << llendl; + return true; + } link_inventory_item(gAgent.getID(), - item_id, + item->getLinkedUUID(), mDstCatID, item->getName(), - item->LLInventoryItem::getDescription(), + item->getActualDescription(), LLAssetType::AT_LINK, new LLBoostFuncInventoryCallback( boost::bind(&LLCallAfterInventoryBatchMgr::onOp,this,item_id,_1,LLTimer()))); - request_sent = true; + return true; } else { @@ -451,7 +464,7 @@ public: LLViewerInventoryCategory *catp = gInventory.getCategory(item_id); if (!catp) { - llwarns << "id not found as inventory item or category " << item_id << llendl; + llwarns << "link request failed, id not found as inventory item or category " << item_id << llendl; return false; } const LLUUID cof = LLAppearanceMgr::instance().getCOF(); @@ -461,6 +474,11 @@ public: if (catp && catp->getPreferredType() == LLFolderType::FT_OUTFIT) { + if (ll_frand() < gSavedSettings.getF32("InventoryDebugSimulateOpFailureRate")) + { + LL_DEBUGS("Avatar") << "simulating failure by not sending request for item " << item_id << llendl; + return true; + } LL_DEBUGS("Avatar") << "linking folder " << item_id << " name " << catp->getName() << " to cof " << cof << llendl; link_inventory_item(gAgent.getID(), item_id, cof, catp->getName(), "", LLAssetType::AT_LINK_FOLDER, @@ -1167,6 +1185,21 @@ S32 LLAppearanceMgr::getCOFVersion() const } } +S32 LLAppearanceMgr::getLastUpdateRequestCOFVersion() const +{ + return mLastUpdateRequestCOFVersion; +} + +S32 LLAppearanceMgr::getLastAppearanceUpdateCOFVersion() const +{ + return mLastAppearanceUpdateCOFVersion; +} + +void LLAppearanceMgr::setLastAppearanceUpdateCOFVersion(S32 new_val) +{ + mLastAppearanceUpdateCOFVersion = new_val; +} + const LLViewerInventoryItem* LLAppearanceMgr::getBaseOutfitLink() { const LLUUID& current_outfit_cat = getCOF(); @@ -1450,13 +1483,13 @@ void LLAppearanceMgr::shallowCopyCategoryContents(const LLUUID& src_id, const LL { case LLAssetType::AT_LINK: { - //LLInventoryItem::getDescription() is used for a new description + //getActualDescription() is used for a new description //to propagate ordering information saved in descriptions of links link_inventory_item(gAgent.getID(), item->getLinkedUUID(), dst_id, item->getName(), - item->LLInventoryItem::getDescription(), + item->getActualDescription(), LLAssetType::AT_LINK, cb); break; } @@ -1636,7 +1669,7 @@ void LLAppearanceMgr::purgeBaseOutfitLink(const LLUUID& category) } } -void LLAppearanceMgr::purgeCategory(const LLUUID& category, bool keep_outfit_links) +void LLAppearanceMgr::purgeCategory(const LLUUID& category, bool keep_outfit_links, LLInventoryModel::item_array_t* keep_items) { LLInventoryModel::cat_array_t cats; LLInventoryModel::item_array_t items; @@ -1649,8 +1682,19 @@ void LLAppearanceMgr::purgeCategory(const LLUUID& category, bool keep_outfit_lin continue; if (item->getIsLinkType()) { +#if 0 + if (keep_items && keep_items->find(item) != LLInventoryModel::item_array_t::FAIL) + { + llinfos << "preserved item" << llendl; + } + else + { + gInventory.purgeObject(item->getUUID()); + } +#else gInventory.purgeObject(item->getUUID()); } +#endif } } @@ -1690,7 +1734,7 @@ void LLAppearanceMgr::linkAll(const LLUUID& cat_uuid, item->getLinkedUUID(), cat_uuid, item->getName(), - item->LLInventoryItem::getDescription(), + item->getActualDescription(), LLAssetType::AT_LINK, cb); @@ -1761,38 +1805,21 @@ void LLAppearanceMgr::updateCOF(const LLUUID& category, bool append) getDescendentsOfAssetType(category, gest_items, LLAssetType::AT_GESTURE, false); removeDuplicateItems(gest_items); -#ifndef LL_RELEASE_FOR_DOWNLOAD - LL_DEBUGS("Avatar") << self_av_string() << "Linking body items" << LL_ENDL; -#endif - // Create links to new COF contents. - LL_DEBUGS("Avatar") << self_av_string() << "creating LLCallAfterInventoryLinkMgr" << LL_ENDL; - bool update_base_outfit_ordering = !append; - LLCallAfterInventoryLinkMgr *link_waiter = - new LLCallAfterInventoryLinkMgr(body_items,cof,"update_appearance_on_destroy", - boost::bind(&LLAppearanceMgr::updateAppearanceFromCOF, - LLAppearanceMgr::getInstance(), - update_base_outfit_ordering)); - -#ifndef LL_RELEASE_FOR_DOWNLOAD - LL_DEBUGS("Avatar") << self_av_string() << "Linking wear items" << LL_ENDL; -#endif - link_waiter->addItems(wear_items); - -#ifndef LL_RELEASE_FOR_DOWNLOAD - LL_DEBUGS("Avatar") << self_av_string() << "Linking obj items" << LL_ENDL; -#endif - link_waiter->addItems(obj_items); + LLInventoryModel::item_array_t all_items; + all_items += body_items; + all_items += wear_items; + all_items += obj_items; + all_items += gest_items; -#ifndef LL_RELEASE_FOR_DOWNLOAD - LL_DEBUGS("Avatar") << self_av_string() << "Linking gesture items" << LL_ENDL; -#endif - link_waiter->addItems(gest_items); + // Will link all the above items. + LLPointer<LLInventoryCallback> link_waiter = new LLUpdateAppearanceOnDestroy; + linkAll(cof,all_items,link_waiter); // Add link to outfit if category is an outfit. if (!append) { - link_waiter->addItem(category); + createBaseOutfitLink(category, NULL); } // Remove current COF contents. Have to do this after creating @@ -1800,7 +1827,7 @@ void LLAppearanceMgr::updateCOF(const LLUUID& category, bool append) // carried over (e.g. keeping old shape if the new outfit does not // contain one) bool keep_outfit_links = append; - purgeCategory(cof, keep_outfit_links); + purgeCategory(cof, keep_outfit_links, &all_items); gInventory.notifyObservers(); LL_DEBUGS("Avatar") << self_av_string() << "waiting for LLUpdateAppearanceOnDestroy" << LL_ENDL; @@ -1885,7 +1912,7 @@ static void remove_non_link_items(LLInventoryModel::item_array_t &items) } //a predicate for sorting inventory items by actual descriptions -bool sort_by_description(const LLInventoryItem* item1, const LLInventoryItem* item2) +bool sort_by_actual_description(const LLInventoryItem* item1, const LLInventoryItem* item2) { if (!item1 || !item2) { @@ -1893,7 +1920,7 @@ bool sort_by_description(const LLInventoryItem* item1, const LLInventoryItem* it return true; } - return item1->LLInventoryItem::getDescription() < item2->LLInventoryItem::getDescription(); + return item1->getActualDescription() < item2->getActualDescription(); } void item_array_diff(LLInventoryModel::item_array_t& full_list, @@ -1975,9 +2002,8 @@ void LLAppearanceMgr::updateAppearanceFromCOF(bool update_base_outfit_ordering) return; } - LLVOAvatar::ScopedPhaseSetter(gAgentAvatarp,"update_appearance_from_cof"); - BoolSetter setIsInUpdateAppearanceFromCOF(mIsInUpdateAppearanceFromCOF); + selfStartPhase("update_appearance_from_cof"); LL_INFOS("Avatar") << self_av_string() << "starting" << LL_ENDL; @@ -2000,7 +2026,7 @@ void LLAppearanceMgr::updateAppearanceFromCOF(bool update_base_outfit_ordering) } // DRANO really should wait for the appearance message to set this. // verify that deleting this line doesn't break anything. - gAgentAvatarp->setIsUsingServerBakes(gAgent.getRegion() && gAgent.getRegion()->getCentralBakeVersion()); + //gAgentAvatarp->setIsUsingServerBakes(gAgent.getRegion() && gAgent.getRegion()->getCentralBakeVersion()); //dumpCat(getCOF(),"COF, start"); @@ -2328,10 +2354,11 @@ bool areMatchingWearables(const LLViewerInventoryItem *a, const LLViewerInventor class LLDeferredCOFLinkObserver: public LLInventoryObserver { public: - LLDeferredCOFLinkObserver(const LLUUID& item_id, bool do_update, LLPointer<LLInventoryCallback> cb = NULL): + LLDeferredCOFLinkObserver(const LLUUID& item_id, bool do_update, LLPointer<LLInventoryCallback> cb = NULL, std::string description = ""): mItemID(item_id), mDoUpdate(do_update), - mCallback(cb) + mCallback(cb), + mDescription(description) { } @@ -2353,23 +2380,24 @@ public: private: const LLUUID mItemID; bool mDoUpdate; + std::string mDescription; LLPointer<LLInventoryCallback> mCallback; }; // BAP - note that this runs asynchronously if the item is not already loaded from inventory. // Dangerous if caller assumes link will exist after calling the function. -void LLAppearanceMgr::addCOFItemLink(const LLUUID &item_id, bool do_update, LLPointer<LLInventoryCallback> cb) +void LLAppearanceMgr::addCOFItemLink(const LLUUID &item_id, bool do_update, LLPointer<LLInventoryCallback> cb, const std::string description) { const LLInventoryItem *item = gInventory.getItem(item_id); if (!item) { - LLDeferredCOFLinkObserver *observer = new LLDeferredCOFLinkObserver(item_id, do_update, cb); + LLDeferredCOFLinkObserver *observer = new LLDeferredCOFLinkObserver(item_id, do_update, cb, description); gInventory.addObserver(observer); } else { - addCOFItemLink(item, do_update, cb); + addCOFItemLink(item, do_update, cb, description); } } @@ -2392,8 +2420,9 @@ void modified_cof_cb(const LLUUID& inv_item) } } -void LLAppearanceMgr::addCOFItemLink(const LLInventoryItem *item, bool do_update, LLPointer<LLInventoryCallback> cb) +void LLAppearanceMgr::addCOFItemLink(const LLInventoryItem *item, bool do_update, LLPointer<LLInventoryCallback> cb, const std::string description) { + std::string link_description = description; const LLViewerInventoryItem *vitem = dynamic_cast<const LLViewerInventoryItem*>(item); if (!vitem) { @@ -2457,18 +2486,48 @@ void LLAppearanceMgr::addCOFItemLink(const LLInventoryItem *item, bool do_update { cb = new LLBoostFuncInventoryCallback(modified_cof_cb); } - const std::string description = vitem->getIsLinkType() ? vitem->getDescription() : ""; + if (vitem->getIsLinkType()) + { + link_description = vitem->getActualDescription(); + } link_inventory_item( gAgent.getID(), vitem->getLinkedUUID(), getCOF(), vitem->getName(), - description, + link_description, LLAssetType::AT_LINK, cb); } return; } +LLInventoryModel::item_array_t LLAppearanceMgr::findCOFItemLinks(const LLUUID& item_id) +{ + + LLInventoryModel::item_array_t result; + const LLViewerInventoryItem *vitem = + dynamic_cast<const LLViewerInventoryItem*>(gInventory.getItem(item_id)); + + if (vitem) + { + LLInventoryModel::cat_array_t cat_array; + LLInventoryModel::item_array_t item_array; + gInventory.collectDescendents(LLAppearanceMgr::getCOF(), + cat_array, + item_array, + LLInventoryModel::EXCLUDE_TRASH); + for (S32 i=0; i<item_array.count(); i++) + { + const LLViewerInventoryItem* inv_item = item_array.get(i).get(); + if (inv_item->getLinkedUUID() == vitem->getLinkedUUID()) + { + result.put(item_array.get(i)); + } + } + } + return result; +} + void LLAppearanceMgr::removeAllClothesFromAvatar() { // Fetch worn clothes (i.e. the ones in COF). @@ -2627,7 +2686,7 @@ void LLAppearanceMgr::updateIsDirty() if (item1->getLinkedUUID() != item2->getLinkedUUID() || item1->getName() != item2->getName() || - item1->LLInventoryItem::getDescription() != item2->LLInventoryItem::getDescription()) + item1->getActualDescription() != item2->getActualDescription()) { mOutfitIsDirty = true; return; @@ -2838,8 +2897,8 @@ struct WearablesOrderComparator return true; } - const std::string& desc1 = item1->LLInventoryItem::getDescription(); - const std::string& desc2 = item2->LLInventoryItem::getDescription(); + const std::string& desc1 = item1->getActualDescription(); + const std::string& desc2 = item2->getActualDescription(); bool item1_valid = (desc1.size() == mControlSize) && (ORDER_NUMBER_SEPARATOR == desc1[0]); bool item2_valid = (desc2.size() == mControlSize) && (ORDER_NUMBER_SEPARATOR == desc2[0]); @@ -2897,7 +2956,7 @@ void LLAppearanceMgr::updateClothingOrderingInfo(LLUUID cat_id, bool update_base if (!item) continue; std::string new_order_str = build_order_string((LLWearableType::EType)type, i); - if (new_order_str == item->LLInventoryItem::getDescription()) continue; + if (new_order_str == item->getActualDescription()) continue; item->setDescription(new_order_str); item->setComplete(TRUE); @@ -2981,13 +3040,36 @@ public: // Successful completion. /* virtual */ void result(const LLSD& content) { - llinfos << "request OK" << llendl; + LL_DEBUGS("Avatar") << "content: " << ll_pretty_print_sd(content) << LL_ENDL; + if (content["success"].asBoolean()) + { + LL_DEBUGS("Avatar") << "OK" << LL_ENDL; + if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) + { + dumpContents(gAgentAvatarp->getFullname() + "_appearance_request_ok", content); + } + } + else + { + onFailure(200); + } } // Error - /*virtual*/ void error(U32 status, const std::string& reason) + /*virtual*/ void errorWithContent(U32 status, const std::string& reason, const LLSD& content) + { + llwarns << "appearance update request failed, status: " << status << " reason: " << reason << " code: " << content["code"].asInteger() << " error: \"" << content["error"].asString() << "\"" << llendl; + if (gSavedSettings.getBOOL("DebugAvatarAppearanceMessage")) + { + dumpContents(gAgentAvatarp->getFullname() + "_appearance_request_error", content); + debugCOF(content); + + } + onFailure(status); + } + + void onFailure(U32 status) { - llwarns << "appearance update request failed, status: " << status << " reason: " << reason << llendl; F32 seconds_to_wait; if (mRetryPolicy->shouldRetry(status,seconds_to_wait)) { @@ -3003,14 +3085,38 @@ public: } } + void dumpContents(const std::string outprefix, const LLSD& content) + { + std::string outfilename = get_sequential_numbered_file_name(outprefix,".xml"); + std::string fullpath = gDirUtilp->getExpandedFilename(LL_PATH_LOGS,outfilename); + std::ofstream ofs(fullpath.c_str(), std::ios_base::out); + ofs << LLSDOStreamer<LLSDXMLFormatter>(content, LLSDFormatter::OPTIONS_PRETTY); + LL_DEBUGS("Avatar") << "results saved to: " << fullpath << LL_ENDL; + } + + void debugCOF(const LLSD& content) + { + //S32 cof_version = content["cof_version"]; + //S32 cof_expected = content["expected"]; + //S32 cof_observed = content["observed"]; + } + + LLPointer<LLHTTPRetryPolicy> mRetryPolicy; }; void LLAppearanceMgr::requestServerAppearanceUpdate(LLCurl::ResponderPtr responder_ptr) { + if (gAgentAvatarp->isEditingAppearance()) + { + // don't send out appearance updates if in appearance editing mode + return; + } + if (!gAgent.getRegion()) { llwarns << "Region not set, cannot request server appearance update" << llendl; + return; } if (gAgent.getRegion()->getCentralBakeVersion()==0) { @@ -3026,7 +3132,11 @@ void LLAppearanceMgr::requestServerAppearanceUpdate(LLCurl::ResponderPtr respond LLSD body; S32 cof_version = getCOFVersion(); body["cof_version"] = cof_version; - LL_DEBUGS("Avatar") << "my_cof_version " << cof_version << llendl; + if (gSavedSettings.getBOOL("DebugForceAppearanceRequestFailure")) + { + body["cof_version"] = cof_version+1; + } + LL_DEBUGS("Avatar") << "request url " << url << " my_cof_version " << cof_version << llendl; //LLCurl::ResponderPtr responder_ptr; if (!responder_ptr.get()) @@ -3223,8 +3333,8 @@ bool LLAppearanceMgr::moveWearable(LLViewerInventoryItem* item, bool closer_to_b closer_to_body ? --it : ++it; LLViewerInventoryItem* swap_item = *it; if (!swap_item) return false; - std::string tmp = swap_item->LLInventoryItem::getDescription(); - swap_item->setDescription(item->LLInventoryItem::getDescription()); + std::string tmp = swap_item->getActualDescription(); + swap_item->setDescription(item->getActualDescription()); item->setDescription(tmp); @@ -3257,7 +3367,7 @@ void LLAppearanceMgr::sortItemsByActualDescription(LLInventoryModel::item_array_ { if (items.size() < 2) return; - std::sort(items.begin(), items.end(), sort_by_description); + std::sort(items.begin(), items.end(), sort_by_actual_description); } //#define DUMP_CAT_VERBOSE @@ -3304,7 +3414,8 @@ LLAppearanceMgr::LLAppearanceMgr(): mOutfitIsDirty(false), mOutfitLocked(false), mIsInUpdateAppearanceFromCOF(false), - mLastUpdateRequestCOFVersion(LLViewerInventoryCategory::VERSION_UNKNOWN) + mLastUpdateRequestCOFVersion(LLViewerInventoryCategory::VERSION_UNKNOWN), + mLastAppearanceUpdateCOFVersion(LLViewerInventoryCategory::VERSION_UNKNOWN) { LLOutfitObserver& outfit_observer = LLOutfitObserver::instance(); |