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 // get a list of all applications to shut down and sort them
error = fRoster->GetShutdownApps(fUserApps, fSystemApps, fBackgroundApps, error = fRoster->GetShutdownApps(fUserApps, fSystemApps, fBackgroundApps,
fVitalSystemApps);//, fInputServer); fVitalSystemApps);
if (error != B_OK) { if (error != B_OK) {
fRoster->RemoveWatcher(this); fRoster->RemoveWatcher(this);
fRoster->SetShuttingDown(false); fRoster->SetShuttingDown(false);
@ -1274,14 +1274,6 @@ ShutdownProcess::_WorkerDoShutdown()
// sync // sync
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 // phase 1: terminate the user apps
_SetPhase(USER_APP_TERMINATION_PHASE); _SetPhase(USER_APP_TERMINATION_PHASE);
_QuitApps(fUserApps, false); _QuitApps(fUserApps, false);
@ -1292,13 +1284,11 @@ ShutdownProcess::_WorkerDoShutdown()
// phase 3: terminate the background apps // phase 3: terminate the background apps
_SetPhase(BACKGROUND_APP_TERMINATION_PHASE); _SetPhase(BACKGROUND_APP_TERMINATION_PHASE);
// TODO: _QuitNonApps() and _QuitBackgroundApps() are called in reverse? _QuitBackgroundApps();
// and don't match the phase
_QuitNonApps();
// phase 4: terminate the other processes // phase 4: terminate the other processes
_SetPhase(OTHER_PROCESSES_TERMINATION_PHASE); _SetPhase(OTHER_PROCESSES_TERMINATION_PHASE);
_QuitBackgroundApps(); _QuitNonApps();
_ScheduleTimeoutEvent(kBackgroundAppQuitTimeout, -1); _ScheduleTimeoutEvent(kBackgroundAppQuitTimeout, -1);
_WaitForBackgroundApps(); _WaitForBackgroundApps();
_KillBackgroundApps(); _KillBackgroundApps();
@ -1341,12 +1331,12 @@ ShutdownProcess::_WorkerDoShutdown()
// _QuitApps // _QuitApps
void void
ShutdownProcess::_QuitApps(AppInfoList &list, bool disableCancel) ShutdownProcess::_QuitApps(AppInfoList &list, bool systemApps)
{ {
PRINT(("ShutdownProcess::_QuitApps(%s)\n", PRINT(("ShutdownProcess::_QuitApps(%s)\n",
(disableCancel ? "system" : "user"))); (systemApps ? "system" : "user")));
if (disableCancel) { if (systemApps) {
_SetShutdownWindowCancelButtonEnabled(false); _SetShutdownWindowCancelButtonEnabled(false);
// check one last time for abort events // check one last time for abort events
@ -1384,7 +1374,7 @@ ShutdownProcess::_QuitApps(AppInfoList &list, bool disableCancel)
if (error != B_OK) if (error != B_OK)
throw_error(error); throw_error(error);
if (!disableCancel && event == ABORT_EVENT) { if (!systemApps && event == ABORT_EVENT) {
PRINT(("ShutdownProcess::_QuitApps(): shutdown cancelled by " PRINT(("ShutdownProcess::_QuitApps(): shutdown cancelled by "
"team %ld (-1 => user)\n", team)); "team %ld (-1 => user)\n", team));
@ -1413,8 +1403,6 @@ ShutdownProcess::_QuitApps(AppInfoList &list, bool disableCancel)
return; return;
} }
PRINT(("****RJL: Asking %s to quit\n", appName));
// set window text // set window text
char buffer[1024]; char buffer[1024];
snprintf(buffer, sizeof(buffer), "Asking \"%s\" to quit.", appName); snprintf(buffer, sizeof(buffer), "Asking \"%s\" to quit.", appName);
@ -1448,10 +1436,10 @@ ShutdownProcess::_QuitApps(AppInfoList &list, bool disableCancel)
break; break;
if (event == ABORT_EVENT) { if (event == ABORT_EVENT) {
if (disableCancel) { if (systemApps) {
// If the app requests aborting the shutdown, we don't need // If the app requests aborting the shutdown, we don't need
// to wait any longer. It has processed the request and // 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) if (eventTeam == team)
break; break;
} else { } else {
@ -1474,7 +1462,17 @@ ShutdownProcess::_QuitApps(AppInfoList &list, bool disableCancel)
} else { } else {
// the app is either blocking on a model alert or blocks for another // the app is either blocking on a model alert or blocks for another
// reason // 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(); status_t _Worker();
void _WorkerDoShutdown(); void _WorkerDoShutdown();
void _QuitApps(AppInfoList &list, bool disableCancel); void _QuitApps(AppInfoList &list, bool systemApps);
void _QuitBackgroundApps(); void _QuitBackgroundApps();
void _WaitForBackgroundApps(); void _WaitForBackgroundApps();
void _KillBackgroundApps(); void _KillBackgroundApps();
@ -97,7 +97,6 @@ private:
AppInfoList fSystemApps; AppInfoList fSystemApps;
AppInfoList fUserApps; AppInfoList fUserApps;
AppInfoList fBackgroundApps; AppInfoList fBackgroundApps;
//RosterAppInfo fInputServer;
TimeoutEvent *fTimeoutEvent; TimeoutEvent *fTimeoutEvent;
InternalEventList *fInternalEvents; InternalEventList *fInternalEvents;
sem_id fInternalEventSemaphore; sem_id fInternalEventSemaphore;

View File

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