Skip to content

Commit

Permalink
add compile conditions for tcp_keepalive
Browse files Browse the repository at this point in the history
  • Loading branch information
zephyrchien committed Dec 10, 2023
1 parent 14137a6 commit 4fd5016
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions realm_core/src/tcp/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,18 @@ pub(super) mod keepalive {
if *tcp_keepalive == 0 {
return None;
};
let sec = Duration::from_secs(*tcp_keepalive as u64);
let probe = *tcp_keepalive_probe as u32;
let kpa = TcpKeepalive::new()
.with_time(sec)
.with_interval(sec)
.with_retries(probe);
let secs = Duration::from_secs(*tcp_keepalive as u64);
let mut kpa = TcpKeepalive::new().with_time(secs);
#[cfg(not(target_os = "openbsd"))]
{
kpa = TcpKeepalive::with_interval(kpa, secs);
}
#[cfg(not(any(target_os = "openbsd", target_os = "windows")))]
{
let probe = *tcp_keepalive_probe as u32;
kpa = TcpKeepalive::with_retries(kpa, probe);
}

Some(kpa)
}
}

0 comments on commit 4fd5016

Please sign in to comment.