diff options
author | Roland McGrath <roland@gnu.org> | 2001-03-31 23:06:48 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2001-03-31 23:06:48 +0000 |
commit | 401faf3bb898ddb4f7c025a4f9a78386cc381e0b (patch) | |
tree | 7a3237d6e2309046f5337e3e3b5eb31db89a4c5f | |
parent | 6e6cf5ec0d5050697976185685111aa9b89be5d7 (diff) |
2001-03-29 Neal H Walfield <neal@cs.uml.edu>
* claim-right.c (ports_claim_right): Include errno.h and
assert.h. Add assertions. Clean up the logic.
-rw-r--r-- | libports/claim-right.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/libports/claim-right.c b/libports/claim-right.c index 2ddb3aaa..9986ba2e 100644 --- a/libports/claim-right.c +++ b/libports/claim-right.c @@ -1,5 +1,5 @@ /* Take a receive right away from a port - Copyright (C) 1996 Free Software Foundation, Inc. + Copyright (C) 1996, 2001 Free Software Foundation, Inc. Written by Michael I. Bushnell, p/BSG. This file is part of the GNU Hurd. @@ -20,33 +20,34 @@ #include "ports.h" +#include <assert.h> +#include <errno.h> #include <hurd/ihash.h> mach_port_t ports_claim_right (void *portstruct) { + error_t err; struct port_info *pi = portstruct; - mach_port_t ret; + mach_port_t ret = pi->port_right; - if (pi->port_right != MACH_PORT_NULL) + if (ret == MACH_PORT_NULL) + return ret; + + mutex_lock (&_ports_lock); + ihash_locp_remove (pi->bucket->htable, pi->hentry); + err = mach_port_move_member (mach_task_self (), ret, MACH_PORT_NULL); + assert_perror (err); + pi->port_right = MACH_PORT_NULL; + if (pi->flags & PORT_HAS_SENDRIGHTS) { - ret = pi->port_right; - - mutex_lock (&_ports_lock); - ihash_locp_remove (pi->bucket->htable, pi->hentry); - mach_port_move_member (mach_task_self (), ret, MACH_PORT_NULL); - pi->port_right = MACH_PORT_NULL; - if (pi->flags & PORT_HAS_SENDRIGHTS) - { - pi->flags &= ~PORT_HAS_SENDRIGHTS; - mutex_unlock (&_ports_lock); - ports_port_deref (pi); - } - else - mutex_unlock (&_ports_lock); + pi->flags &= ~PORT_HAS_SENDRIGHTS; + mutex_unlock (&_ports_lock); + ports_port_deref (pi); } else - ret = MACH_PORT_NULL; + mutex_unlock (&_ports_lock); + return ret; } |