From: Andrey Kuzmin Date: Fri, 10 Oct 2014 02:14:27 +0000 (-0600) Subject: engines/libaio: better protect against a busy loop in getevents() X-Git-Tag: fio-2.1.14~69 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=3441a52d588b95267f31491d4dca5f1418b1dcf5 engines/libaio: better protect against a busy loop in getevents() If we reap nothing and we were asked to reap > 0 events, then reuse our commit, sleep, and retry loop. Signed-off-by: Jens Axboe --- diff --git a/engines/libaio.c b/engines/libaio.c index 7c3a42a4..12f3b366 100644 --- a/engines/libaio.c +++ b/engines/libaio.c @@ -165,9 +165,9 @@ static int fio_libaio_getevents(struct thread_data *td, unsigned int min, r = io_getevents(ld->aio_ctx, actual_min, max, ld->aio_events + events, lt); } - if (r >= 0) + if (r > 0) events += r; - else if (r == -EAGAIN) { + else if ((min && r == 0) || r == -EAGAIN) { fio_libaio_commit(td); usleep(100); } else if (r != -EINTR)