Added AIFetchInventoryFolder and more.

Added a new statemachine AIFetchInventoryFolder, which can be used
to fetch the contents of a folder by name or UUID.

Also added AIEvent (and one event,
AIEvent::LLInventoryModel_mIsAgentInvUsable_true, which is needed
for AIFetchInventoryFolder).

Fixed LLInventoryModel::sBackgroundFetchActive to correctly reflect
whether or not LLInventoryModel::backgroundFetch is added to
gIdleCallbacks.

Avoid duplicated entries in sFetchQueue.

Reset sFullFetchStarted in LLInventoryModel::stopBackgroundFetch to
allow for a renewed full fetch when some single-folder fetch stops it.

Added AIStateMachine::mQueued to make calling 'cont()' more robust:
calling cont() / idle() / cont() on a row would otherwise add a
statemachine twice to the active list, which would cause a crash
when it's killed.
This commit is contained in:
Aleric Inglewood
2011-05-22 22:01:11 +02:00
parent e1fb1fa6b7
commit 13560e292e
12 changed files with 603 additions and 11 deletions

View File

@@ -132,6 +132,8 @@ void AIStateMachine::cont(void)
DoutEntering(dc::statemachine, "AIStateMachine::cont() [" << (void*)this << "]");
llassert(mIdle);
mIdle = false;
if (mQueued)
return;
AIWriteAccess<cscm_type> cscm_w(continued_statemachines_and_calling_mainloop);
cscm_w->continued_statemachines.push_back(this);
if (!cscm_w->calling_mainloop)
@@ -140,6 +142,7 @@ void AIStateMachine::cont(void)
cscm_w->calling_mainloop = true;
gIdleCallbacks.addFunction(&AIStateMachine::mainloop);
}
mQueued = true;
}
void AIStateMachine::set_state(state_type state)
@@ -214,6 +217,12 @@ void AIStateMachine::kill(void)
{
// Should only be called from finish().
llassert(mIdle && (mState == bs_initialize || mState == bs_finish));
if (mState == bs_initialize)
{
// Bump the statemachine onto the active statemachine list, or else it won't be deleted.
cont();
idle();
}
mState = bs_killed;
}
@@ -288,6 +297,7 @@ void AIStateMachine::mainloop(void*)
nonempty = true;
active_statemachines.push_back(QueueElement(*iter));
Dout(dc::statemachine, "Adding " << (void*)*iter << " to active_statemachines");
(*iter)->mQueued = false;
}
if (nonempty)
AIWriteAccess<cscm_type>(cscm_r)->continued_statemachines.clear();