Skip to content

Commit

Permalink
Fix connect timeout for non linux targets, check for readiness
Browse files Browse the repository at this point in the history
  • Loading branch information
B I Mohammed Abbas committed Jul 3, 2024
1 parent 2db4ff4 commit 8842a10
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions library/std/src/sys/pal/unix/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,19 +213,11 @@ impl Socket {
}
0 => {}
_ => {
// linux returns POLLOUT|POLLERR|POLLHUP for refused connections (!), so look
// for POLLHUP rather than read readiness
if pollfd.revents & libc::POLLHUP != 0 {
let e = self.take_error()?.unwrap_or_else(|| {
io::const_io_error!(
io::ErrorKind::Uncategorized,
"no error set after POLLHUP",
)
});
return Err(e);
}

return Ok(());
//Check if the socket connection is actually valid and did not raise any errors.
match self.take_error()?{
None => return Ok(()),
Some(e) => return Err(e)
};
}
}
}
Expand Down

0 comments on commit 8842a10

Please sign in to comment.