axboe / liburing

Library providing helpers for the Linux kernel io_uring support
MIT License
2.7k stars 393 forks source link

Encountered a rather peculiar issue: sqe->flags |= IOSQE_IO_LINK must be set after io_uring_prep_connect. #1125

Closed sxstd001 closed 2 months ago

sxstd001 commented 2 months ago

Encountered a rather peculiar issue where sqe->flags |= IOSQE_IO_LINK must be set after io_uring_prep_connect, otherwise it results in an Invalid argument error.

✘: io_uring_prep_link_timeout cqe.res is Invalid argument

sqe->user_data = 9901; 
sqe->flags |= IOSQE_IO_LINK;   // if before io_uring_prep_connect,  io_uring_prep_link_timeout return Invalid argument;
io_uring_prep_connect(sqe, conn.fd,  (sockaddr*)&conn.addr, sizeof(conn.addr));
....
io_uring_prep_link_timeout.....

✔ no problem;

io_uring_prep_connect(sqe, conn.fd,  (sockaddr*)&conn.addr, sizeof(conn.addr));
sqe->user_data = 9901; 
sqe->flags |= IOSQE_IO_LINK;  
....
io_uring_prep_link_timeout.....
axboe commented 2 months ago

This isn't peculiar - any io_uring_prep_foo() helper clears the SQE, setting any fields in the SQE before that will be lost.