-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Conversation
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. |
@alexchrichton when will |
⌛ Testing commit ea58799 with merge e930cb7... |
💔 Test failed - auto-linux-64-nopt-t |
Socket timeouts will land once the associated RFC lands. |
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<()> { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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<()> {
There was a problem hiding this comment.
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.
what about merging all the three into one definition on L200? |
@doomsplayer Because it seems the constant for macos/ios is |
Oops. These two words are too similar. I made a mistake On Tue, Apr 21, 2015 at 11:18 AM Sean McArthur [email protected]
|
ready to merge @alexcrichton |
why use dummy implementation on linux?
why use dummy implementation on linux?