-
Notifications
You must be signed in to change notification settings - Fork 3k
TLSSocket send/recv return WOULD_BLOCK error instead of NO_CONNECTION #9584
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
TLSSocket send/recv return WOULD_BLOCK error instead of NO_CONNECTION #9584
Conversation
@michalpasztamobica, thank you for your changes. |
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 don't see why you are changing this?
When calling Socket::connect() in non blocking mode:
- First call returns
NSAPI_ERROR_IN_PROGRESS
which means that asyncronous operation started. - All subsequent calls return
NSAPI_ERROR_ALREADY
until connection is reached. - When connected, returns
NSAPI_ERROR_IS_CONNECTED
There is no WOULD_BLOCK
in Socket::connect()
What was the problem you are fixing?
@@ -197,9 +197,6 @@ nsapi_error_t TLSSocketWrapper::start_handshake(bool first_call) | |||
|
|||
ret = continue_handshake(); | |||
if (first_call) { | |||
if (ret == NSAPI_ERROR_ALREADY) { | |||
ret = NSAPI_ERROR_IN_PROGRESS; // If first call should return IN_PROGRESS |
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.
This sounds like you are changing the API.
4ead3ed
to
9fb0bf6
Compare
@SeppoTakalo , thank you for your alertness, I overinterpreted my task. There should be no API change, indeed. The PR was only meant to address the return type of continue_handshake. Now I see that connect's behavior should remain unchanged. I amended the PR, I hope it's ok now. |
eeb3ea3
to
7ece4e7
Compare
With the current code the status is following:
@SeppoTakalo , please confirm that we have the common understanding of the situation. |
Not exactly, continue_handshake() returns:
This is called from connect(), which might translate calls, and return:
Same kind of translation might happen in send()/recv() calls, where they might call continue_handshake() in case TLS handshake was not completed. In those case it might return:
|
In case mbedtls fails to execute handshake advertising MBEDTLS_ERR_SSL_WANT_READ or MBEDTLS_ERR_SSL_WANT_WRITE, TLSSocketWrapper::continue_handshake returns NSAPI_ERROR_WOULD_BLOCK.
7ece4e7
to
9db9724
Compare
I have run an internal CI job against the mbed-client-testapp and all tests passed fine. @SeppoTakalo , do you have more ideas on what we could check before merging this into master? |
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.
Think this looks OK now
@0xc0170 , this PR is already approved. Could you change the label, please? |
CI started |
Test run: SUCCESSSummary: 12 of 12 test jobs passed |
Description
In case mbedtls handshake advertising MBEDTLS_ERR_SSL_WANT_READ or MBEDTLS_ERR_SSL_WANT_WRITE is not really a critical error and should be recoverable. We improve the accurateness of the return value from send/recv function by returning NSAPI_ERROR_WOULD_BLOCK instead of NSAPI_ERROR_NO_CONNECTION in such case.
Pull request type
Reviewers
@SeppoTakalo
@kjbracey-arm