Skip to content

Commit

Permalink
Fix accidental blocking socket in crashtracking
Browse files Browse the repository at this point in the history
Rust stdlib UnixListener is not async by default unlike the tokio one. It did apparently not fail during manual testing, but CI showed it sometimes failing.

Explicitly making it set_nonblocking(true).

Signed-off-by: Bob Weinand <bob.weinand@datadoghq.com>
  • Loading branch information
bwoebi committed Aug 27, 2024
1 parent f55df58 commit e966b19
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crashtracker/src/receiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ pub fn get_unix_socket(socket_path: impl AsRef<str>) -> anyhow::Result<UnixListe
use std::os::linux::net::SocketAddrExt;
std::os::unix::net::SocketAddr::from_abstract_name(socket_path.as_ref())
.and_then(|addr| {
std::os::unix::net::UnixListener::bind_addr(&addr).and_then(UnixListener::from_std)
std::os::unix::net::UnixListener::bind_addr(&addr)
.and_then(|listener| {
listener.set_nonblocking(true)?;
Ok(listener)
})
.and_then(UnixListener::from_std)
})
.map_err(anyhow::Error::msg)
};
Expand Down

0 comments on commit e966b19

Please sign in to comment.