Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unreadable AsyncFd cannot be polled correctly with Interest::READABLE with epoll on Linux #6632

Open
XOR-op opened this issue Jun 12, 2024 · 1 comment
Labels
A-tokio Area: The main tokio crate C-bug Category: This is a bug. M-io Module: tokio/io

Comments

@XOR-op
Copy link

XOR-op commented Jun 12, 2024

Version
tokio v1.38.0

Platform
Linux 5.11.0-25-generic, Ubuntu 20.04.1

Description
The file descriptor refers to a kernel module, which is not readable but pollable. Calling libc::read on it will receive a EINVAL error. However, this file descriptor supports epoll, and can be correctly polled by EPOLLIN, without any EPOLLERR event triggered. The behaviors of AsyncFd and epoll mismatched.

The following code will hang infinitely while manual calling to epoll will return correct event count:

async_fd.ready(Interest::READABLE | Interest::PRIORITY).await

The following code will return immediately, while no events will be received even if EPOLLERR is registered:

async_fd.ready(Interest::READABLE | Interest::PRIORITY | Interest::ERROR).await

It turns out AsyncFd thinks there are some errors while no error is from epoll.

I hope to know if this is the expected behavior; if it is, is there any workaround to get the same behavior with epoll?

@XOR-op XOR-op added A-tokio Area: The main tokio crate C-bug Category: This is a bug. labels Jun 12, 2024
@Darksonn Darksonn added the M-io Module: tokio/io label Jun 13, 2024
@Darksonn
Copy link
Contributor

The fact that libc::read doesn't work is not an issue, and AsyncFd will not try to call it. However, I'm not sure what the actual issue is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-bug Category: This is a bug. M-io Module: tokio/io
Projects
None yet
Development

No branches or pull requests

2 participants