Skip to content

Lack of documentation regarding cancel safety on TcpStream::peek #7303

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

Open
cvengler opened this issue May 3, 2025 · 3 comments · May be fixed by #7305
Open

Lack of documentation regarding cancel safety on TcpStream::peek #7303

cvengler opened this issue May 3, 2025 · 3 comments · May be fixed by #7305
Labels
A-tokio Area: The main tokio crate C-bug Category: This is a bug. M-net Module: tokio/net T-docs Topic: documentation

Comments

@cvengler
Copy link

cvengler commented May 3, 2025

Version
latest

Platform
Documentation related

Description
Some methods in TcpStream contain a note regarding their cancel safety, such as TcpStream::readable. However, this information is not present with the TcpStream::peek method. The only reference I could find there, is that it uses the recv system call with the MSG_PEEK argument, potentially referring the user to dig into the abyss of the respective Unix manual pages.

I expected to see this happen: A subsection on cancel safety for the TcpStream::peek method.

@cvengler cvengler added A-tokio Area: The main tokio crate C-bug Category: This is a bug. labels May 3, 2025
@cvengler
Copy link
Author

cvengler commented May 3, 2025

I hope lack of documentation is considered a bug in this project. I tend to consider it as such myself but many projects handle this differently.

@cvengler
Copy link
Author

cvengler commented May 3, 2025

I assume it is cancel safe, because the documentation points out that it is just a recv system call with the MSG_PEEK flag. Given that an abortion of that single system call does not create a faulty state or something, my intuition would argue it being cancel safe.

@maminrayej
Copy link
Member

Yes, I believe TcpStream::peek is cancel safe. A PR to update the documentation is welcome.

cvengler added a commit to cvengler/tokio that referenced this issue May 4, 2025
@cvengler cvengler linked a pull request May 4, 2025 that will close this issue
@Darksonn Darksonn added T-docs Topic: documentation M-net Module: tokio/net labels May 5, 2025
cvengler added a commit to cvengler/tokio that referenced this issue May 6, 2025
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 T-docs Topic: documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants