Improve readability of an error check in set_non_blocking
This commit is contained in:
parent
d0c589d5ce
commit
0fc1a7da93
@ -194,11 +194,11 @@ pub fn wouldblock() -> bool {
|
||||
|
||||
pub fn set_nonblocking(fd: sock_t, nb: bool) {
|
||||
let mut set = nb as libc::c_ulong;
|
||||
(if unsafe { c::ioctlsocket(fd, c::FIONBIO, &mut set) } != 0 {
|
||||
Err(last_error())
|
||||
} else {
|
||||
Ok(())
|
||||
}).unwrap();
|
||||
if unsafe { c::ioctlsocket(fd, c::FIONBIO, &mut set) } != 0 {
|
||||
// The above function should not return an error unless we passed it
|
||||
// invalid parameters. Panic on errors.
|
||||
Err(last_error()).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init_net() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user