Improved the shutdown process some more. Systems apps are allowed to ignore the

quit request and are simply removed from the list of apps to close if this
happens. This is primarily designed for the input_server.

I also corrected the MIME type of the debug_server which was causing it to be
incorrectly killed at shutdown.

I did some other clean-up and removed the code I unintentionally submitted
yesterday.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19509 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ryan Leavengood 2006-12-14 05:15:47 +00:00
parent 9eee47669d
commit 970014a60a
3 changed files with 38 additions and 48 deletions

View File

@ -709,7 +709,7 @@ ShutdownProcess::Init(BMessage *request)
// get a list of all applications to shut down and sort them
error = fRoster->GetShutdownApps(fUserApps, fSystemApps, fBackgroundApps,
fVitalSystemApps);//, fInputServer);
fVitalSystemApps);
if (error != B_OK) {
fRoster->RemoveWatcher(this);
fRoster->SetShuttingDown(false);
@ -1274,14 +1274,6 @@ ShutdownProcess::_WorkerDoShutdown()
// sync
sync();
// notify the input server we are shutting down
/*if (fInputServer.registration_time != 0) {
// The SYSTEM_SHUTTING_DOWN message is defined in InputServerTypes.h
BMessage message(SYSTEM_SHUTTING_DOWN);
SingleMessagingTargetSet target(fInputServer.port, B_PREFERRED_TOKEN);
MessageDeliverer::Default()->DeliverMessage(&message, target);
}*/
// phase 1: terminate the user apps
_SetPhase(USER_APP_TERMINATION_PHASE);
_QuitApps(fUserApps, false);
@ -1292,13 +1284,11 @@ ShutdownProcess::_WorkerDoShutdown()
// phase 3: terminate the background apps
_SetPhase(BACKGROUND_APP_TERMINATION_PHASE);
// TODO: _QuitNonApps() and _QuitBackgroundApps() are called in reverse?
// and don't match the phase
_QuitNonApps();
_QuitBackgroundApps();
// phase 4: terminate the other processes
_SetPhase(OTHER_PROCESSES_TERMINATION_PHASE);
_QuitBackgroundApps();
_QuitNonApps();
_ScheduleTimeoutEvent(kBackgroundAppQuitTimeout, -1);
_WaitForBackgroundApps();
_KillBackgroundApps();
@ -1341,12 +1331,12 @@ ShutdownProcess::_WorkerDoShutdown()
// _QuitApps
void
ShutdownProcess::_QuitApps(AppInfoList &list, bool disableCancel)
ShutdownProcess::_QuitApps(AppInfoList &list, bool systemApps)
{
PRINT(("ShutdownProcess::_QuitApps(%s)\n",
(disableCancel ? "system" : "user")));
(systemApps ? "system" : "user")));
if (disableCancel) {
if (systemApps) {
_SetShutdownWindowCancelButtonEnabled(false);
// check one last time for abort events
@ -1384,7 +1374,7 @@ ShutdownProcess::_QuitApps(AppInfoList &list, bool disableCancel)
if (error != B_OK)
throw_error(error);
if (!disableCancel && event == ABORT_EVENT) {
if (!systemApps && event == ABORT_EVENT) {
PRINT(("ShutdownProcess::_QuitApps(): shutdown cancelled by "
"team %ld (-1 => user)\n", team));
@ -1413,8 +1403,6 @@ ShutdownProcess::_QuitApps(AppInfoList &list, bool disableCancel)
return;
}
PRINT(("****RJL: Asking %s to quit\n", appName));
// set window text
char buffer[1024];
snprintf(buffer, sizeof(buffer), "Asking \"%s\" to quit.", appName);
@ -1448,10 +1436,10 @@ ShutdownProcess::_QuitApps(AppInfoList &list, bool disableCancel)
break;
if (event == ABORT_EVENT) {
if (disableCancel) {
if (systemApps) {
// If the app requests aborting the shutdown, we don't need
// to wait any longer. It has processed the request and
// won't quit by itself. We'll have to kill it.
// won't quit by itself. We ignore this for system apps.
if (eventTeam == team)
break;
} else {
@ -1474,7 +1462,17 @@ ShutdownProcess::_QuitApps(AppInfoList &list, bool disableCancel)
} else {
// the app is either blocking on a model alert or blocks for another
// reason
_QuitBlockingApp(list, team, appName, !disableCancel);
if (!systemApps)
_QuitBlockingApp(list, team, appName, true);
else {
// This is a system app: remove it from the list
BAutolock _(fWorkerLock);
if (RosterAppInfo *info = list.InfoFor(team)) {
list.RemoveInfo(info);
delete info;
}
}
}
}
}

View File

@ -70,7 +70,7 @@ private:
status_t _Worker();
void _WorkerDoShutdown();
void _QuitApps(AppInfoList &list, bool disableCancel);
void _QuitApps(AppInfoList &list, bool systemApps);
void _QuitBackgroundApps();
void _WaitForBackgroundApps();
void _KillBackgroundApps();
@ -97,7 +97,6 @@ private:
AppInfoList fSystemApps;
AppInfoList fUserApps;
AppInfoList fBackgroundApps;
//RosterAppInfo fInputServer;
TimeoutEvent *fTimeoutEvent;
InternalEventList *fInternalEvents;
sem_id fInternalEventSemaphore;

View File

@ -177,7 +177,6 @@ PRINT(("full registration: %d\n", fullReg));
// check the parameters
team_id otherTeam = -1;
uint32 token = 0;
RosterAppInfo *otherInfo = NULL;
uint32 launchFlags = flags & B_LAUNCH_MASK;
@ -188,12 +187,13 @@ PRINT(("full registration: %d\n", fullReg));
PRINT(("flags: %lx\n", flags));
PRINT(("ref: %ld, %lld, %s\n", ref.device, ref.directory, ref.name));
// check single/exclusive launchers
RosterAppInfo *info = NULL;
if ((launchFlags == B_SINGLE_LAUNCH
|| launchFlags == B_EXCLUSIVE_LAUNCH)
&& (((otherInfo = fRegisteredApps.InfoFor(&ref)))
|| ((otherInfo = fEarlyPreRegisteredApps.InfoFor(&ref))))) {
&& (((info = fRegisteredApps.InfoFor(&ref)))
|| ((info = fEarlyPreRegisteredApps.InfoFor(&ref))))) {
SET_ERROR(error, B_ALREADY_RUNNING);
otherTeam = otherInfo->team;
otherTeam = info->team;
}
} else
SET_ERROR(error, B_ENTRY_NOT_FOUND);
@ -202,12 +202,13 @@ PRINT(("ref: %ld, %lld, %s\n", ref.device, ref.directory, ref.name));
// signature
if (error == B_OK && signature) {
// check exclusive launchers
RosterAppInfo *info = NULL;
if (launchFlags == B_EXCLUSIVE_LAUNCH
&& (((otherInfo = fRegisteredApps.InfoFor(signature)))
|| ((otherInfo = fEarlyPreRegisteredApps.InfoFor(signature))))) {
&& (((info = fRegisteredApps.InfoFor(signature)))
|| ((info = fEarlyPreRegisteredApps.InfoFor(signature))))) {
SET_ERROR(error, B_ALREADY_RUNNING);
otherTeam = otherInfo->team;
token = otherInfo->token;
otherTeam = info->team;
token = info->token;
}
}
@ -276,12 +277,6 @@ PRINT(("added to early pre-regs, token: %lu\n", token));
request->SendReply(&reply);
}
if (otherInfo) {
// Activate the other app
printf("Trying to activate other app with team id: %d\n", otherInfo->team);
ActivateApp(otherInfo);
}
FUNCTION_END();
}
@ -1336,7 +1331,6 @@ TRoster::GetShutdownApps(AppInfoList &userApps, AppInfoList &systemApps,
// * ourself
// * kernel team
// * app server
// * input server
// * debug server
// ourself
@ -1355,16 +1349,9 @@ TRoster::GetShutdownApps(AppInfoList &userApps, AppInfoList &systemApps,
vitalSystemApps.insert(portInfo.team);
}
// input server
RosterAppInfo *info;
/* = fRegisteredApps.InfoFor("application/x-vnd.Be-input_server");
if (info) {
inputServer = *info;
vitalSystemApps.insert(info->team);
}*/
// debug server
info = fRegisteredApps.InfoFor("application/x-vnd.haiku-debug-server");
RosterAppInfo *info =
fRegisteredApps.InfoFor("application/x-vnd.haiku-debug_server");
if (info)
vitalSystemApps.insert(info->team);
@ -1396,6 +1383,12 @@ TRoster::GetShutdownApps(AppInfoList &userApps, AppInfoList &systemApps,
break;
}
// Special case, we add the input server to vital apps here so it is
// not excluded in the lists above
info = fRegisteredApps.InfoFor("application/x-vnd.Be-input_server");
if (info)
vitalSystemApps.insert(info->team);
// clean up on error
if (error != B_OK) {
userApps.MakeEmpty(true);