kqueue OK in 10.4, not calling back to CFSocket in 10.3
kqueue OK in 10.4, not calling back to CFSocket in 10.3
- Subject: kqueue OK in 10.4, not calling back to CFSocket in 10.3
- From: Jerry Krinock <email@hidden>
- Date: Sat, 25 Feb 2006 19:20:26 -0800
- Thread-topic: kqueue OK in 10.4, not calling back to CFSocket in 10.3
In "Advanced Mac OS X Programming" by Dalrymple & Hillegass, there is an
example project which monitors directory changes with a kqueue in a CFSocket
that is added to your main run loop. I like this method because, in my
religion, we avoid spawning threads whenever possible.
It works fine in Tiger, and it compiles and runs fine in Panther, but in
Panther I never get a callback when the directory changes; it "just doesn't
work". (The example project in the book behaves the same way, and Mark D.
told me he has reproduced the issue and would look into it, but the answer
is not obvious to either of us.)
I have confirmed the following in Panther:
kqueue returns a file descriptor, OK.
CFSocketCreateWithNative creates socket, OK.
CFSocketCreateRunLoopSource creates source, OK.
CFRunLoopGetCurrent returns run loop, OK.
After CFRunLoopAddSource, CFRunLoopContainsSource
confirms that my source has been added.
Adding a call to CRFRunLoopWakeUp does not help.
Adding an observer shows that loop does cycle through
in Tiger when the watched directory is changed,
but does not cycle through in Panther.
There is also a command-line project in the book which works fine in both
Tiger and Panther. It camps on the kevent() with a "while" loop. So, I'd
say it is the CFSocket mechanism which is failing.
Does anyone know of any bugs in Panther's kqueue or CFSocket which could
cause this failure?
Jerry Krinock
P.S. I pondered for a long time whether to post this to Carbon-dev or
Cocoa-dev. It seems there should be a "CoreFoundation-dev" list.
The example projects can be downloaded from the book's web site:
http://www.borkware.com/corebook/second-edition-files/15-kqueues.tar.gz
The command-Line project which does work OK is "dirwatcher".
The project using CFSocket which does not work is "CocoaDirWatcher".
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden