summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHongnan Li <hongnan.li@linux.alibaba.com>2020-07-07 17:46:11 +0800
committerJens Axboe <axboe@kernel.dk>2020-07-07 09:03:31 -0600
commit531d76936714dee3f64e325c90545ef232f38b69 (patch)
treea44f826d663664527d642f81dcd77976a4051375
parente30d9ade76d307b5b3e35965434c5f07eb1fbfa8 (diff)
downloadliburing-531d76936714dee3f64e325c90545ef232f38b69.tar.gz
liburing-531d76936714dee3f64e325c90545ef232f38b69.tar.bz2
compat_libaio.c: get correct io_event data from cqe->user_data
cqe->user_data is a point to struct io_completion,not struct iocb. Signed-off-by: Hongnan Li <hongnan.li@linux.alibaba.com>
-rw-r--r--src/compat_libaio.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/compat_libaio.c b/src/compat_libaio.c
index a60a6c5..9001509 100644
--- a/src/compat_libaio.c
+++ b/src/compat_libaio.c
@@ -265,6 +265,7 @@ static int __io_getevents(struct io_context *ctx, long min_nr, long nr,
struct io_uring *ring = &ctx->ring;
struct io_uring_cqe *cqe;
int ret, total = 0;
+ struct io_completion *ic;
if (!nr)
return 0;
@@ -273,6 +274,7 @@ static int __io_getevents(struct io_context *ctx, long min_nr, long nr,
pthread_mutex_lock(&ctx->complete_lock);
ret = 0;
+ ic = malloc(sizeof(*ic));
while (nr) {
struct io_event *ev = &events[total];
@@ -286,8 +288,9 @@ static int __io_getevents(struct io_context *ctx, long min_nr, long nr,
break;
}
- ev->data = NULL;
- ev->obj = io_uring_cqe_get_data(cqe);
+ ic = io_uring_cqe_get_data(cqe);
+ ev->data = ic->data;
+ ev->obj = ic->iocb;
ev->res = cqe->res;
ev->res2 = 0;
io_uring_cqe_seen(ring, cqe);
@@ -296,7 +299,7 @@ static int __io_getevents(struct io_context *ctx, long min_nr, long nr,
if (min_nr)
min_nr--;
};
-
+ free(ic);
pthread_mutex_unlock(&ctx->complete_lock);
return total ? total : ret;
}