Skip to content

Commit

Permalink
Fix race condition on connection check
Browse files Browse the repository at this point in the history
  • Loading branch information
schaefi committed Apr 10, 2024
1 parent ebb7294 commit 6b279f7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions firecracker-pilot/src/firecracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())?;
Expand Down

0 comments on commit 6b279f7

Please sign in to comment.