From 5a71edcee3770b365c112e085ed5e1848d40c300 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Wed, 20 Mar 1996 18:42:37 +0000 Subject: (ports_claim_right): --- libports/claim-right.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'libports') diff --git a/libports/claim-right.c b/libports/claim-right.c index 827aa79a..2569fa77 100644 --- a/libports/claim-right.c +++ b/libports/claim-right.c @@ -26,15 +26,24 @@ mach_port_t ports_claim_right (void *portstruct) { struct port_info *pi = portstruct; - - mutex_lock (&_ports_lock); - ihash_locp_remove (pi->bucket->htable, pi->hentry); - mutex_unlock (&_ports_lock); - pi->port_right = MACH_PORT_NULL; - if (pi->flags & PORT_HAS_SENDRIGHTS) + mach_port_t ret; + + if (pi->port_right != MACH_PORT_NULL) { - pi->flags &= ~PORT_HAS_SENDRIGHTS; - ports_port_deref (pi); + ret = pi->port_right; + + mutex_lock (&_ports_lock); + ihash_locp_remove (pi->bucket->htable, pi->hentry); + 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); + } } + else + ret = MACH_PORT_NULL; + return ret; } -- cgit v1.2.3