Added method CheckSanity() which checks whether the (pre-)registered apps are still alive and removes obsolete entries.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1518 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2002-10-14 21:21:06 +00:00
parent 463322c288
commit b48b6fb598
2 changed files with 41 additions and 0 deletions
+39
View File
@@ -61,6 +61,9 @@
pre-registered applications.
*/
//! The maximal period of time an app may be early pre-registered (60 s).
const bigtime_t kMaximalEarlyPreRegistrationPeriod = 60000000LL;
// constructor
/*! \brief Creates a new roster.
@@ -732,6 +735,42 @@ TRoster::ActivateApp(RosterAppInfo *info)
}
}
// CheckSanity
/*! \brief Checks whether the (pre-)registered applications are still running.
This is necessary, since killed applications don't unregister properly.
*/
void
TRoster::CheckSanity()
{
// not early (pre-)registered applications
AppInfoList obsoleteApps;
for (AppInfoList::Iterator it = fRegisteredApps.It(); it.IsValid(); ++it) {
team_info teamInfo;
if (get_team_info((*it)->team, &teamInfo) != B_OK)
obsoleteApps.AddInfo(*it);
}
// remove the apps
for (AppInfoList::Iterator it = obsoleteApps.It(); it.IsValid(); ++it) {
RemoveApp(*it);
delete *it;
}
// early pre-registered applications
obsoleteApps.MakeEmpty();
bigtime_t timeLimit = system_time() - kMaximalEarlyPreRegistrationPeriod;
for (AppInfoList::Iterator it = fEarlyPreRegisteredApps.It();
it.IsValid();
++it) {
if ((*it)->registration_time < timeLimit)
obsoleteApps.AddInfo(*it);
}
// remove the apps
for (AppInfoList::Iterator it = obsoleteApps.It(); it.IsValid(); ++it) {
fEarlyPreRegisteredApps.RemoveInfo(*it);
delete *it;
}
}
// _AppAdded
/*! \brief Hook method invoked, when an application has been added.
+2
View File
@@ -69,6 +69,8 @@ public:
void RemoveApp(RosterAppInfo *info);
void ActivateApp(RosterAppInfo *info);
void CheckSanity();
private:
// hook functions
void _AppAdded(RosterAppInfo *info);