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) {
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;
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;