Differences From Artifact [46057c9c67]:
- File src/OFKernelEventObserver_select.m — part of check-in [1ba08eebc5] at 2015-10-19 22:15:13 on branch trunk — Add platform.h & make platform defines consistent (user: js, size: 4908) [annotate] [blame] [check-ins using]
To Artifact [8f0b3058db]:
- File
src/OFKernelEventObserver_select.m
— part of check-in
[e9b4700cb6]
at
2015-12-29 21:33:07
on branch trunk
— Refactor OFKernelEventObserver
This moves the locked queue for actions to
OFKernelEventObserver_LockedQueue, which is now used for select and
poll, but skipped for kqueue and epoll, as they natively support changes
from another thread.This fixes the problem that removing an object is delayed until the next
observe call - at which point it might have already been closed, meaning
the fd is no longer available. This was mainly a problem with kqueue, as
closing the fd already removed it from the kqueue, which then resulted
in an error being returned when trying to manually remove the fd from
the kqueue. (user: js, size: 4812) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
61 62 63 64 65 66 67 | _maxFD = (int)_cancelFD[0]; return self; } - (void)OF_addObjectForReading: (id)object | < | | < | | > < < > < < | 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | _maxFD = (int)_cancelFD[0]; return self; } - (void)OF_addObjectForReading: (id)object fileDescriptor: (int)fd { if (fd < 0 || fd > INT_MAX - 1) @throw [OFOutOfRangeException exception]; #ifndef OF_WINDOWS if (fd >= FD_SETSIZE) @throw [OFOutOfRangeException exception]; #endif if (fd > _maxFD) _maxFD = fd; FD_SET(fd, &_readFDs); } - (void)OF_addObjectForWriting: (id)object fileDescriptor: (int)fd { if (fd < 0 || fd > INT_MAX - 1) @throw [OFOutOfRangeException exception]; #ifndef OF_WINDOWS if (fd >= FD_SETSIZE) @throw [OFOutOfRangeException exception]; #endif if (fd > _maxFD) _maxFD = fd; FD_SET(fd, &_writeFDs); } - (void)OF_removeObjectForReading: (id)object fileDescriptor: (int)fd { /* TODO: Adjust _maxFD */ if (fd < 0) @throw [OFOutOfRangeException exception]; #ifndef OF_WINDOWS if (fd >= FD_SETSIZE) @throw [OFOutOfRangeException exception]; #endif FD_CLR(fd, &_readFDs); } - (void)OF_removeObjectForWriting: (id)object fileDescriptor: (int)fd { /* TODO: Adjust _maxFD */ if (fd < 0) @throw [OFOutOfRangeException exception]; #ifndef OF_WINDOWS if (fd >= FD_SETSIZE) @throw [OFOutOfRangeException exception]; #endif |
︙ | ︙ | |||
140 141 142 143 144 145 146 | id const *objects; fd_set readFDs; fd_set writeFDs; struct timeval timeout; int events; size_t i, count; | | | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | id const *objects; fd_set readFDs; fd_set writeFDs; struct timeval timeout; int events; size_t i, count; [self OF_processQueue]; [self OF_processReadBuffers]; objc_autoreleasePoolPop(pool); #ifdef FD_COPY FD_COPY(&_readFDs, &readFDs); FD_COPY(&_writeFDs, &writeFDs); |
︙ | ︙ |