Skip to content

Commit 8998153

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

File tree

1 file changed

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

1 file changed

+20
-10
lines changed

library/std/src/sys/pal/unix/net.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,16 +213,26 @@ 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+
}
224+
else{
225+
// linux returns POLLOUT|POLLERR|POLLHUP for refused connections (!), so look
226+
// for POLLHUP rather than read readiness
227+
if pollfd.revents & libc::POLLHUP != 0 {
228+
let e = self.take_error()?.unwrap_or_else(|| {
229+
io::const_io_error!(
230+
io::ErrorKind::Uncategorized,
231+
"no error set after POLLHUP",
232+
)
233+
});
234+
return Err(e);
235+
}
226236
}
227237

228238
return Ok(());

0 commit comments

Comments
 (0)