Skip to content

Commit 25711d4

Browse files
author
B I Mohammed Abbas
committed
Fix connect_timeout, check for connection readiness
1 parent 2db4ff4 commit 25711d4

File tree

1 file changed

+5
-12
lines changed
  • library/std/src/sys/pal/unix

1 file changed

+5
-12
lines changed

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

+5-12
Original file line numberDiff line numberDiff line change
@@ -213,18 +213,11 @@ 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);
226-
}
227-
216+
//Check if the socket connection is actually valid and did not raise any errors.
217+
match self.take_error()?{
218+
None => return Ok(()),
219+
Some(e) => return Err(e)
220+
};
228221
return Ok(());
229222
}
230223
}

0 commit comments

Comments
 (0)