summaryrefslogtreecommitdiff
path: root/libfshelp
diff options
context:
space:
mode:
authorJustus Winter <justus@gnupg.org>2016-10-09 17:00:31 +0200
committerJustus Winter <justus@gnupg.org>2016-10-09 22:05:28 +0200
commit3319f7f6a238cf88b9f46849e7be84d3c96376d6 (patch)
treef48ea46bada825114aa0ffa911cd3c90ca2ad7d5 /libfshelp
parent2c0f4a09a5166bf777ce4648dda2d671cc464b14 (diff)
fshelp: Fix fetching the control port.
* libfshelp/fetch-control.c (fshelp_fetch_control): Check if the control port is still alive, or deallocate the dead name, record the fact in the transbox, and return MACH_PORT_NULL.
Diffstat (limited to 'libfshelp')
-rw-r--r--libfshelp/fetch-control.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/libfshelp/fetch-control.c b/libfshelp/fetch-control.c
index 26c12d88..91c65bb0 100644
--- a/libfshelp/fetch-control.c
+++ b/libfshelp/fetch-control.c
@@ -19,13 +19,24 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "fshelp.h"
+#include <assert.h>
error_t
fshelp_fetch_control (struct transbox *box,
mach_port_t *control)
{
+ error_t err = 0;
*control = box->active;
if (*control != MACH_PORT_NULL)
- mach_port_mod_refs (mach_task_self (), *control, MACH_PORT_RIGHT_SEND, 1);
- return 0;
+ err = mach_port_mod_refs (mach_task_self (), *control,
+ MACH_PORT_RIGHT_SEND, 1);
+
+ if (err == KERN_INVALID_RIGHT)
+ {
+ err = mach_port_deallocate (mach_task_self (), *control);
+ assert_perror (err);
+ *control = box->active = MACH_PORT_NULL;
+ }
+
+ return err;
}