diff options
-rw-r--r-- | proc/ChangeLog | 12 | ||||
-rw-r--r-- | proc/mgt.c | 2 | ||||
-rw-r--r-- | proc/msg.c | 29 | ||||
-rw-r--r-- | proc/notify.c | 4 |
4 files changed, 30 insertions, 17 deletions
diff --git a/proc/ChangeLog b/proc/ChangeLog index 2edfb145..d19324d3 100644 --- a/proc/ChangeLog +++ b/proc/ChangeLog @@ -1,3 +1,15 @@ +1999-03-11 Mark Kettenis <kettenis@gnu.org> + + * notify.c (do_mach_notify_dead_name): Remove unnecessary braces. + + * msg.c (S_proc_setmsgport): Remove unused variable FOO. + (S_proc_getmsgport): Only check if the message port is still alive + if it is not MACH_PORT_NULL. Use mach_port_type instead of + mach_port_get_refs to check if the port is dead. + + * mgt.c (S_proc_reassign): Use mach_port_destroy to release the + old task port. + Tue Mar 9 13:11:43 1999 Thomas Bushnell, BSG <tb@mit.edu> * notify.c (do_mach_notify_dead_name): Don't check against @@ -219,7 +219,7 @@ S_proc_reassign (struct proc *p, remove_proc_from_hash (p); task_terminate (p->p_task); - mach_port_deallocate (mach_task_self (), p->p_task); + mach_port_destroy (mach_task_self (), p->p_task); p->p_task = stubp->p_task; /* For security, we need use the request port from STUBP */ @@ -50,7 +50,6 @@ S_proc_setmsgport (struct proc *p, mach_port_t *oldmsgport, mach_msg_type_name_t *oldmsgport_type) { - mach_port_t foo; if (!p) return EOPNOTSUPP; @@ -92,8 +91,6 @@ 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; @@ -116,19 +113,25 @@ restart: if (!p) return ESRCH; - err = mach_port_get_refs (mach_task_self (), p->p_msgport, - MACH_PORT_RIGHT_SEND, &refs); - if (err || !refs) + /* Only check if the message port passed away, if we know that it + was ever alive. */ + if (p->p_msgport != MACH_PORT_NULL) { - /* 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; + mach_port_type_t type; + error_t err; + + err = mach_port_type (mach_task_self (), p->p_msgport, &type); + if (err || (type & MACH_PORT_TYPE_DEAD_NAME)) + { + /* 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; } - diff --git a/proc/notify.c b/proc/notify.c index d0fd2f60..07fc376d 100644 --- a/proc/notify.c +++ b/proc/notify.c @@ -53,9 +53,7 @@ do_mach_notify_dead_name (mach_port_t notify, p = ports_lookup_port (proc_bucket, notify, proc_class); if (!p) - { - return EOPNOTSUPP; - } + return EOPNOTSUPP; if (p->p_task == deadport) { |