Skip to content

Commit e8765e0

Browse files
authored
fix(server): fix compile-time cfgs for TCP keepalive options (#3039)
Closes #3038
1 parent 9ad4055 commit e8765e0

File tree

1 file changed

+63
-6
lines changed

1 file changed

+63
-6
lines changed

src/server/tcp.rs

Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,24 +43,62 @@ impl TcpKeepaliveConfig {
4343
}
4444
}
4545

46-
#[cfg(not(any(target_os = "openbsd", target_os = "redox", target_os = "solaris")))]
46+
#[cfg(any(
47+
target_os = "android",
48+
target_os = "dragonfly",
49+
target_os = "freebsd",
50+
target_os = "fuchsia",
51+
target_os = "illumos",
52+
target_os = "linux",
53+
target_os = "netbsd",
54+
target_vendor = "apple",
55+
windows,
56+
))]
4757
fn ka_with_interval(ka: TcpKeepalive, interval: Duration, dirty: &mut bool) -> TcpKeepalive {
4858
*dirty = true;
4959
ka.with_interval(interval)
5060
}
5161

52-
#[cfg(any(target_os = "openbsd", target_os = "redox", target_os = "solaris"))]
62+
#[cfg(not(any(
63+
target_os = "android",
64+
target_os = "dragonfly",
65+
target_os = "freebsd",
66+
target_os = "fuchsia",
67+
target_os = "illumos",
68+
target_os = "linux",
69+
target_os = "netbsd",
70+
target_vendor = "apple",
71+
windows,
72+
)))]
5373
fn ka_with_interval(ka: TcpKeepalive, _: Duration, _: &mut bool) -> TcpKeepalive {
5474
ka // no-op as keepalive interval is not supported on this platform
5575
}
5676

57-
#[cfg(not(any(target_os = "openbsd", target_os = "redox", target_os = "solaris", target_os = "windows")))]
77+
#[cfg(any(
78+
target_os = "android",
79+
target_os = "dragonfly",
80+
target_os = "freebsd",
81+
target_os = "fuchsia",
82+
target_os = "illumos",
83+
target_os = "linux",
84+
target_os = "netbsd",
85+
target_vendor = "apple",
86+
))]
5887
fn ka_with_retries(ka: TcpKeepalive, retries: u32, dirty: &mut bool) -> TcpKeepalive {
5988
*dirty = true;
6089
ka.with_retries(retries)
6190
}
6291

63-
#[cfg(any(target_os = "openbsd", target_os = "redox", target_os = "solaris", target_os = "windows"))]
92+
#[cfg(not(any(
93+
target_os = "android",
94+
target_os = "dragonfly",
95+
target_os = "freebsd",
96+
target_os = "fuchsia",
97+
target_os = "illumos",
98+
target_os = "linux",
99+
target_os = "netbsd",
100+
target_vendor = "apple",
101+
)))]
64102
fn ka_with_retries(ka: TcpKeepalive, _: u32, _: &mut bool) -> TcpKeepalive {
65103
ka // no-op as keepalive retries is not supported on this platform
66104
}
@@ -401,7 +439,17 @@ mod tests {
401439
}
402440
}
403441

404-
#[cfg(not(any(target_os = "openbsd", target_os = "redox", target_os = "solaris")))]
442+
#[cfg(any(
443+
target_os = "android",
444+
target_os = "dragonfly",
445+
target_os = "freebsd",
446+
target_os = "fuchsia",
447+
target_os = "illumos",
448+
target_os = "linux",
449+
target_os = "netbsd",
450+
target_vendor = "apple",
451+
windows,
452+
))]
405453
#[test]
406454
fn tcp_keepalive_interval_config() {
407455
let mut kac = TcpKeepaliveConfig::default();
@@ -413,7 +461,16 @@ mod tests {
413461
}
414462
}
415463

416-
#[cfg(not(any(target_os = "openbsd", target_os = "redox", target_os = "solaris", target_os = "windows")))]
464+
#[cfg(any(
465+
target_os = "android",
466+
target_os = "dragonfly",
467+
target_os = "freebsd",
468+
target_os = "fuchsia",
469+
target_os = "illumos",
470+
target_os = "linux",
471+
target_os = "netbsd",
472+
target_vendor = "apple",
473+
))]
417474
#[test]
418475
fn tcp_keepalive_retries_config() {
419476
let mut kac = TcpKeepaliveConfig::default();

0 commit comments

Comments
 (0)