ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev_linuxaio.c
(Generate patch)

Comparing libev/ev_linuxaio.c (file contents):
Revision 1.16 by root, Mon Jun 24 00:30:24 2019 UTC vs.
Revision 1.18 by root, Mon Jun 24 04:54:08 2019 UTC

198 linuxaio_iocbps [fd]->io.aio_buf = 0; 198 linuxaio_iocbps [fd]->io.aio_buf = 0;
199 anfds [fd].events = 0; 199 anfds [fd].events = 0;
200 fd_change (EV_A_ fd, 0); 200 fd_change (EV_A_ fd, 0);
201 201
202 /* feed events, we do not expect or handle POLLNVAL */ 202 /* feed events, we do not expect or handle POLLNVAL */
203 if (ecb_expect_false (res & POLLNVAL)) 203 if (expect_false (res & POLLNVAL))
204 fd_kill (EV_A_ fd); 204 fd_kill (EV_A_ fd);
205 else 205 else
206 fd_event ( 206 fd_event (
207 EV_A_ 207 EV_A_
208 fd, 208 fd,
229 229
230 if (head == tail) 230 if (head == tail)
231 return 0; 231 return 0;
232 232
233 /* bail out if the ring buffer doesn't match the expected layout */ 233 /* bail out if the ring buffer doesn't match the expected layout */
234 if (ecb_expect_false (ring->magic != AIO_RING_MAGIC) 234 if (expect_false (ring->magic != AIO_RING_MAGIC)
235 || ring->incompat_features != AIO_RING_INCOMPAT_FEATURES 235 || ring->incompat_features != AIO_RING_INCOMPAT_FEATURES
236 || ring->header_length != sizeof (struct aio_ring)) /* TODO: or use it to find io_event[0]? */ 236 || ring->header_length != sizeof (struct aio_ring)) /* TODO: or use it to find io_event[0]? */
237 return 0; 237 return 0;
238 238
239 /* make sure the events up to tail are visible */ 239 /* make sure the events up to tail are visible */
240 ECB_MEMORY_FENCE_ACQUIRE; 240 ECB_MEMORY_FENCE_ACQUIRE;
241 241
262inline_size 262inline_size
263void 263void
264linuxaio_get_events (EV_P_ ev_tstamp timeout) 264linuxaio_get_events (EV_P_ ev_tstamp timeout)
265{ 265{
266 struct timespec ts; 266 struct timespec ts;
267 struct io_event ioev; 267 struct io_event ioev[1];
268 int res; 268 int res;
269 269
270 if (linuxaio_get_events_from_ring (EV_A)) 270 if (linuxaio_get_events_from_ring (EV_A))
271 return; 271 return;
272 272
275 /* if the ring buffer changes layout, but so be it */ 275 /* if the ring buffer changes layout, but so be it */
276 276
277 ts.tv_sec = (long)timeout; 277 ts.tv_sec = (long)timeout;
278 ts.tv_nsec = (long)((timeout - ts.tv_sec) * 1e9); 278 ts.tv_nsec = (long)((timeout - ts.tv_sec) * 1e9);
279 279
280 res = ev_io_getevents (linuxaio_ctx, 1, 1, &ioev, &ts); 280 res = ev_io_getevents (linuxaio_ctx, 1, sizeof (ioev) / sizeof (ioev [0]), ioev, &ts);
281 281
282 if (res < 0) 282 if (res < 0)
283 if (errno == EINTR) 283 if (errno == EINTR)
284 /* ignored */; 284 /* ignored */;
285 else 285 else
286 ev_syserr ("(libev) linuxaio io_getevents"); 286 ev_syserr ("(libev) linuxaio io_getevents");
287 else if (res) 287 else if (res)
288 { 288 {
289 /* at least one event received, handle it and any remaining ones in the ring buffer */ 289 /* at least one event received, handle it and any remaining ones in the ring buffer */
290 linuxaio_parse_events (EV_A_ &ioev, 1); 290 linuxaio_parse_events (EV_A_ ioev, res);
291 linuxaio_get_events_from_ring (EV_A); 291 linuxaio_get_events_from_ring (EV_A);
292 } 292 }
293} 293}
294 294
295#if EPOLL_FALLBACK 295#if EPOLL_FALLBACK
320 /* which allows us to pinpoint the errornous iocb */ 320 /* which allows us to pinpoint the errornous iocb */
321 for (submitted = 0; submitted < linuxaio_submitcnt; ) 321 for (submitted = 0; submitted < linuxaio_submitcnt; )
322 { 322 {
323 int res = ev_io_submit (linuxaio_ctx, linuxaio_submitcnt - submitted, linuxaio_submits + submitted); 323 int res = ev_io_submit (linuxaio_ctx, linuxaio_submitcnt - submitted, linuxaio_submits + submitted);
324 324
325 if (ecb_expect_false (res < 0)) 325 if (expect_false (res < 0))
326 if (errno == EAGAIN) 326 if (errno == EAGAIN)
327 { 327 {
328 /* This happens when the ring buffer is full, at least. I assume this means 328 /* This happens when the ring buffer is full, at least. I assume this means
329 * that the event was queued synchronously during io_submit, and thus 329 * that the event was queued synchronously during io_submit, and thus
330 * the buffer overflowed. 330 * the buffer overflowed.
376 for (;;) 376 for (;;)
377 { 377 {
378 int idx; 378 int idx;
379 int res = epoll_wait (backend_fd, events, sizeof (events) / sizeof (events [0]), 0); 379 int res = epoll_wait (backend_fd, events, sizeof (events) / sizeof (events [0]), 0);
380 380
381 if (ecb_expect_false (res < 0)) 381 if (expect_false (res < 0))
382 ev_syserr ("(libev) linuxaio epoll_wait"); 382 ev_syserr ("(libev) linuxaio epoll_wait");
383 else if (!res) 383 else if (!res)
384 break; 384 break;
385 385
386 for (idx = res; idx--; ) 386 for (idx = res; idx--; )

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines