From 1602ca3148308cf34986aab0e7e19111292e2328 Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Wed, 17 Oct 2012 22:24:03 +0200 Subject: [PATCH] Close connection when an exception occurs. --- src/XMPPConnection.m | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/XMPPConnection.m b/src/XMPPConnection.m index 2d47303..499d61d 100644 --- a/src/XMPPConnection.m +++ b/src/XMPPConnection.m @@ -299,7 +299,8 @@ [sock asyncReadIntoBuffer: buffer length: BUFFER_LENGTH target: self - selector: @selector(stream:didReadIntoBuffer:length:)]; + selector: @selector(stream:didReadIntoBuffer:length: + exception:)]; } - (BOOL)XMPP_parseBuffer: (const void*)buffer @@ -340,7 +341,13 @@ - (BOOL)stream: (OFStream*)stream didReadIntoBuffer: (char*)buffer length: (size_t)length + exception: (OFException*)exception { + if (exception != nil) { + [self close]; + return NO; + } + if (![self XMPP_parseBuffer: buffer length: length]) return NO; @@ -355,8 +362,8 @@ [sock asyncReadIntoBuffer: buffer length: BUFFER_LENGTH target: self - selector: @selector(stream: - didReadIntoBuffer:length:)]; + selector: @selector(stream:didReadIntoBuffer: + length:exception:)]; return NO; }