Fixed a bug in PM: sending of reply messages didn't check if destination

process is still alive. This caused a panic in some situations, e.g., when
all processes are killed on a shutdown.
This commit is contained in:
Jorrit Herder 2005-05-27 13:10:58 +00:00
parent c2be104821
commit 07d582872f
2 changed files with 9 additions and 4 deletions

View file

@ -37,7 +37,7 @@ PUBLIC void main()
{
/* Main routine of the process manager. */
int result, proc_nr;
int result, s, proc_nr;
struct mproc *rmp;
pm_init(); /* initialize process manager tables */
@ -74,9 +74,12 @@ PUBLIC void main()
* the call just made above. The processes must not be swapped out.
*/
for (proc_nr=0, rmp=mproc; proc_nr < NR_PROCS; proc_nr++, rmp++) {
if ((rmp->mp_flags & (REPLY | ONSWAP)) == REPLY) {
if (send(proc_nr, &rmp->mp_reply) != OK)
if ((rmp->mp_flags & IN_USE) &&
(rmp->mp_flags & (REPLY | ONSWAP)) == REPLY) {
if ((s=send(proc_nr, &rmp->mp_reply)) != OK) {
printf("Warning, PM send failed: %d, ", s);
panic("PM can't reply to", proc_nr);
}
rmp->mp_flags &= ~REPLY;
}
}

View file

@ -71,8 +71,10 @@ PUBLIC int do_reboot()
tell_fs(REBOOT,0,0,0); /* tell FS to prepare for shutdown */
check_sig(-1, SIGKILL); /* kill all processes except init */
/* Ask the kernel to abort. All system services, including the PM, will
* get a HARD_STOP notification. Await the notification in the main loop.
*/
sys_abort(m_in.reboot_flag, PM_PROC_NR, monitor_code, m_in.reboot_size);
sys_exit(0);
}
/*=====================================================================*