From 2bde733e093beaeb6e54ebcddfc1e855d92db65b Mon Sep 17 00:00:00 2001 From: "Dave St.Germain" Date: Thu, 14 May 2026 15:17:20 +0000 Subject: [PATCH] fix: enable compilation on OpenBSD by removing keepalive interval (fix #1413) (#1453) This fixes #1413 by conditionally compiling the section that sets a keepalive interval, which isn't supported on OpenBSD. Tested on OpenBSD 7.8 Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/1453 Reviewed-by: Alex --- src/net/netapp.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/net/netapp.rs b/src/net/netapp.rs index 4a53f1d1..518479ff 100644 --- a/src/net/netapp.rs +++ b/src/net/netapp.rs @@ -43,6 +43,7 @@ pub(crate) const NETAPP_VERSION_TAG: u64 = 0x6772676e65740010; // grgnet 0x0010 /// Time a connection must be idle before the first keepalive probe is sent. const TCP_KEEPALIVE_TIME: Duration = Duration::from_secs(30); /// Interval between keepalive probes after the first. +#[cfg(not(target_os = "openbsd"))] const TCP_KEEPALIVE_INTERVAL: Duration = Duration::from_secs(10); /// Timeout for outgoing TCP connection attempts. @@ -52,9 +53,15 @@ const CONNECT_TIMEOUT: Duration = Duration::from_secs(10); fn set_keepalive(stream: &TcpStream) -> Result<(), std::io::Error> { let sock_ref = socket2::SockRef::from(stream); + // OpenBSD does not support with_interval method + #[cfg(not(target_os = "openbsd"))] let keepalive = socket2::TcpKeepalive::new() .with_time(TCP_KEEPALIVE_TIME) .with_interval(TCP_KEEPALIVE_INTERVAL); + + #[cfg(target_os = "openbsd")] + let keepalive = socket2::TcpKeepalive::new().with_time(TCP_KEEPALIVE_TIME); + sock_ref.set_tcp_keepalive(&keepalive) }