ObjXMPP  Check-in [b88cb91f47]

Overview
Comment:Close connection when an exception occurs.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b88cb91f4780b38222f640e57f21d2f4d0e1b8888de617c56667ed8cd8644461
User & Date: js on 2012-10-17 20:24:03
Other Links: manifest | tags
Context
2012-11-08
11:56
Update buildsys. check-in: df39a315dc user: js tags: trunk
2012-10-17
20:24
Close connection when an exception occurs. check-in: b88cb91f47 user: js tags: trunk
2012-10-14
11:04
Adjust to recent ObjFW changes. check-in: 1a040269e5 user: js tags: trunk
Changes

Modified src/XMPPConnection.m from [efe09bc35c] to [74e0c7a892].

295
296
297
298
299
300
301
302


303
304
305
306
307
308
309
295
296
297
298
299
300
301

302
303
304
305
306
307
308
309
310







-
+
+







- (void)handleConnection
{
	char *buffer = [self allocMemoryWithSize: BUFFER_LENGTH];

	[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
		   length: (size_t)length
{
	if ([sock isAtEndOfStream]) {
		[delegates broadcastSelector: @selector(connectionWasClosed:)
336
337
338
339
340
341
342

343





344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359


360
361
362
363
364
365
366
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364


365
366
367
368
369
370
371
372
373







+

+
+
+
+
+














-
-
+
+







	oldParser = nil;
	oldElementBuilder = nil;
}

-      (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;

	if (oldParser != nil || oldElementBuilder != nil) {
		[oldParser release];
		[oldElementBuilder release];

		oldParser = nil;
		oldElementBuilder = nil;

		[sock asyncReadIntoBuffer: buffer
				   length: BUFFER_LENGTH
				   target: self
				 selector: @selector(stream:
					       didReadIntoBuffer:length:)];
				 selector: @selector(stream:didReadIntoBuffer:
					       length:exception:)];

		return NO;
	}

	return YES;
}