From fc539b7d38ff1dcf0f28fb76edf8bcdbbed99dea Mon Sep 17 00:00:00 2001 From: Alexandra Ellwood Date: Fri, 22 Aug 2008 16:44:22 +0000 Subject: [PATCH] CCAPI is leaking mach ports Need to destroy the mach ports instead of deallocating because we requested notifications on the port so just deallocating won't actually destroy the port. Also deallocate any port which was previously registered for notifications. ticket: new git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20688 dc483132-0cff-0310-8789-dd5450dbe970 --- src/ccapi/lib/mac/ccapi_os_ipc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ccapi/lib/mac/ccapi_os_ipc.c b/src/ccapi/lib/mac/ccapi_os_ipc.c index f90562107..2fabb1922 100644 --- a/src/ccapi/lib/mac/ccapi_os_ipc.c +++ b/src/ccapi/lib/mac/ccapi_os_ipc.c @@ -240,7 +240,11 @@ cc_int32 cci_os_ipc (cc_int32 in_launch_server, err = mach_port_request_notification (mach_task_self (), reply_port, MACH_NOTIFY_NO_SENDERS, 1, reply_port, MACH_MSG_TYPE_MAKE_SEND_ONCE, - &old_notification_target ); + &old_notification_target); + + if (!err && old_notification_target != MACH_PORT_NULL) { + mach_port_deallocate (mach_task_self (), old_notification_target); + } } if (!err) { @@ -263,7 +267,7 @@ cc_int32 cci_os_ipc (cc_int32 in_launch_server, pthread_setspecific (g_reply_stream_key, NULL); pthread_setspecific (g_server_died_key, NULL); - if (MACH_PORT_VALID (reply_port)) { mach_port_deallocate (mach_task_self (), reply_port); } + if (reply_port != MACH_PORT_NULL) { mach_port_destroy (mach_task_self (), reply_port); } if (ool_request_length ) { vm_deallocate (mach_task_self (), (vm_address_t) ool_request, ool_request_length); } if (reply_stream ) { cci_stream_release (reply_stream); } -- 2.26.2