From 44b349e32da727f9dcda6aface1f7875a20972a4 Mon Sep 17 00:00:00 2001 From: "Neal H. Walfield" Date: Tue, 20 Feb 2024 10:38:20 +0100 Subject: ipc: Ensure server's socket is in non-blocking mode. - According to the documentation for [`TcpListener::from_std`] the passed socket must be in non-blocking mode: > The caller is responsible for ensuring that the listener is in > non-blocking mode. Otherwise all I/O operations on the listener > will block the thread, which will cause unexpected > behavior. Non-blocking mode can be set using set_nonblocking. [`TcpListener::from_std`]: https://docs.rs/tokio/1.36.0/tokio/net/struct.TcpListener.html - Make sure that is the case for any socket we pass to `TcpListener::from_std`. --- ipc/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/ipc/src/lib.rs b/ipc/src/lib.rs index 89b9a7ca..3f91e211 100644 --- a/ipc/src/lib.rs +++ b/ipc/src/lib.rs @@ -356,6 +356,7 @@ impl Server { let handler = (self.descriptor.factory)(self.descriptor.clone(), &local)?; let server = async move { + l.set_nonblocking(true)?; let socket = tokio::net::TcpListener::from_std(l).unwrap(); loop { -- cgit v1.2.3