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

Interest::PRIORITY never ready on TcpStream #5784

Open
leftmostcat opened this issue Jun 10, 2023 · 0 comments
Open

Interest::PRIORITY never ready on TcpStream #5784

leftmostcat opened this issue Jun 10, 2023 · 0 comments
Labels
A-tokio Area: The main tokio crate C-bug Category: This is a bug. M-net Module: tokio/net

Comments

@leftmostcat
Copy link

leftmostcat commented Jun 10, 2023

Version
Current trunk.

Platform
Linux 6.3.6-200.fc38.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jun 5 15:45:04 UTC 2023 x86_64 GNU/Linux

Description
I have created a tokio TcpStream with the following code:

#[tokio::main]
async fn main() -> std::io::Result<()> {
    let addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080);
    let listener = TcpListener::bind(&addr).await?;

    println!("Awaiting listener");
    let (stream, _) = listener.accept().await?;

    println!("Awaiting priority");
    stream.ready(Interest::PRIORITY).await?;

    println!("Received");
}

Connecting to the resulting listener with telnet and issuing a send synch command, I expect to see "Received" in the output and for the the program to terminate. Instead, the stream.ready() future never completes.

At present, TcpListener::accept() ends up calling PollEvented::new() via TcpStream::new(), which registers Interest::READABLE and Interest::WRITABLE explicitly, but does not provide for Interest::PRIORITY.

AsyncFd provides a with_interest() function to allow for asking for Interest::PRIORITY; should there similarly be an accept_with_interest() on TcpListener to forward to TcpStream, coupled with a connect_with_interest() on TcpStream for the other direction?

@leftmostcat leftmostcat added A-tokio Area: The main tokio crate C-bug Category: This is a bug. labels Jun 10, 2023
@Darksonn Darksonn added the M-net Module: tokio/net label Jun 11, 2023
leftmostcat added a commit to leftmostcat/tokio that referenced this issue Jun 14, 2023
With the addition of Interest::PRIORITY, it is possible to ask `ready()`
to wake on urgent data. However, because `PollEvented` is set up with
only read/write interest, `ready()`'s future will never complete.

Add support for specifying custom interest in the creation of
`PollEvented` to allow `ready()` to correctly poll for urgent.

Fixes: tokio-rs#5784
leftmostcat added a commit to leftmostcat/tokio that referenced this issue Jun 15, 2023
With the addition of Interest::PRIORITY, it is possible to ask `ready()`
to wake on urgent data. However, because `PollEvented` is set up with
only read/write interest, `ready()`'s future will never complete.

Add support for specifying custom interest in the creation of
`PollEvented` to allow `ready()` to correctly poll for urgent.

Fixes: tokio-rs#5784
leftmostcat added a commit to leftmostcat/tokio that referenced this issue Jun 15, 2023
With the addition of Interest::PRIORITY, it is possible to ask `ready()`
to wake on urgent data. However, because `PollEvented` is set up with
only read/write interest, `ready()`'s future will never complete.

Add support for specifying custom interest in the creation of
`PollEvented` to allow `ready()` to correctly poll for urgent.

Fixes: tokio-rs#5784
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-net Module: tokio/net
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants