null engine: fix queue bug with repeated commit() calls before event retrieval
Don't return anything if min_events == 0. This exposed a bug in
the commit handler, it needs to add to ->events, not set it.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/engines/null.c b/engines/null.c
index 1988678..67ac453 100644
--- a/engines/null.c
+++ b/engines/null.c
@@ -24,14 +24,17 @@
return nd->io_us[event];
}
-static int fio_null_getevents(struct thread_data *td, int fio_unused min,
+static int fio_null_getevents(struct thread_data *td, int min_events,
int fio_unused max, struct timespec fio_unused *t)
{
struct null_data *nd = td->io_ops->data;
- int ret;
+ int ret = 0;
+
+ if (min_events) {
+ ret = nd->events;
+ nd->events = 0;
+ }
- ret = nd->events;
- nd->events = 0;
return ret;
}
@@ -39,7 +42,7 @@
{
struct null_data *nd = td->io_ops->data;
- nd->events = nd->queued;
+ nd->events += nd->queued;
nd->queued = 0;
return 0;
}