MYNetwork icon indicating copy to clipboard operation
MYNetwork copied to clipboard

MYDNSConnection -open creates retain loop?

Open ghmrs356 opened this issue 11 years ago • 4 comments

The socket context makes the CFSocket retain and release its owner, why?

CFSocketContext ctxt = { 0, (__bridge void *)(self), CFRetain, CFRelease, NULL };

there should be no reason to do that, since you're invalidating and releasing the socket on dealloc. Creating the socket using the context like:

CFSocketContext ctxt = { 0, (__bridge void *)(self), NULL, NULL, NULL };

seems to work fine. This fixes the deadlock problem I was having, but I'm unsure as to whether the retain/release socket context is on purpose.

ghmrs356 avatar Jun 29 '13 18:06 ghmrs356

To be honest I can't remember why I did that. Taking out the retain/release would definitely fix the deadlock since the object wouldn't get dealloced on the internal socket thread anymore.

It sounds like you've made this change locally and have been running with it? If you are comfortable that it hasn't resulted in any crashes, let me know and I'll check it in.

snej avatar Jul 02 '13 16:07 snej

It looks like this fixes an issue I had (presumably the same problem) where a bunch of threads would just end up spin-locking forever. Since it's been two weeks since the last message from @ghmrs356 about it, I'm gonna go ahead and put in the pull request.

aleffert avatar Jul 18 '13 21:07 aleffert

Any movement on this?

aleffert avatar Aug 05 '13 21:08 aleffert

All I can say is that it appears to work fine.

ghmrs356 avatar Aug 06 '13 05:08 ghmrs356