From 07d582872fa1fd448a0421abe7cef80ae8693979 Mon Sep 17 00:00:00 2001 From: Jorrit Herder Date: Fri, 27 May 2005 13:10:58 +0000 Subject: [PATCH] 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. --- servers/pm/main.c | 9 ++++++--- servers/pm/misc.c | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/servers/pm/main.c b/servers/pm/main.c index 671a97b0c..9f214a4a4 100644 --- a/servers/pm/main.c +++ b/servers/pm/main.c @@ -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; } } diff --git a/servers/pm/misc.c b/servers/pm/misc.c index 32aa327d5..fa18427cc 100644 --- a/servers/pm/misc.c +++ b/servers/pm/misc.c @@ -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); } /*=====================================================================*