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

refactor(s2n-quic-platform): use socket ring for tokio #1792

Merged
merged 3 commits into from
Jun 15, 2023

Conversation

camshaft
Copy link
Contributor

@camshaft camshaft commented Jun 5, 2023

Description of changes:

This change finally wires up the new "socket v2" async ring buffers to the tokio IO provider. It also deletes all of the "socket v1" code.

Testing:

Since this is just a refactor, all of the existing tests should pass, including the QNS tests.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@camshaft camshaft force-pushed the camshaft/io-tokio-upgrade branch 3 times, most recently from 2e06837 to cffd965 Compare June 14, 2023 03:23
@camshaft camshaft force-pushed the camshaft/io-tokio-upgrade branch from cffd965 to 5fd3f24 Compare June 15, 2023 03:54
@camshaft camshaft force-pushed the camshaft/io-tokio-upgrade branch 2 times, most recently from 7f1a3cd to 3b2e56b Compare June 15, 2023 04:13
@camshaft camshaft marked this pull request as ready for review June 15, 2023 04:13
@camshaft camshaft requested a review from WesleyRosenblum June 15, 2023 04:13
@camshaft camshaft force-pushed the camshaft/io-tokio-upgrade branch from 9f7241d to cd946a7 Compare June 15, 2023 16:33
}

#[inline]
unsafe fn set_payload_len(&mut self, len: usize) {
debug_assert!(len <= core::u32::MAX as usize);
debug_assert!(len <= core::u16::MAX as usize);
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we going from u32 to u16. was the previous check not correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the msg_len is a u32. but in general we don't allow payloads to be bigger that u16

@@ -17,25 +17,25 @@ testing = ["std", "generator", "futures/std", "io-testing"] # Testing allows to
io-testing = ["bach"]
generator = ["bolero-generator", "s2n-quic-core/generator"]
tokio-runtime = ["futures", "tokio"]
xdp = ["s2n-quic-xdp"]
xdp = ["dep:s2n-quic-xdp"]
Copy link
Contributor

Choose a reason for hiding this comment

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

what does dep: do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://doc.rust-lang.org/cargo/reference/features.html#optional-dependencies - basically makes it explicit that it's enabling a dependency, not a feature. but i'm going to remove this for now and do a separate PR to fix the --all-feature stuff in CI

@@ -90,6 +73,7 @@ impl Io {
},
});

// try to use the tokio runtime handle if provided
Copy link
Contributor

Choose a reason for hiding this comment

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

can you also add a comment on the else case. is that case used when s2n-quic runs inside another program which already started the tokio runtime.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep

@@ -8,13 +8,25 @@ use core::ops::ControlFlow;
use socket2::{Domain, Protocol, Socket, Type};
use std::io;

/// Calls the given libc function and wraps the result in an `io::Result`.
macro_rules! libc {
Copy link
Contributor

Choose a reason for hiding this comment

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

doesnt have to be in this PR but all setsockopt calls can use a comment explaining what its doing. Otherwise reader has to lookup the call and or be familiar with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@camshaft camshaft removed the request for review from WesleyRosenblum June 15, 2023 19:15
@camshaft camshaft force-pushed the camshaft/io-tokio-upgrade branch from db0dc35 to 0d69d19 Compare June 15, 2023 20:03
@camshaft camshaft requested a review from toidiu June 15, 2023 20:04
@camshaft camshaft enabled auto-merge (squash) June 15, 2023 20:04
@camshaft camshaft merged commit e127850 into main Jun 15, 2023
@camshaft camshaft deleted the camshaft/io-tokio-upgrade branch June 15, 2023 22:45
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.

3 participants