Re: [SOLVED] Unresponsive CFMessagePort
Re: [SOLVED] Unresponsive CFMessagePort
- Subject: Re: [SOLVED] Unresponsive CFMessagePort
- From: Jerry Krinock <email@hidden>
- Date: Thu, 6 Jan 2011 21:37:15 -0800
On 2011 Jan 06, at 17:33, Dave Keck wrote:
> Oh, `sudo launchctl bstree` might also be useful.
Thank you, Dave. It was useful. It told me that my server port was "active" (A). This confirms what the Client tells me, that the port is found, but times out when connecting to it. Odd, though, that, if I sent messages repeatedly, the Client would get a couple seconds of kCFMessagePortReceiveTimeout errors and then after that, kCFMessagePortSendTimeout errors.
Thus knowing what to look for, I found the problem, which is that I was using the same port name for two different transient tasks, but the port for the second task was being created before the port for the first task was invalidated and released. This was because I was invalidating and releasing the port in the server's -dealloc method, which was running lazily when an autorelease pool was released.
Just for the record, the trick is that if you try to create a port while an older port with the same name is invalidated but not yet deallocated, an exception is raised and logged in the console. However if the older port is still active, and then later invalidated and deallocated, you get this silent failure, a nonresponsive port.
On 2011 Jan 06, at 16:48, Dave Keck wrote:
> consider using NSMachPort
> instead of CFMessagePort; you can lose a lot of code in doing so.
> Here's an example showing how to set up a client and server using
> NSMachPort and NSMachBootstrapServer:
>
> http://pastie.org/1435791
>
> This code would of course work the same if the client and server were
> in separate processes, assuming the server port is registered in a
> bootstrap context that's visible to the client.
Thank you. It does look like less code. I'll study it tomorrow.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden