mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/fix_transport_ssl_blocking' into 'master'
transport: fix transport ssl blocking See merge request espressif/esp-idf!10120
This commit is contained in:
commit
ddd8ca6671
@ -87,6 +87,7 @@ static int ssl_poll_read(esp_transport_handle_t t, int timeout_ms)
|
|||||||
{
|
{
|
||||||
transport_ssl_t *ssl = esp_transport_get_context_data(t);
|
transport_ssl_t *ssl = esp_transport_get_context_data(t);
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
int remain = 0;
|
||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
fd_set readset;
|
fd_set readset;
|
||||||
fd_set errset;
|
fd_set errset;
|
||||||
@ -95,6 +96,10 @@ static int ssl_poll_read(esp_transport_handle_t t, int timeout_ms)
|
|||||||
FD_SET(ssl->tls->sockfd, &readset);
|
FD_SET(ssl->tls->sockfd, &readset);
|
||||||
FD_SET(ssl->tls->sockfd, &errset);
|
FD_SET(ssl->tls->sockfd, &errset);
|
||||||
|
|
||||||
|
if ((remain = esp_tls_get_bytes_avail(ssl->tls)) > 0) {
|
||||||
|
ESP_LOGD(TAG, "remain data in cache, need to read again");
|
||||||
|
return remain;
|
||||||
|
}
|
||||||
ret = select(ssl->tls->sockfd + 1, &readset, NULL, &errset, esp_transport_utils_ms_to_timeval(timeout_ms, &timeout));
|
ret = select(ssl->tls->sockfd + 1, &readset, NULL, &errset, esp_transport_utils_ms_to_timeval(timeout_ms, &timeout));
|
||||||
if (ret > 0 && FD_ISSET(ssl->tls->sockfd, &errset)) {
|
if (ret > 0 && FD_ISSET(ssl->tls->sockfd, &errset)) {
|
||||||
int sock_errno = 0;
|
int sock_errno = 0;
|
||||||
@ -150,10 +155,8 @@ static int ssl_read(esp_transport_handle_t t, char *buffer, int len, int timeout
|
|||||||
int poll, ret;
|
int poll, ret;
|
||||||
transport_ssl_t *ssl = esp_transport_get_context_data(t);
|
transport_ssl_t *ssl = esp_transport_get_context_data(t);
|
||||||
|
|
||||||
if (esp_tls_get_bytes_avail(ssl->tls) <= 0) {
|
if ((poll = esp_transport_poll_read(t, timeout_ms)) <= 0) {
|
||||||
if ((poll = esp_transport_poll_read(t, timeout_ms)) <= 0) {
|
return poll;
|
||||||
return poll;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ret = esp_tls_conn_read(ssl->tls, (unsigned char *)buffer, len);
|
ret = esp_tls_conn_read(ssl->tls, (unsigned char *)buffer, len);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user