Differences From Artifact [b099b55bf8]:
- File
src/OFKernelEventObserver.m
— part of check-in
[220513a3f5]
at
2015-05-09 18:13:19
on branch trunk
— More OFKernelEventObserver refactoring
This was necessary because select(), poll() and kevent() on FreeBSD and
OS X would sometimes return 0 events, even if there are some, and
sometimes return the correct number of events that were pending, meaning
the number of events returned is unreliable. To make things worse,
whether it returns 0 or the number of events that were pending is
completely non-deterministic on both FreeBSD and OS X (running the same
tests multiple times in a row would make it sometimes work and sometimes
fail).In order to prevent code from depending on the return value of
-[observeForTimeInterval:] (which would depend on select(), poll() and
kevent() returning the correct number), OFKernelObserver no longer
returns whether there were pending events. It is expected that
-[observe] or -[observeForTimeInterval:] is just called in a loop as
long as events should be handled.The tests have been changed as well to reflect this. What they do now is
set a deadline and call -[observeForTimeInterval:] with a small timeout
in a loop until the deadline is reached or all events have been handled.Note: DragonFlyBSD has not been tested, but will most likely behave like
FreeBSD and OS X. (user: js, size: 7927) [annotate] [blame] [check-ins using]
To Artifact [b0c771eac2]:
- File
src/OFKernelEventObserver.m
— part of check-in
[4cecf82254]
at
2015-10-04 11:11:28
on branch trunk
— Special cases for the Wii's weird network stack
This fixes the tests on Wii. (user: js, size: 8177) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
58 59 60 61 62 63 64 65 66 67 68 69 70 71 | enum { QUEUE_ADD = 0, QUEUE_REMOVE = 1, QUEUE_READ = 0, QUEUE_WRITE = 2 }; #define QUEUE_ACTION (QUEUE_ADD | QUEUE_REMOVE) @implementation OFKernelEventObserver + (void)initialize { if (self != [OFKernelEventObserver class]) return; | > > > > > | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | enum { QUEUE_ADD = 0, QUEUE_REMOVE = 1, QUEUE_READ = 0, QUEUE_WRITE = 2 }; #define QUEUE_ACTION (QUEUE_ADD | QUEUE_REMOVE) #ifdef __wii__ /* FIXME: Add a port registry for Wii */ static uint16_t freePort = 65535; #endif @implementation OFKernelEventObserver + (void)initialize { if (self != [OFKernelEventObserver class]) return; |
︙ | ︙ | |||
124 125 126 127 128 129 130 131 | exceptionWithClass: [self class]]; _cancelAddr.sin_family = AF_INET; _cancelAddr.sin_port = 0; _cancelAddr.sin_addr.s_addr = inet_addr("127.0.0.1"); # ifdef __wii__ /* The Wii does not accept port 0 as "choose any free port" */ | > | | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | exceptionWithClass: [self class]]; _cancelAddr.sin_family = AF_INET; _cancelAddr.sin_port = 0; _cancelAddr.sin_addr.s_addr = inet_addr("127.0.0.1"); # ifdef __wii__ _cancelAddr.sin_len = 8; /* The Wii does not accept port 0 as "choose any free port" */ _cancelAddr.sin_port = freePort--; # endif if (bind(_cancelFD[0], (struct sockaddr*)&_cancelAddr, sizeof(_cancelAddr))) @throw [OFInitializationFailedException exceptionWithClass: [self class]]; |
︙ | ︙ | |||
351 352 353 354 355 356 357 | } - (void)cancel { #ifdef OF_HAVE_PIPE OF_ENSURE(write(_cancelFD[1], "", 1) > 0); #else | > | | > > > > | 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | } - (void)cancel { #ifdef OF_HAVE_PIPE OF_ENSURE(write(_cancelFD[1], "", 1) > 0); #else # ifndef __wii__ OF_ENSURE(sendto(_cancelFD[1], "", 1, 0, (struct sockaddr*)&_cancelAddr, sizeof(_cancelAddr)) > 0); # else OF_ENSURE(sendto(_cancelFD[1], "", 1, 0, (struct sockaddr*)&_cancelAddr, 8) > 0); # endif #endif } - (void)OF_processReadBuffers { id const *objects = [_readObjects objects]; size_t i, count = [_readObjects count]; |
︙ | ︙ |