tokio/util/
blocking_check.rs1#[cfg(unix)]
2use std::os::fd::AsFd;
3
4#[cfg(unix)]
5#[allow(unused_variables)]
6#[track_caller]
7pub(crate) fn check_socket_for_blocking<S: AsFd>(s: &S) -> crate::io::Result<()> {
8 #[cfg(not(tokio_allow_from_blocking_fd))]
9 {
10 let sock = socket2::SockRef::from(s);
11
12 debug_assert!(
13 sock.nonblocking()?,
14 "Registering a blocking socket with the tokio runtime is unsupported. \
15 If you wish to do anyways, please add `--cfg tokio_allow_from_blocking_fd` to your \
16 RUSTFLAGS. See github.com/tokio-rs/tokio/issues/7172 for details."
17 );
18 }
19
20 Ok(())
21}
22
23#[cfg(not(unix))]
24#[allow(unused_variables)]
25pub(crate) fn check_socket_for_blocking<S>(s: &S) -> crate::io::Result<()> {
26 Ok(())
29}