Overview
Comment: | OFPollKernelEventObserver: Copy FDs
This allows them to be modified while they are still being processed. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
7e9f70c47733ad6d7bb889143754bbda |
User & Date: | js on 2020-01-13 00:18:40 |
Other Links: | manifest | tags |
Context
2020-01-14
| ||
00:16 | More consistent -[close] behavior check-in: 3b43d51006 user: js tags: trunk | |
2020-01-13
| ||
00:18 | OFPollKernelEventObserver: Copy FDs check-in: 7e9f70c477 user: js tags: trunk | |
2020-01-12
| ||
17:37 | OFHTTPClient: Always keep the underlying socket check-in: b4810363ea user: js tags: trunk | |
Changes
Modified src/OFPollKernelEventObserver.m from [22bca879fa] to [0607878a6c].
︙ | ︙ | |||
158 159 160 161 162 163 164 165 166 167 168 169 170 171 | events: POLLOUT]; [super removeObjectForWriting: object]; } - (void)observeForTimeInterval: (of_time_interval_t)timeInterval { struct pollfd *FDs; int events; size_t nFDs; if ([self of_processReadBuffers]) return; | > > | > | | | | | | > > | 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 | events: POLLOUT]; [super removeObjectForWriting: object]; } - (void)observeForTimeInterval: (of_time_interval_t)timeInterval { void *pool; struct pollfd *FDs; int events; size_t nFDs; if ([self of_processReadBuffers]) return; pool = objc_autoreleasePoolPush(); FDs = [[[_FDs mutableCopy] autorelease] mutableItems]; nFDs = _FDs.count; #ifdef OPEN_MAX if (nFDs > OPEN_MAX) @throw [OFOutOfRangeException exception]; #endif events = poll(FDs, (nfds_t)nFDs, (int)(timeInterval != -1 ? timeInterval * 1000 : -1)); if (events < 0) @throw [OFObserveFailedException exceptionWithObserver: self errNo: errno]; for (size_t i = 0; i < nFDs; i++) { assert(FDs[i].fd <= _maxFD); if (FDs[i].revents & POLLIN) { void *pool2; if (FDs[i].fd == _cancelFD[0]) { char buffer; #ifdef OF_HAVE_PIPE OF_ENSURE(read(_cancelFD[0], &buffer, 1) == 1); #else OF_ENSURE(recvfrom(_cancelFD[0], &buffer, 1, 0, NULL, NULL) == 1); #endif FDs[i].revents = 0; continue; } pool2 = objc_autoreleasePoolPush(); if ([_delegate respondsToSelector: @selector(objectIsReadyForReading:)]) [_delegate objectIsReadyForReading: _FDToObject[FDs[i].fd]]; objc_autoreleasePoolPop(pool2); } if (FDs[i].revents & (POLLOUT | POLLHUP)) { void *pool2 = objc_autoreleasePoolPush(); if ([_delegate respondsToSelector: @selector(objectIsReadyForWriting:)]) [_delegate objectIsReadyForWriting: _FDToObject[FDs[i].fd]]; objc_autoreleasePoolPop(pool2); } FDs[i].revents = 0; } objc_autoreleasePoolPop(pool); } @end |