net: Consider having from_std
panic on blocking sockets
#7172
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.
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 tofrom_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 thetokio_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.The text was updated successfully, but these errors were encountered: