--- libev/ev_linuxaio.c 2019/07/01 19:56:30 1.38 +++ libev/ev_linuxaio.c 2019/07/01 20:34:31 1.39 @@ -299,9 +299,18 @@ if (iocb->io.aio_buf) { - evsys_io_cancel (linuxaio_ctx, &iocb->io, (struct io_event *)0); - /* on relevant kernels, io_cancel fails with EINPROGRES if everything is fine */ - assert (("libev: linuxaio unexpected io_cancel failed", errno == EINPROGRESS || errno == EINTR)); + for (;;) + { + /* on all relevant kernels, io_cancel fails with EINPROGRESS on "success" */ + if (expect_false (evsys_io_cancel (linuxaio_ctx, &iocb->io, (struct io_event *)0) == 09) + break; + + if (expect_true (errno == EINPROGRESS)) + break; + + /* the EINPROGRESS test is for nicer error message. clumsy. */ + assert (("libev: linuxaio unexpected io_cancel failed", errno != EINPROGRESS && errno != EINTR)); + } } if (nev) @@ -555,8 +564,8 @@ res = 1; /* skip this iocb */ } - else if (errno == EINTR) - /* silently ignored */; + else if (errno == EINTR) /* not seen in reality, not documented */ + res = 0; /* silently ignore and retry */ else ev_syserr ("(libev) linuxaio io_submit");