未验证 提交 560c0f45 编写于 作者: C Clemens Kirchgatterer 提交者: GitHub

Fix dropped SSL connection when buffer gets full. (#4820)

mbedTLS requires repeated calls to mbedtls_ssl_write() whenever it returns MBEDTLS_ERR_SSL_WANT_READ or MBEDTLS_ERR_SSL_WANT_WRITE. this happens when the client sends data faster then the server or the connection can handle.
上级 4b3f5c8e
......@@ -295,11 +295,13 @@ int send_ssl_data(sslclient_context *ssl_client, const uint8_t *data, uint16_t l
log_v("Writing HTTP request with %d bytes...", len); //for low level debug
int ret = -1;
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
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 && ret < 0) {
log_v("Handling error %d", ret); //for low level debug
return handle_error(ret);
}
//wait for space to become available
vTaskDelay(2);
}
return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册