diff options
author | Michael I. Bushnell <mib@gnu.org> | 1996-03-20 18:41:43 +0000 |
---|---|---|
committer | Michael I. Bushnell <mib@gnu.org> | 1996-03-20 18:41:43 +0000 |
commit | c8f645deb2eb00d721fe17344dd327bde5701b4a (patch) | |
tree | 6c31afe5360e68ead23f7720716986c5dbb63864 | |
parent | 06bc6d144dc7e35442c51fb1e2480e5e062bfce9 (diff) |
(ports_destroy_right): Don't do anything if port has already been
destroyed.
-rw-r--r-- | libports/destroy-right.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/libports/destroy-right.c b/libports/destroy-right.c index 907e64d7..704c0f57 100644 --- a/libports/destroy-right.c +++ b/libports/destroy-right.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1995 Free Software Foundation, Inc. + Copyright (C) 1995, 1996 Free Software Foundation, Inc. Written by Michael I. Bushnell. This file is part of the GNU Hurd. @@ -29,19 +29,22 @@ ports_destroy_right (void *portstruct) struct port_info *pi = portstruct; error_t err; - mutex_lock (&_ports_lock); - ihash_locp_remove (pi->bucket->htable, pi->hentry); - err = mach_port_mod_refs (mach_task_self (), pi->port_right, - MACH_PORT_RIGHT_RECEIVE, -1); - assert_perror (err); - mutex_unlock (&_ports_lock); - - pi->port_right = MACH_PORT_NULL; - - if (pi->flags & PORT_HAS_SENDRIGHTS) + if (pi->port_right != MACH_PORT_NULL) { - pi->flags &= ~PORT_HAS_SENDRIGHTS; - ports_port_deref (pi); + mutex_lock (&_ports_lock); + ihash_locp_remove (pi->bucket->htable, pi->hentry); + err = mach_port_mod_refs (mach_task_self (), pi->port_right, + MACH_PORT_RIGHT_RECEIVE, -1); + assert_perror (err); + mutex_unlock (&_ports_lock); + + pi->port_right = MACH_PORT_NULL; + + if (pi->flags & PORT_HAS_SENDRIGHTS) + { + pi->flags &= ~PORT_HAS_SENDRIGHTS; + ports_port_deref (pi); + } } } |