-
Notifications
You must be signed in to change notification settings - Fork 711
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 UDS support for Unix systems #1098
Conversation
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
How does this PR compare to alexchrichton/mio-uds ? |
@asomers this is updating the UDS implementation to the latest mio. It also moves it in tree because |
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
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.
Overall this looks good, I've add a couple of comments but there are mostly small nits.
I haven't had time to look at the tests yet.
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
This introduced problems cross-platform Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
@Thomasdezeeuw I'm not sure I follow all the parts of this comment in I can rename the I'm not sure I follow |
This commit introduces a significant restructure from the original UDS support proposal. Originally, the UDS types dispatched the the `std` UDS types from the `net` module. This was different from other `net` module types because it did not use the `sys` modules types for that OS. This was okay because currently UDS is only supported by Unix, but when windows support is added this would have been a problem. The new structure sets up most of the work for Windows UDS support as the `net` module UDS types now all dispatch to their inner `sys` module types. Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
@Thomasdezeeuw I think most of your comments should be addressed from the last commit. Below is my commit message:
I have left all your comments from your last review that had to do with this unresolved, but I think they should all be addressed at this point. |
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 to me, thanks @kleimkuhler.
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
This did not work across all plaforms :( This reverts commit 9d9cbc6.
Since this change is so large, can some double check this and merge if acceptable? |
/// | ||
/// [`net::SocketAddr`]: std::os::unix::net::SocketAddr | ||
/// [`accept`]: #method.accept | ||
pub struct SocketAddr { |
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.
Let's not do it in this PR, but as a follow up it would be nice to move this type to a separate file.
src/net/uds/datagram.rs
Outdated
use std::io; | ||
use std::net::Shutdown; | ||
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; | ||
use std::os::unix::net::SocketAddr; |
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.
It looks like we are using the std
version of SocketAddr
here. Should we focus on only using mio
s version?
src/net/uds/listener.rs
Outdated
} | ||
|
||
/// Returns the local socket address of this listener. | ||
pub fn local_addr(&self) -> io::Result<net::SocketAddr> { |
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.
Same: should we focus on only using mio's version of SocketAddr
?
src/net/uds/stream.rs
Outdated
use std::io::{self, IoSlice, IoSliceMut}; | ||
use std::net::Shutdown; | ||
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; | ||
use std::os::unix::net::SocketAddr; |
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.
Same: should we focus on only using mio's version of SocketAddr
?
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.
Looks great to me. One thought, which I added inline, should we only use mio's definition of SocketAddr
(for consistency)? Again, if/when std
allows external construction of SocketAddr
, we can switch all at once.
@carllerche I had limited the use of mio's That's a good point though about using it everywhere for now and changing over all at once when we can. I'll make that change! |
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
Signed-off-by: Kevin Leimkuhler <kleimkuhler@icloud.com>
@carllerche Had to introduce some further Also fixed a |
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 for the work and taking this to completion 👍
Summary
This change adds UDS support for Unix systems. The networking primitives
src/net/uds
. These modules provide the structs forUnixDatagram
s,UnixListener
s, andUnixStream
s. Each of the methods on these structsdispatch to the Unix system structs in
src/sys/unix/uds.rs
.Use of these new structs should feel fairly similar to the
Tcp[...]
equivalents. The tests added also reflect the similar behavior that would be
expected.
Details
Since this change only adds UDS support, there should be no behavior changes
anywhere else. For reviewing, I recommend starting from the networking
primitives and seeing what methods they dispatch to.
The tests added in
tests/uds.rs
should feel fairly similar totcp_stream.rs
--the main difference coming from supportingPathBuf
s as thesocket address to connect to.
I originally pulled in some testing infrastructure added to
v0.6.x
in #944,but ultimately found the functionality to not be as helpful due to a lot of
changes that have since taken place in
master
. I think #944 could still behelpful, but as a separate change that is more about improving testing
functionality and not included in a change that introduces additional
functionality.
Signed-off-by: Kevin Leimkuhler kleimkuhler@icloud.com