From d583c2bf9159456ec145a99eacf29d6df4331f2b Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 21 Feb 1996 22:17:09 +0000 Subject: (fshelp_set_active): When EXCL, make sure the active translator is really active. --- libfshelp/set-active.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/libfshelp/set-active.c b/libfshelp/set-active.c index f2cc297b..4f25a50e 100644 --- a/libfshelp/set-active.c +++ b/libfshelp/set-active.c @@ -28,9 +28,23 @@ fshelp_set_active (struct transbox *box, { int cancel; - if (excl - && ((box->active != MACH_PORT_NULL) || (box->flags & TRANSBOX_STARTING))) - return EBUSY; + if (excl) + { + if (box->flags & TRANSBOX_STARTING) + return EBUSY; + if (box->active != MACH_PORT_NULL) + /* It looks like there's an existing translator, but make sure. */ + { + mach_port_urefs_t dead_refs; + error_t err = + mach_port_get_refs (mach_task_self (), + box->active, MACH_PORT_RIGHT_DEAD_NAME, + &dead_refs); + if (!err && dead_refs == 0) + /* Still active, we lose. */ + return EBUSY; + } + } while (box->flags & TRANSBOX_STARTING) { -- cgit v1.2.3