[PATCH] fio: fix aio syscall returns and io_u leak on end-of-io
authorJens Axboe <axboe@suse.de>
Mon, 7 Nov 2005 15:57:33 +0000 (16:57 +0100)
committerJens Axboe <axboe@suse.de>
Mon, 7 Nov 2005 15:57:33 +0000 (16:57 +0100)
fio.c

diff --git a/fio.c b/fio.c
index 27e0e36629ca4b418702accf73f28b1a83cc0ff7..f5461514c821ecc381afda6f801a29d362470a08 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -770,8 +770,10 @@ static struct io_u *get_io_u(struct thread_data *td)
        if (!io_u)
                return NULL;
 
-       if (get_next_offset(td, &io_u->offset))
+       if (get_next_offset(td, &io_u->offset)) {
+               put_io_u(td, io_u);
                return NULL;
+       }
 
        io_u->buflen = get_next_buflen(td);
        if (!io_u->buflen) {
@@ -1030,9 +1032,9 @@ static int io_u_queue(struct thread_data *td, struct io_u *io_u)
                ret = io_submit(td->aio_ctx, 1, &iocb);
                if (ret == 1)
                        return 0;
-               else if (ret == EAGAIN)
+               else if (ret == -EAGAIN)
                        usleep(100);
-               else if (ret == EINTR)
+               else if (ret == -EINTR)
                        continue;
                else
                        break;
@@ -1228,7 +1230,7 @@ static void do_async_io(struct thread_data *td)
 
                ret = io_u_getevents(td, min_evts, td->cur_depth, timeout);
                if (ret < 0) {
-                       td->error = errno;
+                       td->error = ret;
                        break;
                } else if (!ret)
                        continue;