-
Notifications
You must be signed in to change notification settings - Fork 9
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 tokio support #2
Conversation
Cargo.toml
Outdated
|
||
[target."cfg(unix)".dev-dependencies] | ||
tempdir = "0.3" | ||
tokio_02 = {package="tokio", version = "0.2", features = ["macros", "rt-core", "test-util"]} |
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.
Ideally this would be optional
as well, but I don't think Cargo allows optional dev-dependencies. Thus, it's either forcing these tokio test-related features for non-test builds, or forcing all test builds to take a tokio dependency.
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 know 😞
This is by the way why the minimal-versions job is failing.
Either try to find the earliest patch version of tokio where cargo check -Z minimal-versions
passes, or if the latest version doesn't pass either then remove the cargo test
part of that job.
What's worse is that those feature flags added under dev-dependencies are also implicitly enabled for regular builds that enable that feature. For that reason i enable test-only mio_07 features through RUSTFLAGS in .cirrus.yml, .travis.yml and tests/test_{locally,target}.sh. While doing this might be pedantic since most final executables are going to want those features anyway, it could make those crates break when/if -Z features=dev_dep (which fixes that bug) becomes the default.
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.
What do you think about moving the dev dependency features to RUSTFLAGS? If it's not pointless I can do that later.
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.
Interesting; I wasn't aware of this issue, or workaround. I tried moving the dev features to RUSTFLAGS
, but had some issues with macros
and tokio's failure to pull in the tokio-macros
sub-crate:
$ RUSTFLAGS='--cfg feature="os-poll" --cfg feature="rt-core" --cfg feature="macros"' cargo test --all-features
...
error[E0432]: unresolved import `tokio_macros`
--> /home/jon/.cargo/registry/src/gh.neting.cc-1ecc6299db9ec823/tokio-0.2.22/src/lib.rs:403:13
|
403 | pub use tokio_macros::select_priv_declare_output_enum;
| ^^^^^^^^^^^^ use of undeclared type or module `tokio_macros`
(note, I realized that test-util
isn't actually used, so that will be dropped regardless of the outcome of this)
One workaround is just importing tokio-macros
itself into dev-dependencies, and then setting up tests such that:
#[tokio_macros::test]
async fn test_listener_accept() {
...
}
which isn't something I've really seen other crates do (especially in documentation, which exclusively uses tokio::main
), but I couldn't come up with a better solution offhand.
Thoughts?
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's also cargo-hack
which looks to address these limitations in cargo. I did a quick trial run and it didn't seem to like running test with --all-features
, but worked as expected when I wrote everything out manually:
$ cargo hack --features="mio_07,tokio,tokio_02/macros,tokio_02/rt-core,mio_07/os-poll" test
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 attempt. We'll just have to accept it being enabled for now.
(by the time I'm releasing v1.0 of this it will probably have been fixed in cargo :)
cargo-hack looks interesting but feels too complex.
I'll add notes to the README and determine what needs to be done to satisfy OSX CI, but any interim reviews would be appreciated. |
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!
You probably also need to update the MSRV to what tokio or futures require.
(The next uds release will be a major version due to other changes anyway).
Do you plan to add more methods? If not I'll add bind_unix_addr()
and the like later.
Cargo.toml
Outdated
|
||
[target."cfg(unix)".dev-dependencies] | ||
tempdir = "0.3" | ||
tokio_02 = {package="tokio", version = "0.2", features = ["macros", "rt-core", "test-util"]} |
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 know 😞
This is by the way why the minimal-versions job is failing.
Either try to find the earliest patch version of tokio where cargo check -Z minimal-versions
passes, or if the latest version doesn't pass either then remove the cargo test
part of that job.
What's worse is that those feature flags added under dev-dependencies are also implicitly enabled for regular builds that enable that feature. For that reason i enable test-only mio_07 features through RUSTFLAGS in .cirrus.yml, .travis.yml and tests/test_{locally,target}.sh. While doing this might be pedantic since most final executables are going to want those features anyway, it could make those crates break when/if -Z features=dev_dep (which fixes that bug) becomes the default.
4f96005
to
7445302
Compare
I went ahead and rebased the
I think it might be best to leave that out for this initial pass. Not trying to push work onto you, but honestly you would probably get the tokio sockets up to parity a lot faster than I could. There's still the larger question of what to do about |
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 rebasing.
After changing the MSRV documentation, you can squash the later commits into one commit adding stream and another adding listener.
Sorry for being slow to respond. I was traveling last weekend and have been working late.
Cargo.toml
Outdated
|
||
[target."cfg(unix)".dev-dependencies] | ||
tempdir = "0.3" | ||
tokio_02 = {package="tokio", version = "0.2", features = ["macros", "rt-core", "test-util"]} |
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.
What do you think about moving the dev dependency features to RUSTFLAGS? If it's not pointless I can do that later.
README.md
Outdated
## Minimum Rust version | ||
|
||
The minimum Rust version is 1.36, because of `std::io::IoSlice`. | ||
If this is a problem I can make the parts that need it opt-out. | ||
The minimum Rust version is 1.39, because of the MSRV of both `tokio` and `futures`. |
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.
Since those dependencies are optional, this makes it unclear what the minimum supported version is when not enabling the tokio feature. Either don't mention the reason or add that the minimum version is 1.36 by default.
@@ -650,6 +662,17 @@ impl NonblockingUnixSeqpacketConn { | |||
// nonblockingness is shared and therefore inherited | |||
Ok(NonblockingUnixSeqpacketConn { fd: cloned.into_raw_fd() }) | |||
} | |||
|
|||
/// Shuts down the read, write, or both halves of this connection. | |||
pub fn shutdown(&self, how: Shutdown) -> 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 for adding shutdown()
!
Maybe add a test? (I can do that later though)
Forgot to say that the failing test is probably flaky or maybe apple changed something. |
Adds a listener accept test that also demonstrates `tokio::UnixSeqpacketConn` usage.
67ccdbe
to
c48d0af
Compare
Went ahead and rebased again to clean things up since there are only one or two remaining items. But the latest changes were:
Let me know your thoughts how what to do about Sidenote: you may be right about CI flakiness. I see the latest commit c48d0af has passed, but I didn't make any explicit changes for that to happen.. |
@tormol any further thoughts? Tokio is also on the verge of releasing 0.3 (which will invariably resemble 1.0 more closely than 0.2) so that is something to consider. |
THANK YOU. Sorry for being so slow to respond again. |
No worries at all-- know that feeling all too well, and I actually just had my first child in September, so my OSS work has been pretty inconsistent as well. Glad to see the PR make it across the finish line though! |
Congratulations!
I'm hoping to test this on NetBSD and IllumOS and release this weekend.
Before doing that I'm going to try to stabilize the macOS CI and commit some features that libc now supports.
Den 16. oktober 2020 00:49:52 CEST, skrev Jon Magnuson <notifications@github.com>:
…No worries at all-- know that feeling all too well, and I actually just
had my first child in September, so my OSS work has been pretty
inconsistent as well. Glad to see the PR make it across the finish line
though!
--
You are receiving this because you modified the open/close state.
Reply to this email directly or view it on GitHub:
#2 (comment)
|
0.2.0 is now released. When I tested on Illumos, the test binaries created by |
Adds dependencies
tokio
+futures
behind 'tokio' feature.Implements
tokio::UnixSeqpacketConn
andtokio::UnixSeqpacketListener
for supportingSEQPACKET
sockets in Tokio.Closes #1.
Much of this roughly follows how tokio
UnixStream
/Listener
s (SOCK_STREAM
) are set up, but attempts to adopt some of the existing API naming used byuds
. However, I'm totally open to other naming conventions, or module organization for that matter.My immediate use-case is for
UnixSeqPacketConn
, but have also introduced (perhaps a bit more roughly) the Listener type for the sake of some sort of completeness.