Skip to content

Commit d69f613

Browse files
author
B I Mohammed Abbas
committed
Read readiness of socket in connect timeout for VxWorks target
1 parent 66b4f00 commit d69f613

File tree

1 file changed

+19
-10
lines changed
  • library/std/src/sys/pal/unix

1 file changed

+19
-10
lines changed

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

+19-10
Original file line numberDiff line numberDiff line change
@@ -213,16 +213,25 @@ 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-
});
225-
return Err(e);
216+
if cfg!(target_os = "vxworks") {
217+
// Check if the connnection actually succeeded and return ok only when
218+
// the socket is ready and no errors were found
219+
// https://github.com/rust-lang/rust/issues/127018
220+
if let Some(e) = self.take_error()? {
221+
return Err(e);
222+
}
223+
} else {
224+
// linux returns POLLOUT|POLLERR|POLLHUP for refused connections (!), so look
225+
// for POLLHUP rather than read readiness
226+
if pollfd.revents & libc::POLLHUP != 0 {
227+
let e = self.take_error()?.unwrap_or_else(|| {
228+
io::const_io_error!(
229+
io::ErrorKind::Uncategorized,
230+
"no error set after POLLHUP",
231+
)
232+
});
233+
return Err(e);
234+
}
226235
}
227236

228237
return Ok(());

0 commit comments

Comments
 (0)