Skip to content

Commit 9ced5f1

Browse files
committed
fix: Align the cfg compilation with the socket2
1 parent dce81a0 commit 9ced5f1

File tree

1 file changed

+45
-38
lines changed

1 file changed

+45
-38
lines changed

src/client/legacy/connect/http.rs

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -111,48 +111,55 @@ impl TcpKeepaliveConfig {
111111
}
112112
}
113113

114-
#[cfg(not(any(
115-
target_os = "aix",
116-
target_os = "openbsd",
117-
target_os = "redox",
118-
target_os = "solaris"
119-
)))]
120114
fn ka_with_interval(ka: TcpKeepalive, interval: Duration, dirty: &mut bool) -> TcpKeepalive {
121-
*dirty = true;
122-
ka.with_interval(interval)
123-
}
124-
125-
#[cfg(any(
126-
target_os = "aix",
127-
target_os = "openbsd",
128-
target_os = "redox",
129-
target_os = "solaris"
130-
))]
131-
fn ka_with_interval(ka: TcpKeepalive, _: Duration, _: &mut bool) -> TcpKeepalive {
132-
ka // no-op as keepalive interval is not supported on this platform
115+
if cfg!(
116+
// See https://docs.rs/socket2/0.5.8/src/socket2/lib.rs.html#511-525
117+
any(
118+
target_os = "android",
119+
target_os = "dragonfly",
120+
target_os = "freebsd",
121+
target_os = "fuchsia",
122+
target_os = "illumos",
123+
target_os = "ios",
124+
target_os = "visionos",
125+
target_os = "linux",
126+
target_os = "macos",
127+
target_os = "netbsd",
128+
target_os = "tvos",
129+
target_os = "watchos",
130+
target_os = "windows",
131+
)
132+
) {
133+
*dirty = true;
134+
ka.with_interval(interval)
135+
} else {
136+
ka
137+
}
133138
}
134139

135-
#[cfg(not(any(
136-
target_os = "aix",
137-
target_os = "openbsd",
138-
target_os = "redox",
139-
target_os = "solaris",
140-
target_os = "windows"
141-
)))]
142140
fn ka_with_retries(ka: TcpKeepalive, retries: u32, dirty: &mut bool) -> TcpKeepalive {
143-
*dirty = true;
144-
ka.with_retries(retries)
145-
}
146-
147-
#[cfg(any(
148-
target_os = "aix",
149-
target_os = "openbsd",
150-
target_os = "redox",
151-
target_os = "solaris",
152-
target_os = "windows"
153-
))]
154-
fn ka_with_retries(ka: TcpKeepalive, _: u32, _: &mut bool) -> TcpKeepalive {
155-
ka // no-op as keepalive retries is not supported on this platform
141+
if cfg!(
142+
// See https://docs.rs/socket2/0.5.8/src/socket2/lib.rs.html#557-570
143+
any(
144+
target_os = "android",
145+
target_os = "dragonfly",
146+
target_os = "freebsd",
147+
target_os = "fuchsia",
148+
target_os = "illumos",
149+
target_os = "ios",
150+
target_os = "visionos",
151+
target_os = "linux",
152+
target_os = "macos",
153+
target_os = "netbsd",
154+
target_os = "tvos",
155+
target_os = "watchos",
156+
)
157+
) {
158+
*dirty = true;
159+
ka.with_retries(retries)
160+
} else {
161+
ka
162+
}
156163
}
157164
}
158165

0 commit comments

Comments
 (0)