From 6b279f78e0cacd015de3e28ee0d2c63f2935aad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Sch=C3=A4fer?= Date: Tue, 9 Apr 2024 18:43:42 +0200 Subject: [PATCH] Fix race condition on connection check --- firecracker-pilot/src/firecracker.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/firecracker-pilot/src/firecracker.rs b/firecracker-pilot/src/firecracker.rs index b37362d..b168405 100644 --- a/firecracker-pilot/src/firecracker.rs +++ b/firecracker-pilot/src/firecracker.rs @@ -433,6 +433,12 @@ pub fn check_connected(program_name: &String) -> Result<(), FlakeError> { } let mut buffer = [0; 14]; if let Ok(mut stream) = UnixStream::connect(&vsock_uds_path) { + let _ = stream.set_write_timeout( + Some(time::Duration::from_millis(200)) + ); + let _ = stream.set_read_timeout( + Some(time::Duration::from_millis(200)) + ); stream.write_all( format!("CONNECT {}\n", defaults::VM_PORT ).as_bytes())?;