Hi dear list members,
I have ported most parts of the CocoaHTTPServer from Robbie Hanson
including GCDAsyncSocket to Linux and found an interesting difference in
memory management.
Here's the dealloc function of GCDAsyncSocket:
- (void)dealloc
{
LogInfo(@"%@ - %@ (start)", THIS_METHOD, self);
if (dispatch_get_specific(IsOnSocketQueueOrTargetQueueKey))
{
[self closeWithError:nil];
}
else
{
dispatch_sync(socketQueue, ^{
[self closeWithError:nil];
});
}
This method crashes on Linux when the dealloc function in not called in
the socket or target queue as the block that calls closeWithError is
executed in this case. Catching "self" in it increments and after block
execution decrements the retain count of "self". Doing this in a dealloc
method of course leads into disaster.
But the same code does not crash on MacOS or iOS, even if the block
containing closwWithError is executed.
I don't understand that, but maybe somebody knowing the differences
better than I can explain that.
Best regards,
Mathias
_______________________________________________
Discuss-gnustep mailing list
Discuss-gnustep@gnu.org
https://lists.gnu.org/mailman/listinfo/discuss-gnustep