Skip to content

Commit

Permalink
Fix connect timeout for non-linux targets, read readiness of socket c…
Browse files Browse the repository at this point in the history
…onnection before returning success
  • Loading branch information
B I Mohammed Abbas committed Jul 4, 2024
1 parent 66b4f00 commit 08379a8
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions library/std/src/sys/pal/unix/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,9 @@ 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",
)
});
// Check if the connnection actually succeeded and return ok only when
// the socket is ready and no errors were found
if let Some(e) = self.take_error()? {
return Err(e);
}

Expand Down

0 comments on commit 08379a8

Please sign in to comment.