From 3441a52d588b95267f31491d4dca5f1418b1dcf5 Mon Sep 17 00:00:00 2001 From: Andrey Kuzmin Date: Thu, 9 Oct 2014 20:14:27 -0600 Subject: [PATCH] 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 --- engines/libaio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) -- 2.25.1