Reputation: 129
I am using asynchronous IO api in my project, i am confused of the parameters io_event.res
and io_event.res2
it seams that res means the io size, but what's the meaning of res2. Comments that i found in the file /usr/include/linux/aio.abi.h
help nothing.
I will appriciate it so much if anyone explain that and shwo us an example.
/* read() from /dev/aio returns these structures. */
struct io_event {
__u64 data; /* the data field from the iocb */
__u64 obj; /* what iocb this event came from */
__s64 res; /* result code for this event */
__s64 res2; /* secondary result */
};
my code as below
size_t nevents = 2;
struct io_event events[nevents];
ret = io_getevents(ioctx, 1, nevents, events, NULL);
if (ret < 0) {
perror("io_getevents");
exit(1);
}
for (size_t i=0; i<ret; i++) {
struct io_event *ev = &events[i];
printf("Event returned with res=%lld res2=%lld\n", ev->res, ev->res2);
nevents--;
}
Upvotes: 0
Views: 995
Reputation: 11
res return the size of succeed io operation. if failed,res return the negative errno
Upvotes: 1