Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork218
TLSSocketWrapper split read/write event flags#983
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
69 changes: 69 additions & 0 deletionspatches/0240-TLSSocketWrapper-add-read-write-event-flags.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| From 4369443525c662ddb2ecb15dd9cdba0098e1f01d Mon Sep 17 00:00:00 2001 | ||
| From: pennam <m.pennasilico@arduino.cc> | ||
| Date: Mon, 28 Oct 2024 09:56:31 +0100 | ||
| Subject: [PATCH] TLSSocketWrapper: add read/write event flags | ||
| This allows to properly handle timeouts during read write operations | ||
| --- | ||
| .../netsocket/include/netsocket/TLSSocketWrapper.h | 4 ++++ | ||
| connectivity/netsocket/source/TLSSocketWrapper.cpp | 8 ++++---- | ||
| 2 files changed, 8 insertions(+), 4 deletions(-) | ||
| diff --git a/connectivity/netsocket/include/netsocket/TLSSocketWrapper.h b/connectivity/netsocket/include/netsocket/TLSSocketWrapper.h | ||
| index 2dc3b4b000..79fe5c564d 100644 | ||
| --- a/connectivity/netsocket/include/netsocket/TLSSocketWrapper.h | ||
| +++ b/connectivity/netsocket/include/netsocket/TLSSocketWrapper.h | ||
| @@ -379,6 +379,10 @@ private: | ||
| Socket *_transport; | ||
| int _timeout = -1; | ||
| + // Event flags | ||
| + static const int READ_FLAG = 0x1u; | ||
| + static const int WRITE_FLAG = 0x2u; | ||
| + | ||
| #ifdef MBEDTLS_X509_CRT_PARSE_C | ||
| mbedtls_x509_crt *_cacert = nullptr; | ||
| mbedtls_x509_crt *_clicert = nullptr; | ||
| diff --git a/connectivity/netsocket/source/TLSSocketWrapper.cpp b/connectivity/netsocket/source/TLSSocketWrapper.cpp | ||
| index c020cd9f59..3a66be2e5e 100644 | ||
| --- a/connectivity/netsocket/source/TLSSocketWrapper.cpp | ||
| +++ b/connectivity/netsocket/source/TLSSocketWrapper.cpp | ||
| @@ -381,7 +381,7 @@ nsapi_error_t TLSSocketWrapper::continue_handshake() | ||
| ret = mbedtls_ssl_handshake(&_ssl); | ||
| if (_timeout && (ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE)) { | ||
| uint32_t flag; | ||
| - flag = _event_flag.wait_any(1, _timeout); | ||
| + flag = _event_flag.wait_any(WRITE_FLAG | READ_FLAG, _timeout); | ||
| if (flag & osFlagsError) { | ||
| break; | ||
| } | ||
| @@ -461,7 +461,7 @@ nsapi_error_t TLSSocketWrapper::send(const void *data, nsapi_size_t size) | ||
| break; | ||
| } else if (ret == MBEDTLS_ERR_SSL_WANT_WRITE || ret == MBEDTLS_ERR_SSL_WANT_READ) { | ||
| uint32_t flag; | ||
| - flag = _event_flag.wait_any(1, _timeout); | ||
| + flag = _event_flag.wait_any(WRITE_FLAG, _timeout); | ||
| if (flag & osFlagsError) { | ||
| // Timeout break | ||
| break; | ||
| @@ -522,7 +522,7 @@ nsapi_size_or_error_t TLSSocketWrapper::recv(void *data, nsapi_size_t size) | ||
| break; | ||
| } else if (ret == MBEDTLS_ERR_SSL_WANT_WRITE || ret == MBEDTLS_ERR_SSL_WANT_READ) { | ||
| uint32_t flag; | ||
| - flag = _event_flag.wait_any(1, _timeout); | ||
| + flag = _event_flag.wait_any(READ_FLAG, _timeout); | ||
| if (flag & osFlagsError) { | ||
| // Timeout break | ||
| break; | ||
| @@ -855,7 +855,7 @@ nsapi_error_t TLSSocketWrapper::listen(int) | ||
| void TLSSocketWrapper::event() | ||
| { | ||
| - _event_flag.set(1); | ||
| + _event_flag.set(READ_FLAG | WRITE_FLAG); | ||
| if (_sigio) { | ||
| _sigio(); | ||
| } | ||
| -- | ||
| 2.45.2 | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.