From 3a74518ce7a6c5ce5cc556e36eb1bb1a37420165 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 18 May 2015 08:22:35 -0400 Subject: [PATCH] Invalidate and release the listening socket in -[MessageQueue disconnectClient]. The socket could be leaked (and not re-openable) if it never accepted a connection but was told to -disconnect. --- Source/MessageQueue.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/MessageQueue.m b/Source/MessageQueue.m index 5778169..d9e76a6 100644 --- a/Source/MessageQueue.m +++ b/Source/MessageQueue.m @@ -200,6 +200,12 @@ static void MessageQueueWriteEvent(CFWriteStreamRef stream, } - (void)disconnectClient { + if (_socket) { + CFSocketInvalidate(_socket); + CFRelease(_socket); + _socket = NULL; + } + if (_readStream) { CFReadStreamUnscheduleFromRunLoop(_readStream, [_runLoop getCFRunLoop], kCFRunLoopCommonModes); CFReadStreamClose(_readStream); -- 2.22.5