1 | #[cfg (unix)] |
2 | use std::os::fd::AsFd; |
3 | |
4 | #[cfg (unix)] |
5 | #[allow (unused_variables)] |
6 | #[track_caller ] |
7 | pub(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: SockRef<'_> = 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)] |
25 | pub(crate) fn check_socket_for_blocking<S>(s: &S) -> crate::io::Result<()> { |
26 | // we cannot retrieve the nonblocking status on windows |
27 | // and i dont know how to support wasi yet |
28 | Ok(()) |
29 | } |
30 | |