From 2ddb245fac99802e63742c21f7da0d499e9cecf6 Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Thu, 15 Apr 2010 17:31:09 +0000 Subject: [Author: dmaclach] refactor GTMUnitTestingUtilities into GTMAppKitUnitTestingUtilties and GTMFoundationUnitTestingUtilities. convert GTMSignalHandler over to using new runloop routines fix bug in GTMSignalHandler API with GC where releasing it wasn't sufficient to stop it listening. R=thomasvl DELTA=1227 (638 added, 566 deleted, 23 changed) --- Foundation/GTMSignalHandler.m | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'Foundation/GTMSignalHandler.m') diff --git a/Foundation/GTMSignalHandler.m b/Foundation/GTMSignalHandler.m index dd67269..677c10a 100644 --- a/Foundation/GTMSignalHandler.m +++ b/Foundation/GTMSignalHandler.m @@ -44,7 +44,6 @@ static CFSocketRef gRunLoopSocket = NULL; - (void)notify; - (void)addFileDescriptorMonitor:(int)fd; - (void)registerWithKQueue; -- (void)unregisterWithKQueue; @end @@ -88,19 +87,17 @@ static CFSocketRef gRunLoopSocket = NULL; } #if GTM_SUPPORT_GC + - (void)finalize { - [self unregisterWithKQueue]; - + [self invalidate]; [super finalize]; - } + #endif - (void)dealloc { - [self unregisterWithKQueue]; - + [self invalidate]; [super dealloc]; - } // Cribbed from Advanced Mac OS X Programming. @@ -181,7 +178,7 @@ static void SocketCallBack(CFSocketRef socketref, CFSocketCallBackType type, } -- (void)unregisterWithKQueue { +- (void)invalidate { // Short-circuit cases where we didn't actually register a kqueue event. if (signo_ == 0) return; if (action_ == nil) return; @@ -193,7 +190,10 @@ static void SocketCallBack(CFSocketRef socketref, CFSocketCallBackType type, if (kevent(gSignalKQueueFileDescriptor, &filter, 1, NULL, 0, &noWait) != 0) { _GTMDevLog(@"could not remove event for signal %d. Errno %d", signo_, errno); // COV_NF_LINE } - + + // Set action_ to nil so that if invalidate is called on us twice, + // nothing happens. + action_ = nil; } - (void)notify { -- cgit v1.2.3