Skip to content

Commit 7d772b0

Browse files
committed
Use SO_LINGER_SEC on macOS for TcpSocket::set/get_linger
1 parent b51af46 commit 7d772b0

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ os-util = ["os-ext"]# Replaced with "os-ext" feature.
5353
log = "0.4.8"
5454

5555
[target.'cfg(unix)'.dependencies]
56-
libc = "0.2.82"
56+
libc = "0.2.86"
5757

5858
[target.'cfg(windows)'.dependencies]
5959
miow = "0.3.6"

src/sys/unix/tcp.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ pub(crate) fn set_linger(socket: TcpSocket, dur: Option<Duration>) -> io::Result
140140
syscall!(setsockopt(
141141
socket,
142142
libc::SOL_SOCKET,
143+
#[cfg(target_vendor = "apple")]
144+
libc::SO_LINGER_SEC,
145+
#[cfg(not(target_vendor = "apple"))]
143146
libc::SO_LINGER,
144147
&val as *const libc::linger as *const libc::c_void,
145148
size_of::<libc::linger>() as libc::socklen_t,
@@ -154,6 +157,9 @@ pub(crate) fn get_linger(socket: TcpSocket) -> io::Result<Option<Duration>> {
154157
syscall!(getsockopt(
155158
socket,
156159
libc::SOL_SOCKET,
160+
#[cfg(target_vendor = "apple")]
161+
libc::SO_LINGER_SEC,
162+
#[cfg(not(target_vendor = "apple"))]
157163
libc::SO_LINGER,
158164
&mut val as *mut _ as *mut _,
159165
&mut len,

0 commit comments

Comments
 (0)