about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorB I Mohammed Abbas <bimohammdabbas@gmail.com>2024-07-25 15:11:26 +0530
committerB I Mohammed Abbas <bimohammdabbas@gmail.com>2024-07-25 15:11:26 +0530
commit17b4fbc388ec11a3c1cdf7e33ff00a0322edaf98 (patch)
tree4ee19a871bc277c1e36d937293a455f23e612859 /library/std/src
parent66b4f0021bfb11a8c20d084c99a40f4a78ce1d38 (diff)
downloadrust-17b4fbc388ec11a3c1cdf7e33ff00a0322edaf98.tar.gz
rust-17b4fbc388ec11a3c1cdf7e33ff00a0322edaf98.zip
In connect timeout, read readiness of socket for vxworks. Check pollhup or pollerr for refused connections in linux
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/sys/pal/unix/net.rs29
1 files changed, 19 insertions, 10 deletions
diff --git a/library/std/src/sys/pal/unix/net.rs b/library/std/src/sys/pal/unix/net.rs
index b8dc1538a63..092c3ee594d 100644
--- a/library/std/src/sys/pal/unix/net.rs
+++ b/library/std/src/sys/pal/unix/net.rs
@@ -213,16 +213,25 @@ 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);
+                    if cfg!(target_os = "vxworks") {
+                        // VxWorks poll does not return  POLLHUP or POLLERR in revents. Check if the
+                        // connnection actually succeeded and return ok only when the socket is
+                        // ready and no errors were found.
+                        if let Some(e) = self.take_error()? {
+                            return Err(e);
+                        }
+                    } else {
+                        // linux returns POLLOUT|POLLERR|POLLHUP for refused connections (!), so look
+                        // for POLLHUP or POLLERR rather than read readiness
+                        if pollfd.revents & (libc::POLLHUP | libc::POLLERR) != 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(());