clean up c::linger
conversion
This commit is contained in:
parent
3b6777f1ab
commit
dafc14794f
@ -387,7 +387,7 @@ pub fn shutdown(&self, how: Shutdown) -> io::Result<()> {
|
||||
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)
|
||||
|
@ -449,7 +449,7 @@ pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user