Skip to content

Commit 08379a8

Browse files
author
B I Mohammed Abbas
committed
Fix connect timeout for non-linux targets, read readiness of socket connection before returning success
1 parent 66b4f00 commit 08379a8

File tree

1 file changed

+3
-9
lines changed
  • library/std/src/sys/pal/unix

1 file changed

+3
-9
lines changed

Diff for: library/std/src/sys/pal/unix/net.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,9 @@ impl Socket {
213213
}
214214
0 => {}
215215
_ => {
216-
// linux returns POLLOUT|POLLERR|POLLHUP for refused connections (!), so look
217-
// for POLLHUP rather than read readiness
218-
if pollfd.revents & libc::POLLHUP != 0 {
219-
let e = self.take_error()?.unwrap_or_else(|| {
220-
io::const_io_error!(
221-
io::ErrorKind::Uncategorized,
222-
"no error set after POLLHUP",
223-
)
224-
});
216+
// Check if the connnection actually succeeded and return ok only when
217+
// the socket is ready and no errors were found
218+
if let Some(e) = self.take_error()? {
225219
return Err(e);
226220
}
227221

0 commit comments

Comments
 (0)