Re: Crash in CFReadStreamOpen
Re: Crash in CFReadStreamOpen
- Subject: Re: Crash in CFReadStreamOpen
- From: Benoit Foucher <email@hidden>
- Date: Thu, 28 May 2009 15:49:03 +0200
Hi,
On May 26, 2009, at 11:35 PM, Jens Alfke wrote:
On May 26, 2009, at 1:42 PM, Benoit Foucher wrote:
I'm getting an EXC_BAD_ACCESS crash in CFReadSreamOpen and I don't
understand why. The code only fails with OS X 10.5.7. It works fine
on 10.5.6. I wonder if this is perhaps because I add the stream to
another thread's run loop from the main thread. However, I didn't
see any mention of this not being thread safe -- on the contrary
the documentation seems to indicate that CF run loop functions are
thread safe...
I've had trouble in the past with thread-safety of CFRunLoop,
regardless of what the docs say.
Scheduling something on a different thread's runloop is a really
unusual thing. Ordinarily you'd do the setup and scheduling (i.e.
opening the stream) on the same thread that will be handling the
events. What's your code trying to do?
It's actually not clear to me how I'm supposed to use run loops if the
APIs aren't thread safe or why the different methods to register a
source with a run loop provide a run loop parameter. Suppose I want a
thread pool to handle IO for multiple network connections (either
using the CFSocket or CFStream APIs). How can I register the network
connections with the run loop of each thread from the pool?
If I can't call CFRunLoopAddSource or CFReadStreamScheduleWithRunLoop
from a separate thread, I suppose I'll have to somehow register the
source from each thread. If that's the case, do you have any
recommendation on the best way to do this?
Thanks.
Cheers,
Benoit.
—Jens
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden