From 3ffd4b45a043c96b5cafbbfa8842056ed3b865c7 Mon Sep 17 00:00:00 2001 From: octo Date: Tue, 11 Apr 2006 22:24:37 +0000 Subject: [PATCH] Corrected some defines and the handling of `io_master_port'. --- src/apple_sensors.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/apple_sensors.c b/src/apple_sensors.c index a8f92a54..24e8f977 100644 --- a/src/apple_sensors.c +++ b/src/apple_sensors.c @@ -30,6 +30,7 @@ #if HAVE_CTYPE_H # include #endif + #if HAVE_MACH_MACH_TYPES_H # include #endif @@ -39,6 +40,9 @@ #if HAVE_MACH_MACH_ERROR_H # include #endif +#if HAVE_MACH_MACH_PORT_H +# include +#endif #if HAVE_COREFOUNDATION_COREFOUNDATION_H # include #endif @@ -55,8 +59,8 @@ # define IOKIT_HAVE_READ 0 #endif -#if IOKIT_HAVE_READ -static mach_port_t io_master_port; +#if HAVE_IOKIT_IOKITLIB_H +static mach_port_t io_master_port = MACH_PORT_NULL; #endif static char *temperature_file = "apple_sensors/temperature-%s.rrd"; @@ -74,7 +78,12 @@ static void as_init (void) #if IOKIT_HAVE_READ kern_return_t status; - /* FIXME: de-allocate port if it's defined */ + if (io_master_port != MACH_PORT_NULL) + { + mach_port_deallocate (mach_task_self (), + io_master_port); + io_master_port = MACH_PORT_NULL; + } status = IOMasterPort (MACH_PORT_NULL, &io_master_port); if (status != kIOReturnSuccess) @@ -84,7 +93,7 @@ static void as_init (void) io_master_port = MACH_PORT_NULL; return; } -#endif +#endif /* IOKIT_HAVE_READ */ return; } -- 2.30.2