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

implement set_tcp_keepalive for linux #24594

Merged
merged 1 commit into from
Apr 24, 2015
Merged

Conversation

dovahcrow
Copy link
Contributor

why use dummy implementation on linux?

@dovahcrow
Copy link
Contributor Author

r? @alexcrichton

@rust-highfive rust-highfive assigned alexcrichton and unassigned brson Apr 19, 2015
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see CONTRIBUTING.md for more information.

@alexcrichton
Copy link
Member

Huh, weird! Not sure why this was a noop... Regardless, thanks!

@bors: r+ ea58799

@dovahcrow
Copy link
Contributor Author

@alexchrichton when will SO_SNDTIMEOand SO_RCVTIMEO be implemented?

@bors
Copy link
Contributor

bors commented Apr 19, 2015

⌛ Testing commit ea58799 with merge e930cb7...

@bors
Copy link
Contributor

bors commented Apr 19, 2015

💔 Test failed - auto-linux-64-nopt-t

@alexcrichton
Copy link
Member

Socket timeouts will land once the associated RFC lands.

@alexcrichton
Copy link
Member

Would you be interested in adding the necessary constants here?

@@ -207,10 +207,16 @@ impl TcpStream {
setsockopt(&self.inner, libc::IPPROTO_TCP, libc::TCP_KEEPIDLE,
seconds as c_int)
}
#[cfg(target_os = "linux")]
fn set_tcp_keepalive(&self, seconds: u32) -> io::Result<()> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this just add a target_os to the definition right above, on L205?

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

diff --git a/src/libstd/sys/common/net2.rs b/src/libstd/sys/common/net2.rs
index 7d42d65..c6cb673 100644
--- a/src/libstd/sys/common/net2.rs
+++ b/src/libstd/sys/common/net2.rs
@@ -197,18 +197,22 @@ impl TcpStream {
         }
     }

-    #[cfg(any(target_os = "macos", target_os = "ios"))]
+    #[cfg(any(target_os = "macos",
+              target_os = "ios"))]
     fn set_tcp_keepalive(&self, seconds: u32) -> io::Result<()> {
         setsockopt(&self.inner, libc::IPPROTO_TCP, libc::TCP_KEEPALIVE,
                    seconds as c_int)
     }
-    #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
+    #[cfg(any(target_os = "linux",
+              target_os = "freebsd",
+              target_os = "dragonfly"))]
     fn set_tcp_keepalive(&self, seconds: u32) -> io::Result<()> {
         setsockopt(&self.inner, libc::IPPROTO_TCP, libc::TCP_KEEPIDLE,
                    seconds as c_int)
     }
     #[cfg(not(any(target_os = "macos",
                   target_os = "ios",
+                  target_os = "linux",
                   target_os = "freebsd",
                   target_os = "dragonfly")))]
     fn set_tcp_keepalive(&self, _seconds: u32) -> io::Result<()> {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks Duberstein. I'm too busy these days, and even haven't got time
turning on my computer. I'll merge this patch tomorrow.

On 2015年4月22日周三 下午10:13 Tamir Duberstein [email protected] wrote:

In src/libstd/sys/common/net2.rs
#24594 (comment):

@@ -207,10 +207,16 @@ impl TcpStream {
setsockopt(&self.inner, libc::IPPROTO_TCP, libc::TCP_KEEPIDLE,
seconds as c_int)
}

  • #[cfg(target_os = "linux")]
  • fn set_tcp_keepalive(&self, seconds: u32) -> io::Result<()> {

[image: 👍]

diff --git a/src/libstd/sys/common/net2.rs b/src/libstd/sys/common/net2.rs
index 7d42d65..c6cb673 100644--- a/src/libstd/sys/common/net2.rs+++ b/src/libstd/sys/common/net2.rs@@ -197,18 +197,22 @@ impl TcpStream {
}
}

  • #[cfg(any(target_os = "macos", target_os = "ios"))]+ #[cfg(any(target_os = "macos",+ target_os = "ios"))]
    fn set_tcp_keepalive(&self, seconds: u32) -> io::Result<()> {
    setsockopt(&self.inner, libc::IPPROTO_TCP, libc::TCP_KEEPALIVE,
    seconds as c_int)
    }- #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]+ #[cfg(any(target_os = "linux",+ target_os = "freebsd",+ target_os = "dragonfly"))]
    fn set_tcp_keepalive(&self, seconds: u32) -> io::Result<()> {
    setsockopt(&self.inner, libc::IPPROTO_TCP, libc::TCP_KEEPIDLE,
    seconds as c_int)
    }
    #[cfg(not(any(target_os = "macos",
    target_os = "ios",+ target_os = "linux",
    target_os = "freebsd",
    target_os = "dragonfly")))]
    fn set_tcp_keepalive(&self, _seconds: u32) -> io::Result<()> {


Reply to this email directly or view it on GitHub
https://github.com/rust-lang/rust/pull/24594/files#r28875540.

@dovahcrow
Copy link
Contributor Author

what about merging all the three into one definition on L200?

@seanmonstar
Copy link
Contributor

@doomsplayer Because it seems the constant for macos/ios is TCP_KEEPALIVE, where for freebsd/dragonfly/linux, it's TCP_KEEPIDLE.

@dovahcrow
Copy link
Contributor Author

Oops. These two words are too similar. I made a mistake

On Tue, Apr 21, 2015 at 11:18 AM Sean McArthur [email protected]
wrote:

@doomsplayer https://github.com/doomsplayer Because it seems the
constant for macos/ios is TCP_KEEPALIVE, where for
freebsd/dragonfly/linux, it's TCP_KEEPIDLE.


Reply to this email directly or view it on GitHub
#24594 (comment).

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Apr 21, 2015
@dovahcrow
Copy link
Contributor Author

ready to merge @alexcrichton

@alexcrichton
Copy link
Member

@bors: r+ 4d6e2f5

Thanks!

@bors
Copy link
Contributor

bors commented Apr 24, 2015

⌛ Testing commit 4d6e2f5 with merge 2214860...

bors added a commit that referenced this pull request Apr 24, 2015
why use dummy implementation on linux?
@bors bors merged commit 4d6e2f5 into rust-lang:master Apr 24, 2015
@dovahcrow dovahcrow deleted the patch-2 branch April 25, 2015 16:54
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.

7 participants