summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Kleshchev <andreykproductengine@lindenlab.com>2023-04-11 01:33:24 +0300
committerAndrey Kleshchev <andreykproductengine@lindenlab.com>2023-04-11 01:58:28 +0300
commit69e3b5fb4014ef900b129ebde49325f1b074e773 (patch)
treef48beae454d6dfd8734f068b79a495f016b54d54
parent4ce1e68ccb3be42b33cf2dcb58ffb6e78e382016 (diff)
SL-19533 Orphans plus additional logging
-rw-r--r--indra/newview/llaisapi.cpp88
-rw-r--r--indra/newview/llaisapi.h3
-rw-r--r--indra/newview/llinventorymodelbackgroundfetch.cpp17
3 files changed, 100 insertions, 8 deletions
diff --git a/indra/newview/llaisapi.cpp b/indra/newview/llaisapi.cpp
index f869f1652b..1efba0db7a 100644
--- a/indra/newview/llaisapi.cpp
+++ b/indra/newview/llaisapi.cpp
@@ -535,6 +535,35 @@ void AISAPI::FetchCategoryCategories(const LLUUID &catId, ITEM_TYPE type, bool r
}
/*static*/
+void AISAPI::FetchOrphans(completion_t callback)
+{
+ std::string cap = getInvCap();
+ if (cap.empty())
+ {
+ LL_WARNS("Inventory") << "Inventory cap not found!" << LL_ENDL;
+ return;
+ }
+ std::string url = cap + std::string("/orphans");
+
+ invokationFn_t getFn = boost::bind(
+ // Humans ignore next line. It is just a cast to specify which LLCoreHttpUtil::HttpCoroutineAdapter routine overload.
+ static_cast<LLSD(LLCoreHttpUtil::HttpCoroutineAdapter::*)(LLCore::HttpRequest::ptr_t , const std::string& , LLCore::HttpOptions::ptr_t , LLCore::HttpHeaders::ptr_t)>
+ //----
+ // _1 -> httpAdapter
+ // _2 -> httpRequest
+ // _3 -> url
+ // _4 -> body
+ // _5 -> httpOptions
+ // _6 -> httpHeaders
+ (&LLCoreHttpUtil::HttpCoroutineAdapter::getAndSuspend) , _1 , _2 , _3 , _5 , _6);
+
+ LLCoprocedureManager::CoProcedure_t proc(boost::bind(&AISAPI::InvokeAISCommandCoro ,
+ _1 , getFn , url , LLUUID::null , LLSD() , callback , FETCHORPHANS));
+
+ EnqueueAISCommand("FetchOrphans" , proc);
+}
+
+/*static*/
void AISAPI::EnqueueAISCommand(const std::string &procName, LLCoprocedureManager::CoProcedure_t proc)
{
LLCoprocedureManager &inst = LLCoprocedureManager::instance();
@@ -595,7 +624,8 @@ void AISAPI::onUpdateReceived(const std::string& context, const LLSD& update, CO
}
bool is_fetch = (type == FETCHITEM)
|| (type == FETCHCATEGORYCHILDREN)
- || (type == FETCHCATEGORYCATEGORIES);
+ || (type == FETCHCATEGORYCATEGORIES)
+ || (type == FETCHORPHANS);
// parse update llsd into stuff to do or parse received items.
S32 depth = 0;
if (is_fetch && request_body.has("depth"))
@@ -620,9 +650,30 @@ void AISAPI::InvokeAISCommandCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t ht
LL_DEBUGS("Inventory") << "url: " << url << LL_ENDL;
- LLSD result = invoke(httpAdapter, httpRequest, url, body, httpOptions, httpHeaders);
- LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
- LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
+ LLSD result;
+ LLSD httpResults;
+ LLCore::HttpStatus status;
+
+ if (debugLoggingEnabled("AIS3"))
+ {
+ LLTimer ais_timer;
+ ais_timer.start();
+ result = invoke(httpAdapter , httpRequest , url , body , httpOptions , httpHeaders);
+ httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
+ status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
+ F32MillisecondsImplicit elapsed_time = ais_timer.getElapsedTimeF32();
+ LL_DEBUGS("AIS3") << "Request type: " << (S32)type
+ << " \nRequest url: " << url
+ << " \nRequest target: " << targetId
+ << " \nElapsed time: " << elapsed_time
+ << " \nstatus: " << status.toULong() << LL_ENDL;
+ }
+ else
+ {
+ result = invoke(httpAdapter , httpRequest , url , body , httpOptions , httpHeaders);
+ httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
+ status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
+ }
if (!status || !result.isMap())
{
@@ -756,6 +807,7 @@ void AISUpdate::clearParseResults()
mCatDescendentsKnown.clear();
mCatVersionsUpdated.clear();
mItemsCreated.clear();
+ mItemsLost.clear();
mItemsUpdated.clear();
mCategoriesCreated.clear();
mCategoriesUpdated.clear();
@@ -891,6 +943,11 @@ void AISUpdate::parseItem(const LLSD& item_map)
mItemsCreated[item_id] = new_item;
mCatDescendentDeltas[new_item->getParentUUID()];
new_item->setComplete(true);
+
+ if (new_item->getParentUUID().isNull())
+ {
+ mItemsLost[item_id] = new_item;
+ }
}
else if (curr_item)
{
@@ -940,6 +997,11 @@ void AISUpdate::parseLink(const LLSD& link_map)
mItemsCreated[item_id] = new_link;
mCatDescendentDeltas[parent_id];
new_link->setComplete(true);
+
+ if (new_link->getParentUUID().isNull())
+ {
+ mItemsLost[item_id] = new_link;
+ }
}
else if (curr_link)
{
@@ -1299,6 +1361,24 @@ void AISUpdate::doUpdate()
}
}
+ // LOST ITEMS
+ if (!mItemsLost.empty())
+ {
+ LL_INFOS("Inventory") << "Received " << (S32)mItemsLost.size() << " items without a parent" << LL_ENDL;
+ const LLUUID lost_uuid(gInventory.findCategoryUUIDForType(LLFolderType::FT_LOST_AND_FOUND));
+ if (lost_uuid.notNull())
+ {
+ for (deferred_item_map_t::const_iterator lost_it = mItemsLost.begin();
+ lost_it != mItemsLost.end(); ++lost_it)
+ {
+ LLPointer<LLViewerInventoryItem> new_item = lost_it->second;
+
+ new_item->setParent(lost_uuid);
+ new_item->updateParentOnServer(FALSE);
+ }
+ }
+ }
+
// CREATE ITEMS
for (deferred_item_map_t::const_iterator create_it = mItemsCreated.begin();
create_it != mItemsCreated.end(); ++create_it)
diff --git a/indra/newview/llaisapi.h b/indra/newview/llaisapi.h
index d083004195..4e1c6e5a7d 100644
--- a/indra/newview/llaisapi.h
+++ b/indra/newview/llaisapi.h
@@ -59,6 +59,7 @@ public:
static void FetchCategoryChildren(const LLUUID &catId, ITEM_TYPE type = AISAPI::ITEM_TYPE::INVENTORY, bool recursive = false, completion_t callback = completion_t(), S32 depth = 0);
static void FetchCategoryChildren(const std::string &identifier, bool recursive = false, completion_t callback = completion_t(), S32 depth = 0);
static void FetchCategoryCategories(const LLUUID &catId, ITEM_TYPE type = AISAPI::ITEM_TYPE::INVENTORY, bool recursive = false, completion_t callback = completion_t(), S32 depth = 0);
+ static void FetchOrphans(completion_t callback = completion_t() );
static void CopyLibraryCategory(const LLUUID& sourceId, const LLUUID& destId, bool copySubfolders, completion_t callback = completion_t());
private:
@@ -75,6 +76,7 @@ private:
FETCHITEM,
FETCHCATEGORYCHILDREN,
FETCHCATEGORYCATEGORIES,
+ FETCHORPHANS,
} COMMAND_TYPE;
static const std::string INVENTORY_CAP_NAME;
@@ -127,6 +129,7 @@ private:
typedef std::map<LLUUID,LLPointer<LLViewerInventoryItem> > deferred_item_map_t;
deferred_item_map_t mItemsCreated;
+ deferred_item_map_t mItemsLost;
deferred_item_map_t mItemsUpdated;
typedef std::map<LLUUID,LLPointer<LLViewerInventoryCategory> > deferred_category_map_t;
deferred_category_map_t mCategoriesCreated;
diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp
index e988f949e2..35b9442966 100644
--- a/indra/newview/llinventorymodelbackgroundfetch.cpp
+++ b/indra/newview/llinventorymodelbackgroundfetch.cpp
@@ -461,10 +461,13 @@ void LLInventoryModelBackgroundFetch::incrFetchFolderCount(S32 fetching)
void ais_simple_folder_callback(const LLUUID& inv_id)
{
LLInventoryModelBackgroundFetch::instance().incrFetchFolderCount(-1);
- LLViewerInventoryCategory * cat(gInventory.getCategory(inv_id));
- if (cat)
+ if (inv_id.notNull()) // null normally means a failure, but is an expected response for orphans
{
- cat->setFetching(LLViewerInventoryCategory::FETCH_NONE);
+ LLViewerInventoryCategory* cat(gInventory.getCategory(inv_id));
+ if (cat)
+ {
+ cat->setFetching(LLViewerInventoryCategory::FETCH_NONE);
+ }
}
}
@@ -580,6 +583,11 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis()
mFetchItemQueue.pop_front();
curent_time = LLTimer::getTotalSeconds();
}
+
+ LL_DEBUGS(LOG_INV , "AIS3") << "Total active fetches: " << mFetchCount
+ << ", scheduled fodler fetches: " << (S32)mFetchFolderQueue.size()
+ << ", scheduled item fetches: " << (S32)mFetchItemQueue.size()
+ << LL_ENDL;
if (isFolderFetchProcessingComplete() && mFolderFetchActive)
{
@@ -600,7 +608,8 @@ void LLInventoryModelBackgroundFetch::bulkFetchViaAis(const FetchQueueInfo& fetc
if (cat_id.isNull())
{
// Lost and found
- AISAPI::FetchCategoryChildren("lstndfnd", true, ais_simple_folder_callback);
+ // Should it actually be recursive?
+ AISAPI::FetchOrphans(ais_simple_folder_callback);
incrFetchFolderCount(1);
}
else