fix compilation for openbsd

This commit is contained in:
Σrebe - Romain GERARD 2024-05-09 11:31:39 +02:00
parent 88e42d3b9f
commit d3476ce716
No known key found for this signature in database
GPG key ID: 7A42B4B97E0332F4
2 changed files with 159 additions and 1 deletions

View file

@ -22,7 +22,7 @@ pub fn configure_socket(socket: SockRef, so_mark: &Option<u32>) -> Result<(), an
.set_nodelay(true)
.with_context(|| format!("cannot set no_delay on socket: {:?}", io::Error::last_os_error()))?;
#[cfg(not(target_os = "windows"))]
#[cfg(not(any(target_os = "windows", target_os = "openbsd")))]
let tcp_keepalive = TcpKeepalive::new()
.with_time(Duration::from_secs(60))
.with_interval(Duration::from_secs(10))
@ -33,6 +33,9 @@ pub fn configure_socket(socket: SockRef, so_mark: &Option<u32>) -> Result<(), an
.with_time(Duration::from_secs(60))
.with_interval(Duration::from_secs(10));
#[cfg(target_os = "openbsd")]
let tcp_keepalive = TcpKeepalive::new().with_time(Duration::from_secs(60));
socket
.set_tcp_keepalive(&tcp_keepalive)
.with_context(|| format!("cannot set tcp_keepalive on socket: {:?}", io::Error::last_os_error()))?;