-
Notifications
You must be signed in to change notification settings - Fork 722
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
Conversation
a1aa9d2
to
2a5e152
Compare
// 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 | ||
//} |
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 assuming this is going to be used for a later PR? I would say to probably include it there, if so
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 just saw that in your call outs. Not a big deal, then.
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.
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.
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:
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.