mirror of
https://github.com/tokio-rs/axum.git
synced 2024-11-21 22:56:46 +01:00
Fix blocking-mode tcp listener in auto-reload example (#2558)
This commit is contained in:
parent
530aa5530c
commit
5f7fcc5866
1 changed files with 4 additions and 1 deletions
|
@ -16,7 +16,10 @@ async fn main() {
|
||||||
let mut listenfd = ListenFd::from_env();
|
let mut listenfd = ListenFd::from_env();
|
||||||
let listener = match listenfd.take_tcp_listener(0).unwrap() {
|
let listener = match listenfd.take_tcp_listener(0).unwrap() {
|
||||||
// if we are given a tcp listener on listen fd 0, we use that one
|
// if we are given a tcp listener on listen fd 0, we use that one
|
||||||
Some(listener) => TcpListener::from_std(listener).unwrap(),
|
Some(listener) => {
|
||||||
|
listener.set_nonblocking(true).unwrap();
|
||||||
|
TcpListener::from_std(listener).unwrap()
|
||||||
|
}
|
||||||
// otherwise fall back to local listening
|
// otherwise fall back to local listening
|
||||||
None => TcpListener::bind("127.0.0.1:3000").await.unwrap(),
|
None => TcpListener::bind("127.0.0.1:3000").await.unwrap(),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue