-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
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.