From 3bc158f1790d24b69c19d3d2503d4e98961a1c6f Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 29 May 2011 22:15:17 -0400 Subject: [PATCH] Remove testing code from CloseConnection() --- Source/NetworkCallbackController.mm | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/Source/NetworkCallbackController.mm b/Source/NetworkCallbackController.mm index 5e5bd08..dfb350c 100644 --- a/Source/NetworkCallbackController.mm +++ b/Source/NetworkCallbackController.mm @@ -79,21 +79,11 @@ void NetworkCallbackController::OpenConnection(NSUInteger port) void NetworkCallbackController::CloseConnection() { - NSUInteger closeCount = 0; - - if (readStream_) { - UnscheduleReadStream(); - ++closeCount; - } - if (writeStream_) { - UnscheduleWriteStream(); - ++closeCount; - } + UnscheduleReadStream(); + UnscheduleWriteStream(); if (socketHandle_) { - for ( ; closeCount > 0; --closeCount) - close(socketHandle_); - + close(socketHandle_); socketHandle_ = NULL; [connection_ socketDisconnected]; } @@ -169,6 +159,9 @@ void NetworkCallbackController::OnSocketAccept(CFSocketRef socket, CFDataRef address, const void* data) { + // Keep a reference to the socket handle of the child socket. Do not create + // a CFSocket with this because doing so prohibits the use of streams. The + // kCFSocketDataCallBack would have to be used instead. socketHandle_ = *(CFSocketNativeHandle*)data; // Create the streams on the socket. -- 2.43.5