CCAPI is leaking mach ports
authorAlexandra Ellwood <lxs@mit.edu>
Fri, 22 Aug 2008 16:44:22 +0000 (16:44 +0000)
committerAlexandra Ellwood <lxs@mit.edu>
Fri, 22 Aug 2008 16:44:22 +0000 (16:44 +0000)
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

index f905621075629ce8370496cfd8cf4bf99469dbeb..2fabb192209868f301aa7bee88e1719003187f4d 100644 (file)
@@ -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); }