summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoren Shih <seraph@lindenlab.com>2010-05-04 16:53:18 -0400
committerLoren Shih <seraph@lindenlab.com>2010-05-04 16:53:18 -0400
commit9ccb83520758ff8967ad7e32594074266504d4c2 (patch)
tree1966339ceed7152e288e21bc064bf247468a2bff
parent14532f0aa01524b9062583081f8902c2aaf7abf1 (diff)
DEV-49557 : FIXED : Attachments can show up hanging in space
Fix for logic about when all folders have been fetched. Some infrastructure cleanup.
-rw-r--r--indra/newview/llinventorymodelbackgroundfetch.cpp102
-rw-r--r--indra/newview/llinventorymodelbackgroundfetch.h19
2 files changed, 63 insertions, 58 deletions
diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp
index 7d0cab0177..0ff6ab2644 100644
--- a/indra/newview/llinventorymodelbackgroundfetch.cpp
+++ b/indra/newview/llinventorymodelbackgroundfetch.cpp
@@ -46,23 +46,11 @@
const F32 MAX_TIME_FOR_SINGLE_FETCH = 10.f;
const S32 MAX_FETCH_RETRIES = 10;
-struct FetchQueueInfo
-{
- FetchQueueInfo(const LLUUID& id, BOOL recursive) :
- mCatUUID(id), mRecursive(recursive)
- {
- }
- LLUUID mCatUUID;
- BOOL mRecursive;
-};
-typedef std::deque<FetchQueueInfo> fetch_queue_t;
-fetch_queue_t sFetchQueue;
-
LLInventoryModelBackgroundFetch::LLInventoryModelBackgroundFetch() :
mBackgroundFetchActive(FALSE),
mAllFoldersFetched(FALSE),
- mInventoryFetchStarted(FALSE),
- mLibraryFetchStarted(FALSE),
+ mRecursiveInventoryFetchStarted(FALSE),
+ mRecursiveLibraryFetchStarted(FALSE),
mNumFetchRetries(0),
mMinTimeBetweenFetches(0.3f),
mMaxTimeBetweenFetches(10.f),
@@ -77,12 +65,12 @@ LLInventoryModelBackgroundFetch::~LLInventoryModelBackgroundFetch()
bool LLInventoryModelBackgroundFetch::isBulkFetchProcessingComplete()
{
- return sFetchQueue.empty() && mBulkFetchCount<=0;
+ return mFetchQueue.empty() && mBulkFetchCount<=0;
}
bool LLInventoryModelBackgroundFetch::libraryFetchStarted()
{
- return mLibraryFetchStarted;
+ return mRecursiveLibraryFetchStarted;
}
bool LLInventoryModelBackgroundFetch::libraryFetchCompleted()
@@ -97,7 +85,7 @@ bool LLInventoryModelBackgroundFetch::libraryFetchInProgress()
bool LLInventoryModelBackgroundFetch::inventoryFetchStarted()
{
- return mInventoryFetchStarted;
+ return mRecursiveInventoryFetchStarted;
}
bool LLInventoryModelBackgroundFetch::inventoryFetchCompleted()
@@ -127,34 +115,34 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& cat_id, BOOL recursive
mBackgroundFetchActive = TRUE;
if (cat_id.isNull())
{
- if (!mInventoryFetchStarted)
+ if (!mRecursiveInventoryFetchStarted)
{
- mInventoryFetchStarted = TRUE;
- sFetchQueue.push_back(FetchQueueInfo(gInventory.getRootFolderID(), recursive));
+ mRecursiveInventoryFetchStarted |= recursive;
+ mFetchQueue.push_back(FetchQueueInfo(gInventory.getRootFolderID(), recursive));
gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL);
}
- if (!mLibraryFetchStarted)
+ if (!mRecursiveLibraryFetchStarted)
{
- mLibraryFetchStarted = TRUE;
- sFetchQueue.push_back(FetchQueueInfo(gInventory.getLibraryRootFolderID(), recursive));
+ mRecursiveLibraryFetchStarted |= recursive;
+ mFetchQueue.push_back(FetchQueueInfo(gInventory.getLibraryRootFolderID(), recursive));
gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL);
}
}
else
{
// specific folder requests go to front of queue
- if (sFetchQueue.empty() || sFetchQueue.front().mCatUUID != cat_id)
+ if (mFetchQueue.empty() || mFetchQueue.front().mCatUUID != cat_id)
{
- sFetchQueue.push_front(FetchQueueInfo(cat_id, recursive));
+ mFetchQueue.push_front(FetchQueueInfo(cat_id, recursive));
gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL);
}
if (cat_id == gInventory.getLibraryRootFolderID())
{
- mLibraryFetchStarted = TRUE;
+ mRecursiveLibraryFetchStarted |= recursive;
}
if (cat_id == gInventory.getRootFolderID())
{
- mInventoryFetchStarted = TRUE;
+ mRecursiveInventoryFetchStarted |= recursive;
}
}
}
@@ -163,7 +151,7 @@ void LLInventoryModelBackgroundFetch::start(const LLUUID& cat_id, BOOL recursive
void LLInventoryModelBackgroundFetch::findLostItems()
{
mBackgroundFetchActive = TRUE;
- sFetchQueue.push_back(FetchQueueInfo(LLUUID::null, TRUE));
+ mFetchQueue.push_back(FetchQueueInfo(LLUUID::null, TRUE));
gIdleCallbacks.addFunction(&LLInventoryModelBackgroundFetch::backgroundFetchCB, NULL);
}
@@ -180,8 +168,8 @@ void LLInventoryModelBackgroundFetch::stopBackgroundFetch()
void LLInventoryModelBackgroundFetch::setAllFoldersFetched()
{
- if (mInventoryFetchStarted &&
- mLibraryFetchStarted)
+ if (mRecursiveInventoryFetchStarted &&
+ mRecursiveLibraryFetchStarted)
{
mAllFoldersFetched = TRUE;
}
@@ -207,7 +195,7 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
//DEPRECATED OLD CODE FOLLOWS.
// no more categories to fetch, stop fetch process
- if (sFetchQueue.empty())
+ if (mFetchQueue.empty())
{
llinfos << "Inventory fetch completed" << llendl;
@@ -229,7 +217,7 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
while(1)
{
- if (sFetchQueue.empty())
+ if (mFetchQueue.empty())
{
break;
}
@@ -240,13 +228,13 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
break;
}
- const FetchQueueInfo info = sFetchQueue.front();
+ const FetchQueueInfo info = mFetchQueue.front();
LLViewerInventoryCategory* cat = gInventory.getCategory(info.mCatUUID);
// category has been deleted, remove from queue.
if (!cat)
{
- sFetchQueue.pop_front();
+ mFetchQueue.pop_front();
continue;
}
@@ -272,7 +260,7 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
else if (gInventory.isCategoryComplete(info.mCatUUID))
{
// finished with this category, remove from queue
- sFetchQueue.pop_front();
+ mFetchQueue.pop_front();
// add all children to queue
LLInventoryModel::cat_array_t* categories;
@@ -282,7 +270,7 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
it != categories->end();
++it)
{
- sFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(),info.mRecursive));
+ mFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(),info.mRecursive));
}
// we received a response in less than the fast time
@@ -301,12 +289,12 @@ void LLInventoryModelBackgroundFetch::backgroundFetch()
{
// received first packet, but our num descendants does not match db's num descendants
// so try again later
- sFetchQueue.pop_front();
+ mFetchQueue.pop_front();
if (mNumFetchRetries++ < MAX_FETCH_RETRIES)
{
// push on back of queue
- sFetchQueue.push_back(info);
+ mFetchQueue.push_back(info);
}
mTimelyFetchPending = FALSE;
mFetchTimer.reset();
@@ -347,8 +335,9 @@ private:
};
//If we get back a normal response, handle it here
-void LLInventoryModelFetchDescendentsResponder::result(const LLSD& content)
+void LLInventoryModelFetchDescendentsResponder::result(const LLSD& content)
{
+ LLInventoryModelBackgroundFetch *fetcher = LLInventoryModelBackgroundFetch::getInstance();
if (content.has("folders"))
{
@@ -418,7 +407,7 @@ void LLInventoryModelFetchDescendentsResponder::result(const LLSD& content)
if (recursive)
{
- sFetchQueue.push_back(FetchQueueInfo(tcategory->getUUID(), recursive));
+ fetcher->mFetchQueue.push_back(LLInventoryModelBackgroundFetch::FetchQueueInfo(tcategory->getUUID(), recursive));
}
else if ( !gInventory.isCategoryComplete(tcategory->getUUID()) )
{
@@ -463,12 +452,12 @@ void LLInventoryModelFetchDescendentsResponder::result(const LLSD& content)
}
}
- LLInventoryModelBackgroundFetch::instance().incrBulkFetch(-1);
+ fetcher->incrBulkFetch(-1);
- if (LLInventoryModelBackgroundFetch::instance().isBulkFetchProcessingComplete())
+ if (fetcher->isBulkFetchProcessingComplete())
{
llinfos << "Inventory fetch completed" << llendl;
- LLInventoryModelBackgroundFetch::instance().setAllFoldersFetched();
+ fetcher->setAllFoldersFetched();
}
gInventory.notifyObservers("fetchDescendents");
@@ -477,12 +466,14 @@ void LLInventoryModelFetchDescendentsResponder::result(const LLSD& content)
//If we get back an error (not found, etc...), handle it here
void LLInventoryModelFetchDescendentsResponder::error(U32 status, const std::string& reason)
{
+ LLInventoryModelBackgroundFetch *fetcher = LLInventoryModelBackgroundFetch::getInstance();
+
llinfos << "LLInventoryModelFetchDescendentsResponder::error "
<< status << ": " << reason << llendl;
- LLInventoryModelBackgroundFetch::instance().incrBulkFetch(-1);
+ fetcher->incrBulkFetch(-1);
- if (status==499) //timed out. Let's be awesome!
+ if (status==499) // Timed out.
{
for(LLSD::array_const_iterator folder_it = mRequestSD["folders"].beginArray();
folder_it != mRequestSD["folders"].endArray();
@@ -491,14 +482,14 @@ void LLInventoryModelFetchDescendentsResponder::error(U32 status, const std::str
LLSD folder_sd = *folder_it;
LLUUID folder_id = folder_sd["folder_id"];
const BOOL recursive = getIsRecursive(folder_id);
- sFetchQueue.push_front(FetchQueueInfo(folder_id, recursive));
+ fetcher->mFetchQueue.push_front(LLInventoryModelBackgroundFetch::FetchQueueInfo(folder_id, recursive));
}
}
else
{
- if (LLInventoryModelBackgroundFetch::instance().isBulkFetchProcessingComplete())
+ if (fetcher->isBulkFetchProcessingComplete())
{
- LLInventoryModelBackgroundFetch::instance().setAllFoldersFetched();
+ fetcher->setAllFoldersFetched();
}
}
gInventory.notifyObservers("fetchDescendents");
@@ -513,7 +504,7 @@ BOOL LLInventoryModelFetchDescendentsResponder::getIsRecursive(const LLUUID& cat
void LLInventoryModelBackgroundFetch::bulkFetch(std::string url)
{
//Background fetch is called from gIdleCallbacks in a loop until background fetch is stopped.
- //If there are items in sFetchQueue, we want to check the time since the last bulkFetch was
+ //If there are items in mFetchQueue, we want to check the time since the last bulkFetch was
//sent. If it exceeds our retry time, go ahead and fire off another batch.
//Stopbackgroundfetch will be run from the Responder instead of here.
@@ -540,9 +531,10 @@ void LLInventoryModelBackgroundFetch::bulkFetch(std::string url)
LLSD body;
LLSD body_lib;
- while (!(sFetchQueue.empty()) && (folder_count < max_batch_size))
+
+ while (!(mFetchQueue.empty()) && (folder_count < max_batch_size))
{
- const FetchQueueInfo& fetch_info = sFetchQueue.front();
+ const FetchQueueInfo& fetch_info = mFetchQueue.front();
const LLUUID &cat_id = fetch_info.mCatUUID;
if (cat_id.isNull()) //DEV-17797
{
@@ -586,7 +578,7 @@ void LLInventoryModelBackgroundFetch::bulkFetch(std::string url)
it != categories->end();
++it)
{
- sFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mRecursive));
+ mFetchQueue.push_back(FetchQueueInfo((*it)->getUUID(), fetch_info.mRecursive));
}
}
}
@@ -594,7 +586,7 @@ void LLInventoryModelBackgroundFetch::bulkFetch(std::string url)
if (fetch_info.mRecursive)
recursive_cats.push_back(cat_id);
- sFetchQueue.pop_front();
+ mFetchQueue.pop_front();
}
if (folder_count > 0)
@@ -622,8 +614,8 @@ void LLInventoryModelBackgroundFetch::bulkFetch(std::string url)
bool LLInventoryModelBackgroundFetch::fetchQueueContainsNoDescendentsOf(const LLUUID& cat_id) const
{
- for (fetch_queue_t::const_iterator it = sFetchQueue.begin();
- it != sFetchQueue.end(); ++it)
+ for (fetch_queue_t::const_iterator it = mFetchQueue.begin();
+ it != mFetchQueue.end(); ++it)
{
const LLUUID& fetch_id = (*it).mCatUUID;
if (gInventory.isObjectDescendentOf(fetch_id, cat_id))
diff --git a/indra/newview/llinventorymodelbackgroundfetch.h b/indra/newview/llinventorymodelbackgroundfetch.h
index 8ffd1775c6..c1e37eda8f 100644
--- a/indra/newview/llinventorymodelbackgroundfetch.h
+++ b/indra/newview/llinventorymodelbackgroundfetch.h
@@ -68,6 +68,8 @@ class LLInventoryCollectFunctor;
class LLInventoryModelBackgroundFetch : public LLSingleton<LLInventoryModelBackgroundFetch>
{
+ friend class LLInventoryModelFetchDescendentsResponder;
+
public:
LLInventoryModelBackgroundFetch();
~LLInventoryModelBackgroundFetch();
@@ -98,12 +100,20 @@ public:
static void backgroundFetchCB(void*); // background fetch idle function
void backgroundFetch();
+ struct FetchQueueInfo
+ {
+ FetchQueueInfo(const LLUUID& id, BOOL recursive) :
+ mCatUUID(id), mRecursive(recursive)
+ {
+ }
+ LLUUID mCatUUID;
+ BOOL mRecursive;
+ };
protected:
bool fetchQueueContainsNoDescendentsOf(const LLUUID& cat_id) const;
-
private:
- BOOL mInventoryFetchStarted;
- BOOL mLibraryFetchStarted;
+ BOOL mRecursiveInventoryFetchStarted;
+ BOOL mRecursiveLibraryFetchStarted;
BOOL mAllFoldersFetched;
// completing the fetch once per session should be sufficient
@@ -115,6 +125,9 @@ private:
LLFrameTimer mFetchTimer;
F32 mMinTimeBetweenFetches;
F32 mMaxTimeBetweenFetches;
+
+ typedef std::deque<FetchQueueInfo> fetch_queue_t;
+ fetch_queue_t mFetchQueue;
};
#endif // LL_LLINVENTORYMODELBACKGROUNDFETCH_H