From 1e5e50e44df26a15268132dc14b5d3d9cda178ff Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Thu, 29 Nov 2012 02:46:10 +0100 Subject: Fixes bugs in AIO mode --- seqreader.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/seqreader.c b/seqreader.c index 55a7370..78d7eae 100644 --- a/seqreader.c +++ b/seqreader.c @@ -134,8 +134,17 @@ int main(int argc, char *argv[]) { ready = 0; while (1) { if (!done[curio%(AIO_MODE + EXTRA_BUFFERS)]) { - err = io_getevents(aio, 1, AIO_MODE - events, &ev[events], NULL); - if (err < 0) perror("Error waiting for AIO\n"); +// printf("%i,%i - %i [%i %i %i %i]\n", curio, schedio, events, done[0], done[1], done[2], done[3]); + + if (curio < schedio) { + err = io_getevents(aio, 1, AIO_MODE + EXTRA_BUFFERS - events, &ev[events], NULL); + if (err < 0) { + printf("Error waiting for AIO (%i)\n", -err); + exit(-1); + } + } else { + err = 0; + } if ((!ready)&&(err > 1)) { printf("*** Multiple read requests (%i of %i) are finished simultaneously. It is either:\n", err, AIO_MODE); @@ -154,6 +163,7 @@ int main(int argc, char *argv[]) { events += err; for (i = events - 1; (i >= 0)&&((schedio - curio) < (AIO_MODE + EXTRA_BUFFERS)); i--) { +// printf("sched (%i): %i\n", i, schedio); struct iocb *newio = (struct iocb *)ev[i].obj; memset(newio, 0, sizeof(struct iocb)); io_prep_pread(newio, fd, buffer + (schedio % (AIO_MODE + EXTRA_BUFFERS)) * BLOCK_SIZE, BLOCK_SIZE, schedio * BLOCK_SIZE); -- cgit v1.2.3