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
|
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
|
-
+
-
+
-
+
-
-
+
+
-
+
|
OF_ENSURE(write(_cancelFD[1], "", 1) > 0);
#else
OF_ENSURE(sendto(_cancelFD[1], "", 1, 0, (struct sockaddr*)&_cancelAddr,
sizeof(_cancelAddr)) > 0);
#endif
}
- (bool)OF_processCache
- (bool)OF_processReadBuffers
{
id const *objects = [_readObjects objects];
size_t i, count = [_readObjects count];
bool foundInCache = false;
bool foundInReadBuffer = false;
for (i = 0; i < count; i++) {
void *pool = objc_autoreleasePoolPush();
if ([objects[i] isKindOfClass: [OFStream class]] &&
[objects[i] hasDataInReadBuffer] &&
![objects[i] OF_isWaitingForDelimiter]) {
if ([_delegate respondsToSelector:
@selector(objectIsReadyForReading:)])
[_delegate objectIsReadyForReading: objects[i]];
foundInCache = true;
foundInReadBuffer = true;
}
objc_autoreleasePoolPop(pool);
}
/*
* As long as we have data in the cache for any stream, we don't want
* to block.
* As long as we have data in the read buffer for any stream, we don't
* want to block.
*/
if (foundInCache)
if (foundInReadBuffer)
return true;
return false;
}
@end
|