-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Update mio to 0.8 #4270
Update mio to 0.8 #4270
Conversation
As for the socket2 issue, I don't think it should be considered a blocker, but if one of the reviewers wants to make it a blocker, I'm fine with that. |
self.inner.get_send_buffer_size() | ||
self.inner.send_buffer_size().map(|n| n as u32) |
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.
There are several casts in this PR. Do we risk them truncating any data here?
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.
There are 5 casts:
- set_send_buffer_size,set_recv_buffer_size (cast u32 as usize): on tokio, usize is always at least 32 bits.
- send_buffer_size,recv_buffer_size (cast usize as u32): socket2 gets these values as c_int (always i32) and then cast them to usize (1, 2).
- listen (cast u32 as i32): It seems using cast is wrong, I'll fix this.
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.
fixed in 5326df1
"mio/tcp", | ||
"mio/udp", | ||
"mio/uds", | ||
"socket2/all", |
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.
I'm not too familiar with the features of socket2, but can we be more precise here?
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.
socket2's all
feature means enabling APIs that are not available in some OSes, not means enabling all feature flags.
# Enable all API, even ones not available on all OSs. all = []
In our case, this feature is needed to use reuse_port/set_reuse_port, which is not available in Solaris & Illumos.
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.
The change itself seems good, though I'd like to discuss it this evening when the americans come online.
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.
This looks good.
@@ -500,7 +524,7 @@ impl TcpSocket { | |||
/// | |||
/// #[tokio::main] | |||
/// async fn main() -> std::io::Result<()> { | |||
/// | |||
/// | |||
/// let socket2_socket = Socket::new(Domain::IPV4, Type::STREAM, None)?; | |||
/// | |||
/// let socket = TcpSocket::from_std_stream(socket2_socket.into()); |
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.
How about impl From<socket2::Socket> for TcpSocket
?
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.
We don't want to make a crate with version 0.x a public dependency of a crate with version 1.x.
See also api-guidelines: https://rust-lang.github.io/api-guidelines/necessities.html#public-dependencies-of-a-stable-crate-are-stable-c-stable
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.
Also, once this PR is merged, adding the options that socket2 has to the TcpSocket will be easy. So the cases where code like this example is needed should be greatly reduced in the near future.
I got two approvals and no one had raised any objections for over a month, so I'll merge this. |
Closes #4135
Unblocks #3082, #3312, #3542, #3545, #3170, #3309