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

[bindings] Generalize async in preparation for pkey offloading #3844

Merged
merged 3 commits into from
Feb 23, 2023

Conversation

lrstewart
Copy link
Contributor

@lrstewart lrstewart commented Feb 21, 2023

Description of changes:

The previous async logic was very ClientHello-specific. I've refactored so that only one struct has special casing for the ClientHello callback.

I initially didn't even have that special casing and was using Futures to handle the mark_client_hello_cb_done, but that seemed like overkill since more recent async callbacks can handle their own "mark_done". For example: pkey callbacks have s2n_async_pkey_op_apply(s2n_async_pkey_op*), psks have s2n_offered_psk_list_choose_psk(struct s2n_offered_psk_list *), early data has s2n_offered_early_data_accept(struct s2n_offered_early_data *). Basically, our usual model is that async callbacks have a specific instance of a callback-specific context, and the application calls a method on that context to set a result or indicate completion. We don't need to wait for the ConnectionFuture to complete.

Here's an example of one of the new callbacks implemented: lrstewart@0a1505a

Call-outs:

  • I've got the non-special cased version of AsyncCallback::trigger commented out, but I left it there as an example.
  • PLEASE REVIEW MY PINNING. I think the Pins got away from me and multiplied more than they needed to? I may never truly understand Pins. The thought of my memory moving around horrifies me.

Testing:

Existing ClientHello callback tests pass.

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

@github-actions github-actions bot added the s2n-core team label Feb 21, 2023
@lrstewart lrstewart marked this pull request as ready for review February 22, 2023 00:55
@lrstewart lrstewart requested a review from maddeleine February 23, 2023 01:06
Comment on lines +144 to +153
// pub(crate) fn trigger(
// future: ConnectionFutureResult,
// conn: &mut Connection,
//) -> CallbackResult {
// let future = OptionalFuture::new(future);
// let cleanup = MarkDone::None;
// let callback = AsyncCallback { future, cleanup };
// conn.set_async_callback(callback);
// CallbackResult::Success
//}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm assuming this is going to be used for a later PR? I would say to probably include it there, if so

Copy link
Contributor

Choose a reason for hiding this comment

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

I just saw that in your call outs. Not a big deal, then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I usually don't liked commented out code, but I'm un-commenting it in literally the next PR and without it it looks like this is still pretty client-hello specific ;) I just didn't want everyone calling trigger to have to pass in the MarkDone, even though only the ClientHello needs it.

@lrstewart lrstewart enabled auto-merge (squash) February 23, 2023 18:21
@lrstewart lrstewart merged commit dadacbd into aws:main Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants