engines/libaio: better protect against a busy loop in getevents()
authorAndrey Kuzmin <andrey.v.kuzmin@gmail.com>
Fri, 10 Oct 2014 02:14:27 +0000 (20:14 -0600)
committerJens Axboe <axboe@fb.com>
Fri, 10 Oct 2014 02:14:27 +0000 (20:14 -0600)
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 <axboe@fb.com>
engines/libaio.c

index 7c3a42a..12f3b36 100644 (file)
@@ -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)