diff options
author | Neal H. Walfield <neal@sequoia-pgp.org> | 2024-02-20 10:38:20 +0100 |
---|---|---|
committer | Neal H. Walfield <neal@sequoia-pgp.org> | 2024-02-20 11:09:06 +0100 |
commit | 44b349e32da727f9dcda6aface1f7875a20972a4 (patch) | |
tree | 31920a0092bcb8d9e97beae304dbf21fba394d00 | |
parent | 963ca044a05d64fa2b8f6d972ff46d8b7143db6e (diff) |
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`.
-rw-r--r-- | ipc/src/lib.rs | 1 |
1 files changed, 1 insertions, 0 deletions
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 { |