From 8842a10885799048f7814ed524aedee85264635b Mon Sep 17 00:00:00 2001 From: B I Mohammed Abbas Date: Wed, 3 Jul 2024 17:50:43 +0530 Subject: [PATCH] Fix connect timeout for non linux targets, check for readiness --- library/std/src/sys/pal/unix/net.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/library/std/src/sys/pal/unix/net.rs b/library/std/src/sys/pal/unix/net.rs index b8dc1538a6378..d9d161622aa30 100644 --- a/library/std/src/sys/pal/unix/net.rs +++ b/library/std/src/sys/pal/unix/net.rs @@ -213,19 +213,11 @@ 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", - ) - }); - return Err(e); - } - - return Ok(()); + //Check if the socket connection is actually valid and did not raise any errors. + match self.take_error()?{ + None => return Ok(()), + Some(e) => return Err(e) + }; } } }