ObjFW  Check-in [61cad3ee76]

Overview
Comment:Call -[releaseObjects] after calling the delegate.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 61cad3ee76909c206e2fafcba18ef6fc49a548fd9064f06b754949ee8c169a25
User & Date: js on 2011-04-01 17:10:45
Other Links: manifest | tags
Context
2011-04-01
22:14
Cancel the currently blocking -[observe] when the stream set is changed. check-in: a61ab37726 user: js tags: trunk
17:10
Call -[releaseObjects] after calling the delegate. check-in: 61cad3ee76 user: js tags: trunk
16:54
Make OFStreamObserver thread-safe. check-in: 35aab77af3 user: js tags: trunk
Changes

Modified src/OFStreamObserver.m from [bf14750714] to [95f2f3be53].

329
330
331
332
333
334
335

336
337
338
339
340
341
342
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343







+







	cArray = [readStreams cArray];
	count = [readStreams count];

	for (i = 0; i < count; i++) {
		if (cArray[i]->cache != NULL) {
			[delegate streamDidBecomeReadyForReading: cArray[i]];
			foundInCache = YES;
			[pool releaseObjects];
		}
	}

	/*
	 * As long as we have data in the cache for any stream, we don't want
	 * to block.
	 */
357
358
359
360
361
362
363

364
365
366
367
368
369

370
371
372
373
374
375

376
377
378
379
380
381
382
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386







+






+






+







		OFNumber *num;
		OFStream *stream;

		if (fds_c[i].revents & POLLIN) {
			num = [OFNumber numberWithInt: fds_c[i].fd];
			stream = [fdToStream objectForKey: num];
			[delegate streamDidBecomeReadyForReading: stream];
			[pool releaseObjects];
		}

		if (fds_c[i].revents & POLLOUT) {
			num = [OFNumber numberWithInt: fds_c[i].fd];
			stream = [fdToStream objectForKey: num];
			[delegate streamDidBecomeReadyForReading: stream];
			[pool releaseObjects];
		}

		if (fds_c[i].revents & POLLERR) {
			num = [OFNumber numberWithInt: fds_c[i].fd];
			stream = [fdToStream objectForKey: num];
			[delegate streamDidReceiveException: stream];
			[pool releaseObjects];
		}

		fds_c[i].revents = 0;
	}
#else
# ifdef FD_COPY
	FD_COPY(&readfds, &readfds_);
391
392
393
394
395
396
397
398

399


400
401
402

403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418

419

420
421



422


423
424
425
426
427
428
429
395
396
397
398
399
400
401

402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424

425
426
427


428
429
430
431
432
433
434
435
436
437
438
439
440







-
+

+
+



+















-
+

+
-
-
+
+
+

+
+







	if (select(nfds, &readfds_, &writefds_, &exceptfds_,
	    (timeout != -1 ? &tv : NULL)) < 1)
		return NO;

	for (i = 0; i < count; i++) {
		int fd = [cArray[i] fileDescriptor];

		if (FD_ISSET(fd, &readfds_))
		if (FD_ISSET(fd, &readfds_)) {
			[delegate streamDidBecomeReadyForReading: cArray[i]];
			[pool releaseObjects];
		}

		if (FD_ISSET(fd, &exceptfds_)) {
			[delegate streamDidReceiveException: cArray[i]];
			[pool releaseObjects];

			/*
			 * Prevent calling it twice in case the fd is in both
			 * sets.
			 */
			FD_CLR(fd, &exceptfds_);
		}
	}

	cArray = [writeStreams cArray];
	count = [writeStreams count];

	for (i = 0; i < count; i++) {
		int fd = [cArray[i] fileDescriptor];

		if (FD_ISSET(fd, &writefds_))
		if (FD_ISSET(fd, &writefds_)) {
			[delegate streamDidBecomeReadyForWriting: cArray[i]];
			[pool releaseObjects];

		if (FD_ISSET(fd, &exceptfds_))
		}

		if (FD_ISSET(fd, &exceptfds_)) {
			[delegate streamDidReceiveException: cArray[i]];
			[pool releaseObjects];
		}
	}
#endif

	[pool release];

	return YES;
}