From: Alexandra Ellwood Date: Thu, 23 Oct 2008 17:50:43 +0000 (+0000) Subject: Free global mach ports on library unload X-Git-Tag: krb5-1.7-alpha1~272 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6be011a74d39563c81418fd4c330a72e156cdeb8;p=krb5.git Free global mach ports on library unload ticket: 6248 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20911 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/util/mac/k5_mig_client.c b/src/util/mac/k5_mig_client.c index 7d57468bb..7dedbbebb 100644 --- a/src/util/mac/k5_mig_client.c +++ b/src/util/mac/k5_mig_client.c @@ -144,14 +144,14 @@ MAKE_FINI_FUNCTION(k5_cli_ipc_thread_fini); static int k5_cli_ipc_thread_init (void) { int err = 0; - + err = k5_key_register (K5_KEY_IPC_CONNECTION_INFO, k5_ipc_client_cinfo_free); if (!err) { err = k5_mutex_finish_init (&g_service_ports_mutex); } - + return err; } @@ -159,6 +159,23 @@ static int k5_cli_ipc_thread_init (void) static void k5_cli_ipc_thread_fini (void) { + int err = 0; + + err = k5_mutex_lock (&g_service_ports_mutex); + + if (!err) { + int i; + + for (i = 0; i < KIPC_SERVICE_COUNT; i++) { + if (MACH_PORT_VALID (g_service_ports[i].service_port)) { + mach_port_destroy (mach_task_self (), + g_service_ports[i].service_port); + g_service_ports[i].service_port = MACH_PORT_NULL; + } + } + k5_mutex_unlock (&g_service_ports_mutex); + } + k5_key_delete (K5_KEY_IPC_CONNECTION_INFO); k5_mutex_destroy (&g_service_ports_mutex); }