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

net: Consider having from_std panic on blocking sockets #7172

Open
carllerche opened this issue Feb 24, 2025 · 1 comment
Open

net: Consider having from_std panic on blocking sockets #7172

carllerche opened this issue Feb 24, 2025 · 1 comment
Labels
A-tokio Area: The main tokio crate C-proposal Category: a proposal and request for comments M-net Module: tokio/net S-breaking-change A breaking change that requires manual coordination to be released.

Comments

@carllerche
Copy link
Member

While Tokio technically accepts and can function using blocking sockets, it usually results in poor and unexpected runtime behaviors. There is most likely no good reason to pass a blocking socket to from_std. Accidentally passing blocking sockets to from_std is a common error that results in hard-to-debug runtime behaviors.

Because Tokio has historically technically accepted blocking sockets to be passed to from_std, changing the behavior to panic on blocking sockets could be considered a breaking change. We are considering making that change anyway because we are not aware of any valid usage.

As a first step, we changed Tokio to panic when passing a blocking socket to from_std and debug assertions are enabled. Use the tokio_allow_from_blocking_fd cfg flag to disable this assertion.

If you have a valid use case for passing blocking sockets to from_std, please comment in this thread.

@carllerche carllerche added A-tokio Area: The main tokio crate C-proposal Category: a proposal and request for comments M-net Module: tokio/net S-breaking-change A breaking change that requires manual coordination to be released. labels Feb 24, 2025
@carllerche carllerche pinned this issue Feb 24, 2025
@Darksonn
Copy link
Contributor

This is being implemented in #7166. Please also see #5595 that tracks the problem that this proposal is intended to solve.

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-proposal Category: a proposal and request for comments M-net Module: tokio/net S-breaking-change A breaking change that requires manual coordination to be released.
Projects
None yet
Development

No branches or pull requests

2 participants