aboutsummaryrefslogtreecommitdiff
path: root/Foundation/GTMSignalHandler.m
diff options
context:
space:
mode:
authorGravatar thomasvl@gmail.com <thomasvl@gmail.com@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2009-01-22 21:37:19 +0000
committerGravatar thomasvl@gmail.com <thomasvl@gmail.com@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3>2009-01-22 21:37:19 +0000
commitba7d45cf8c3b1938a51a9b3580919c61bf750f9d (patch)
treecf058378356511d3615e921e35b481c72019f902 /Foundation/GTMSignalHandler.m
parent4fd103b5de98d2f469b982677ea389e7ee7d64b3 (diff)
Fixing a like Avi found w/ our use of CFRunLoop from some kqueue code.
Diffstat (limited to 'Foundation/GTMSignalHandler.m')
-rw-r--r--Foundation/GTMSignalHandler.m7
1 files changed, 7 insertions, 0 deletions
diff --git a/Foundation/GTMSignalHandler.m b/Foundation/GTMSignalHandler.m
index 557d8be..b6cfb70 100644
--- a/Foundation/GTMSignalHandler.m
+++ b/Foundation/GTMSignalHandler.m
@@ -105,6 +105,12 @@ static CFSocketRef gRunLoopSocket = NULL;
// Cribbed from Advanced Mac OS X Programming.
static void SocketCallBack(CFSocketRef socketref, CFSocketCallBackType type,
CFDataRef address, const void *data, void *info) {
+ // We're using CFRunLoop calls here. Even when used on the main thread, they
+ // don't trigger the draining of the main application's autorelease pool that
+ // NSRunLoop provides. If we're used in a UI-less app, this means that
+ // autoreleased objects would never go away, so we provide our own pool here.
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
struct kevent event;
if (kevent(gSignalKQueueFileDescriptor, NULL, 0, &event, 1, NULL) == -1) {
@@ -114,6 +120,7 @@ static void SocketCallBack(CFSocketRef socketref, CFSocketCallBackType type,
[handler notify];
}
+ [pool drain];
}
// Cribbed from Advanced Mac OS X Programming