You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用io_uring链接超时与poll_multishot时返回-EINVAL的问题咨询

io_uring链接超时与poll_multishot时返回-EINVAL的问题咨询

大家好,我最近在折腾io_uring,想实现一个带自动超时取消的poll_multishot提交逻辑,写了个函数但一直返回-EINVAL,实在找不到问题所在,想请教下各位。

我原本的思路是提交一个poll_multishot的sqe,然后链接一个超时sqe,让超时后自动取消这个poll操作,目前的函数代码如下:

int upollm(conn_t *conn, uint bit_mask, uint64_t sec, uint64_t nsec) {
   struct io_uring_sqe *sqe = io_uring_get_sqe(&ring);
   if (!sqe) return -1;

   conn->op = IORING_POLL_ADD_MULTI;
   sqe->user_data = (__u64)conn;
   sqe->flags |= IOSQE_IO_LINK;
   io_uring_prep_poll_multishot(sqe, conn->fd, bit_mask);

   sqe = io_uring_get_sqe(&ring);
   if (!sqe) return -1;
}

后续准备超时sqe的代码还没写完,但目前调用这个函数就已经返回-EINVAL了。有没有大佬能帮我分析下,是不是链接poll_multishot和超时sqe的方式有问题?或者是我哪里参数设置错了?

备注:内容来源于stack exchange,提问作者user30393367

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.13 17:34:31