Skip to content

Commit 6a054c2

Browse files
committed
fix: wrap libc::setsockopt in unsafe block
1 parent cee1087 commit 6a054c2

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

crates/rproxy/src/server/proxy/connection_guard.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl ConnectionGuard {
111111

112112
if let Some(stream) = stream {
113113
#[cfg(target_os = "linux")]
114-
{
114+
unsafe {
115115
libc::setsockopt(
116116
stream.as_fd().as_raw_fd(),
117117
libc::IPPROTO_TCP,
@@ -136,16 +136,14 @@ impl ConnectionGuard {
136136
}
137137

138138
#[cfg(target_os = "macos")]
139-
{
140-
unsafe {
141-
libc::setsockopt(
142-
stream.as_fd().as_raw_fd(),
143-
libc::IPPROTO_TCP,
144-
libc::TCP_KEEPALIVE,
145-
&keep_alive_interval as *const _ as *const _,
146-
std::mem::size_of_val(&keep_alive_interval) as libc::socklen_t,
147-
);
148-
}
139+
unsafe {
140+
libc::setsockopt(
141+
stream.as_fd().as_raw_fd(),
142+
libc::IPPROTO_TCP,
143+
libc::TCP_KEEPALIVE,
144+
&keep_alive_interval as *const _ as *const _,
145+
std::mem::size_of_val(&keep_alive_interval) as libc::socklen_t,
146+
);
149147
}
150148
}
151149

0 commit comments

Comments
 (0)