aboutsummaryrefslogtreecommitdiff
path: root/Foundation/GTMFileSystemKQueue.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/GTMFileSystemKQueue.m
parent4fd103b5de98d2f469b982677ea389e7ee7d64b3 (diff)
Fixing a like Avi found w/ our use of CFRunLoop from some kqueue code.
Diffstat (limited to 'Foundation/GTMFileSystemKQueue.m')
-rw-r--r--Foundation/GTMFileSystemKQueue.m7
1 files changed, 7 insertions, 0 deletions
diff --git a/Foundation/GTMFileSystemKQueue.m b/Foundation/GTMFileSystemKQueue.m
index ebb2ec8..ad516f7 100644
--- a/Foundation/GTMFileSystemKQueue.m
+++ b/Foundation/GTMFileSystemKQueue.m
@@ -107,6 +107,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(gFileSystemKQueueFileDescriptor, NULL, 0, &event, 1, NULL) == -1) {
@@ -116,6 +122,7 @@ static void SocketCallBack(CFSocketRef socketref, CFSocketCallBackType type,
[fskq notify:event.fflags];
}
+ [pool drain];
}
// Cribbed from Advanced Mac OS X Programming