From d6b91872cb5785be1382a26cdf7da9fb60a02e13 Mon Sep 17 00:00:00 2001 From: Ivan Golubic Date: Mon, 2 Nov 2020 20:59:03 +0400 Subject: [PATCH] Fix for espressif#3460 issue (#4424) Fixes: #3460 This code has been run in production for 1 month and it looks stable, no data dropped and it definitely fixes the issue described. I think that this can be merged to avoid using custom package referencing in PlatformIO that has been used in quite a few projects for now. Co-authored-by: Ivan Golubic --- libraries/WiFiClientSecure/src/ssl_client.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/libraries/WiFiClientSecure/src/ssl_client.cpp b/libraries/WiFiClientSecure/src/ssl_client.cpp index cf328b74..9f168a0a 100644 --- a/libraries/WiFiClientSecure/src/ssl_client.cpp +++ b/libraries/WiFiClientSecure/src/ssl_client.cpp @@ -284,24 +284,21 @@ int data_to_read(sslclient_context *ssl_client) return res; } - int send_ssl_data(sslclient_context *ssl_client, const uint8_t *data, uint16_t len) { - log_v("Writing HTTP request..."); //for low level debug + log_v("Writing HTTP request with %d bytes...", len); //for low level debug int ret = -1; - while ((ret = mbedtls_ssl_write(&ssl_client->ssl_ctx, data, len)) <= 0) { - if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) { - return handle_error(ret); - } + if ((ret = mbedtls_ssl_write(&ssl_client->ssl_ctx, data, len)) <= 0){ + log_v("Handling error %d", ret); //for low level debug + return handle_error(ret); + } else{ + log_v("Returning with %d bytes written", ret); //for low level debug } - len = ret; - //log_v("%d bytes written", len); //for low level debug return ret; } - int get_ssl_receive(sslclient_context *ssl_client, uint8_t *data, int length) { //log_d( "Reading HTTP response..."); //for low level debug