-
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] Hide ffi types + basic debug info #3279
Conversation
@@ -126,9 +126,9 @@ where | |||
Poll::Ready(Ok(len)) => len as c_int, | |||
Poll::Pending => { | |||
set_errno(Errno(libc::EWOULDBLOCK)); | |||
s2n_status_code::FAILURE | |||
CallbackResult::Failure.into() |
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.
just an observation: this seems alittle odd since we dont use the Success type and instead return len as c_int
. Also it would be nice to have poll_io
return CallbackResult
here and have the downstream function handle the conversion.
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.
also wondering if CallbackResult should instead be called StatusCode so that its reusable for non callback types
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 not trying to solve callbacks here-- that's for later ;) I'm just trying to hide the C types.
just an observation: this seems alittle odd since we dont use the Success type and instead return len as c_int
The interface of some s2n-tls callbacks is a little odd :( We can't use the Success value because success for this callback means a valid length, not a success status code.
it would be nice to have poll_io return CallbackResult here and have the downstream function handle the conversion.
There isn't really a downstream function here to handle the conversion-- this is a callback that will return to C code that doesn't understand Rust enums.
also wondering if CallbackResult should instead be called StatusCode so that its reusable for non callback types
I choose "CallbackResult" because a customer's only interaction with this enum should be writing callbacks, since we handle the status codes returned by s2n-tls APIs. And I would love to remove that interaction too xD
9ce5742
to
182d61f
Compare
Description of changes:
Some minor updates to the low level bindings:
Call-outs:
I'm still not sure we're handling
debug
/s2n_strerror_debug
correctly. It behaves more likes2n_errno
thans2n_strerror_name
ors2n_strerror
. The debug string is set when an error occurs, but will be overridden by any later errors. It's possible we should be copying the debug string into an owned string when we capture the error code. But is allocating a string for every s2n error an issue?Testing:
Added some asserts to the existing test.
Here's the debugging information printed from the example client and server:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.