Skip to content

Commit

Permalink
clean up c::linger conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
ibraheemdev committed Aug 30, 2021
1 parent 3b6777f commit dafc147
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion library/std/src/sys/unix/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ impl Socket {
pub fn set_linger(&self, linger: Option<Duration>) -> io::Result<()> {
let linger = libc::linger {
l_onoff: linger.is_some() as libc::c_int,
l_linger: linger.map(|dur| dur.as_secs() as libc::c_int).unwrap_or_default(),
l_linger: linger.unwrap_or_default().as_secs() as libc::c_int,
};

setsockopt(self, libc::SOL_SOCKET, SO_LINGER, linger)
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/windows/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ impl Socket {
pub fn set_linger(&self, linger: Option<Duration>) -> io::Result<()> {
let linger = c::linger {
l_onoff: linger.is_some() as c_ushort,
l_linger: linger.map(|dur| dur.as_secs() as c_ushort).unwrap_or_default(),
l_linger: linger.unwrap_or_default().as_secs() as c_ushort,
};

net::setsockopt(self, c::SOL_SOCKET, c::SO_LINGER, linger)
Expand Down

0 comments on commit dafc147

Please sign in to comment.