From 224c03daf1d040da83084928e9a1fe978a5a06ae Mon Sep 17 00:00:00 2001 From: Lorenz Leutgeb Date: Tue, 21 Apr 2026 20:10:19 +0200 Subject: [PATCH] node: Expand `target_os` condition for keep-alive `KeepAlive::with_retries` is not just unavailable on Windows, but on a bunch of other operating systems. Copy the condition over from `socket2`. --- crates/radicle-node/src/wire.rs | 38 +++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/crates/radicle-node/src/wire.rs b/crates/radicle-node/src/wire.rs index b1eb3de6..907d1f4c 100644 --- a/crates/radicle-node/src/wire.rs +++ b/crates/radicle-node/src/wire.rs @@ -1193,11 +1193,41 @@ fn session>( { let connection = socket2::SockRef::from(&connection); - let ka = socket2::TcpKeepalive::new() - .with_time(time::Duration::from_secs(30)) - .with_interval(time::Duration::from_secs(10)); + let ka = socket2::TcpKeepalive::new().with_time(time::Duration::from_secs(30)); - #[cfg(not(windows))] + #[cfg(any( + target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "fuchsia", + target_os = "illumos", + target_os = "ios", + target_os = "visionos", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "tvos", + target_os = "watchos", + target_os = "windows", + target_os = "cygwin", + ))] + let ka = ka.with_interval(time::Duration::from_secs(10)); + + #[cfg(any( + target_os = "android", + target_os = "dragonfly", + target_os = "freebsd", + target_os = "fuchsia", + target_os = "illumos", + target_os = "ios", + target_os = "visionos", + target_os = "linux", + target_os = "macos", + target_os = "netbsd", + target_os = "tvos", + target_os = "watchos", + target_os = "cygwin", + ))] let ka = ka.with_retries(3); if let Err(e) = connection.set_tcp_keepalive(&ka) {