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.40 by root, Mon Jul 1 20:35:17 2019 UTC vs.
Revision 1.41 by root, Mon Jul 1 20:41:46 2019 UTC

286linuxaio_modify (EV_P_ int fd, int oev, int nev) 286linuxaio_modify (EV_P_ int fd, int oev, int nev)
287{ 287{
288 array_needsize (ANIOCBP, linuxaio_iocbps, linuxaio_iocbpmax, fd + 1, linuxaio_array_needsize_iocbp); 288 array_needsize (ANIOCBP, linuxaio_iocbps, linuxaio_iocbpmax, fd + 1, linuxaio_array_needsize_iocbp);
289 ANIOCBP iocb = linuxaio_iocbps [fd]; 289 ANIOCBP iocb = linuxaio_iocbps [fd];
290 290
291 if (iocb->io.aio_reqprio < 0) 291 if (expect_false (iocb->io.aio_reqprio < 0))
292 { 292 {
293 /* we handed this fd over to epoll, so undo this first */ 293 /* we handed this fd over to epoll, so undo this first */
294 /* we do it manually because the optimisations on epoll_modify won't do us any good */ 294 /* we do it manually because the optimisations on epoll_modify won't do us any good */
295 epoll_ctl (backend_fd, EPOLL_CTL_DEL, fd, 0); 295 epoll_ctl (backend_fd, EPOLL_CTL_DEL, fd, 0);
296 anfds [fd].emask = 0; 296 anfds [fd].emask = 0;
297 iocb->io.aio_reqprio = 0; 297 iocb->io.aio_reqprio = 0;
298 } 298 }
299 299
300 if (iocb->io.aio_buf) 300 if (expect_false (iocb->io.aio_buf))
301 { 301 {
302 /* iocb active, so cancel it first before resubmit */
302 for (;;) 303 for (;;)
303 { 304 {
304 /* on all relevant kernels, io_cancel fails with EINPROGRESS on "success" */ 305 /* on all relevant kernels, io_cancel fails with EINPROGRESS on "success" */
305 if (expect_false (evsys_io_cancel (linuxaio_ctx, &iocb->io, (struct io_event *)0) == 0)) 306 if (expect_false (evsys_io_cancel (linuxaio_ctx, &iocb->io, (struct io_event *)0) == 0))
306 break; 307 break;
311 /* the EINPROGRESS test is for nicer error message. clumsy. */ 312 /* the EINPROGRESS test is for nicer error message. clumsy. */
312 assert (("libev: linuxaio unexpected io_cancel failed", errno != EINPROGRESS && errno != EINTR)); 313 assert (("libev: linuxaio unexpected io_cancel failed", errno != EINPROGRESS && errno != EINTR));
313 } 314 }
314 } 315 }
315 316
317 iocb->io.aio_buf =
318 (nev & EV_READ ? POLLIN : 0)
319 | (nev & EV_WRITE ? POLLOUT : 0);
320
316 if (nev) 321 if (nev)
317 { 322 {
318 iocb->io.aio_buf =
319 (nev & EV_READ ? POLLIN : 0)
320 | (nev & EV_WRITE ? POLLOUT : 0);
321
322 /* queue iocb up for io_submit */ 323 /* queue iocb up for io_submit */
323 /* this assumes we only ever get one call per fd per loop iteration */ 324 /* this assumes we only ever get one call per fd per loop iteration */
324 ++linuxaio_submitcnt; 325 ++linuxaio_submitcnt;
325 array_needsize (struct iocb *, linuxaio_submits, linuxaio_submitmax, linuxaio_submitcnt, array_needsize_noinit); 326 array_needsize (struct iocb *, linuxaio_submits, linuxaio_submitmax, linuxaio_submitcnt, array_needsize_noinit);
326 linuxaio_submits [linuxaio_submitcnt - 1] = &iocb->io; 327 linuxaio_submits [linuxaio_submitcnt - 1] = &iocb->io;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines