summaryrefslogtreecommitdiff
path: root/proc/msg.c
diff options
context:
space:
mode:
authorThomas Bushnell <thomas@gnu.org>1999-03-12 20:28:52 +0000
committerThomas Bushnell <thomas@gnu.org>1999-03-12 20:28:52 +0000
commit86e760a779b29116426a2d5fd38a955d47cfb046 (patch)
tree1b1206d7824a20af74df3c53a3b1245ce43568b9 /proc/msg.c
parentc41dfc0e9447aa0e7f1e498ef3f8a76f34d905f5 (diff)
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.
Diffstat (limited to 'proc/msg.c')
-rw-r--r--proc/msg.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/proc/msg.c b/proc/msg.c
index 5a9d8919..eae1c603 100644
--- a/proc/msg.c
+++ b/proc/msg.c
@@ -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;
}
-