From 3cbc9f6caa9361b1bb2bdfc6ebd9993ff140d2ee Mon Sep 17 00:00:00 2001 From: Thomas Bushnell Date: Tue, 9 Mar 1999 20:39:31 +0000 Subject: Tue Mar 9 13:11:43 1999 Thomas Bushnell, BSG * notify.c (do_mach_notify_dead_name): Don't check against P->p_msgport anymore. * msg.c (message_port_dead): Delete function. (S_proc_setmsgport): Don't request a dead-name notification anymore. (S_proc_getmsgport): Check to see if P->p_msgport is dead before returning it. * mgt.c (S_proc_reassign): Only use mach_port_deallocate to release P->msgport. (process_has_exited): Likewise. * proc.h (message_port_dead): Delete prototype. --- proc/msg.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'proc/msg.c') diff --git a/proc/msg.c b/proc/msg.c index fe173b68..5a9d8919 100644 --- a/proc/msg.c +++ b/proc/msg.c @@ -1,5 +1,5 @@ /* Message port manipulations - Copyright (C) 1994, 1995, 1996 Free Software Foundation + Copyright (C) 1994, 1995, 1996, 1999 Free Software Foundation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -63,12 +63,6 @@ S_proc_setmsgport (struct proc *p, prociterate (check_message_return, p); p->p_checkmsghangs = 0; - mach_port_request_notification (mach_task_self (), msgport, - MACH_NOTIFY_DEAD_NAME, 1, p->p_pi.port_right, - MACH_MSG_TYPE_MAKE_SEND_ONCE, &foo); - if (foo) - mach_port_deallocate (mach_task_self (), foo); - if (p == startup_proc) /* Init is single threaded, so we can't delay our reply for the essential task RPC; spawn a thread to do it. */ @@ -98,10 +92,13 @@ S_proc_getmsgport (struct proc *callerp, { int cancel; struct proc *p = pid_find_allow_zombie (pid); + error_t err; + mach_port_urefs_t refs; if (!callerp) return EOPNOTSUPP; - + +restart: while (p && p->p_deadmsg && !p->p_dead) { callerp->p_msgportwait = 1; @@ -119,15 +116,19 @@ S_proc_getmsgport (struct proc *callerp, if (!p) return ESRCH; + err = mach_port_get_refs (mach_task_self (), p->p_msgport, + MACH_PORT_RIGHT_SEND, &refs); + if (err || !refs) + { + /* The port appears to be dead; throw it away. */ + mach_port_deallocate (mach_task_self (), p->p_msgport); + p->p_msgport = MACH_PORT_NULL; + p->p_deadmsg = 1; + goto restart; + } + *msgport = p->p_msgport; - return 0; -} -void -message_port_dead (struct proc *p) -{ - mach_port_deallocate (mach_task_self (), p->p_msgport); - p->p_msgport = MACH_PORT_NULL; - p->p_deadmsg = 1; + return 0; } -- cgit v1.2.3