#include <CoreFoundation/CoreFoundation.h>
#include <unistd.h>
#include <sys/event.h>
static void junkCallback(CFFileDescriptorRef fdref, CFOptionFlags callBackTypes, void *info) {}
int main(int argc, char *argv[])
{
int i = 0;
for (i = 0; i < 3; i++)
{
CFFileDescriptorRef fileDescriptor = nil;
CFRunLoopSourceRef runLoopSource = nil;
NSLog(@"CREATE %d", i);
fileDescriptor = CFFileDescriptorCreate(NULL, 0, false, junkCallback, NULL);
runLoopSource = CFFileDescriptorCreateRunLoopSource(NULL, fileDescriptor, 0);
CFRunLoopAddSource([[NSRunLoop currentRunLoop] getCFRunLoop], runLoopSource, kCFRunLoopDefaultMode);
NSLog(@"DESTROY %d", i);
CFRunLoopRemoveSource([[NSRunLoop currentRunLoop] getCFRunLoop], runLoopSource, kCFRunLoopDefaultMode);
CFRelease(runLoopSource);
CFFileDescriptorInvalidate(fileDescriptor);
CFRelease(fileDescriptor);
}
sleep(-1);
return 0;
}
==============================
I'd definitely consider your findings a bug. But I don't think it poses any real issue, since CFFileDescriptor is useless unless it's used with a run loop.
I'd say a radar is in order...
David