Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for QNX Neutrino to master branch #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

flba-eb
Copy link
Owner

@flba-eb flba-eb commented Jan 14, 2023

@gh-tr This is your patch plus fixes for compiler warnings.
⚠️ There have been some merge conflicts ⚠️

Copy link
Collaborator

@gh-tr gh-tr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QNX support ipv6. Did we not implement it in std::net?

@flba-eb
Copy link
Owner Author

flba-eb commented Jan 16, 2023

I think libc is missing symbols (multicast?) that I did not find in the c header files

@gh-tr
Copy link
Collaborator

gh-tr commented Jan 16, 2023

Interesting. I'll try building and see what I find.

@gh-tr
Copy link
Collaborator

gh-tr commented Jan 16, 2023

Ah, OK, I thought you had yanked out all ipv6 support but I see now that the v6 mreq was only for membership which isn't supported. Makes sense. QNX does support a TCP_KEEPALIVE, it's just implemented via a timespec. Perhaps something like this:

index 706a463..0b08a0f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -388,7 +388,7 @@ impl<'a> DerefMut for MaybeUninitSlice<'a> {
 /// See [`Socket::set_tcp_keepalive`].
 #[derive(Debug, Clone)]
 pub struct TcpKeepalive {
-    #[cfg_attr(any(target_os = "openbsd", target_os = "nto"), allow(dead_code))]
+    #[cfg_attr(target_os = "openbsd", allow(dead_code))]
     time: Option<Duration>,
     #[cfg(not(any(
         target_os = "openbsd",
diff --git a/src/sys/unix.rs b/src/sys/unix.rs
index bb33ea4..47b3674 100644
--- a/src/sys/unix.rs
+++ b/src/sys/unix.rs
@@ -176,7 +176,7 @@ pub(crate) use libc::{TCP_KEEPCNT, TCP_KEEPINTVL};
 // See this type in the Windows file.
 pub(crate) type Bool = c_int;
 
-#[cfg(target_vendor = "apple")]
+#[cfg(any(target_vendor = "apple", target_os = "nto"))]
 use libc::TCP_KEEPALIVE as KEEPALIVE_TIME;
 #[cfg(not(any(
     target_vendor = "apple",
@@ -919,6 +919,12 @@ pub(crate) fn set_tcp_keepalive(fd: Socket, keepalive: &TcpKeepalive) -> io::Res
         unsafe { setsockopt(fd, libc::IPPROTO_TCP, KEEPALIVE_TIME, secs)? }
     }
 
+    #[cfg(target_os = "nto")]
+    if let Some(time) = keepalive.time {
+        let secs = into_timeval(Some(time));
+        unsafe { setsockopt(fd, libc::IPPROTO_TCP, KEEPALIVE_TIME, secs)? }
+    }
+
     #[cfg(any(
         target_os = "android",
         target_os = "dragonfly",

@flba-eb
Copy link
Owner Author

flba-eb commented Jan 16, 2023

Great, thank you so much! Your proposal is now included and I will check for the same change in the 0.4 branch

@flba-eb
Copy link
Owner Author

flba-eb commented Jan 16, 2023

0.4 should be fine now, but master (this PR) needed another fix to compile with --all-features.

@gh-tr
Copy link
Collaborator

gh-tr commented Jan 16, 2023

0.4 should be fine now, but master (this PR) needed another fix to compile with --all-features.

I can't seem to create a review for this one. Yep, there is no accept4 on QNX. Change accepted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants