From 5f7fcc5866c1a498923be2a3c67b5bf4279d508f Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Wed, 31 Jan 2024 15:55:42 +0100 Subject: [PATCH] Fix blocking-mode tcp listener in auto-reload example (#2558) --- examples/auto-reload/src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/auto-reload/src/main.rs b/examples/auto-reload/src/main.rs index 5813ec1f..ccbc9a16 100644 --- a/examples/auto-reload/src/main.rs +++ b/examples/auto-reload/src/main.rs @@ -16,7 +16,10 @@ async fn main() { let mut listenfd = ListenFd::from_env(); let listener = match listenfd.take_tcp_listener(0).unwrap() { // 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 None => TcpListener::bind("127.0.0.1:3000").await.unwrap(), };