fixed deadlock situation with TLSSocket_read

pull/494/head
Federico Francescon 2 years ago
parent 21a5d4fdb3
commit 3f6198b54b

@ -923,22 +923,19 @@ TLSSocket_read(TLSSocket self, uint8_t* buf, int size)
int len = 0; int len = 0;
while (len < size) { while (len < size) {
int ret = mbedtls_ssl_read(&(self->ssl), (buf + len), (size - len)); int ret = mbedtls_ssl_read(&(self->ssl), (buf + len), (size - len));
if (ret == 0) { if (ret > 0) {
break;
} else if (ret > 0) {
len += ret; len += ret;
continue; continue;
} }
// Negative values means errors switch (ret) {
switch (ret) case 0: // falling through
{ case MBEDTLS_ERR_SSL_WANT_READ:
case MBEDTLS_ERR_SSL_WANT_READ: // Falling through
case MBEDTLS_ERR_SSL_WANT_WRITE: case MBEDTLS_ERR_SSL_WANT_WRITE:
case MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS: case MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS:
case MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS: case MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS:
continue; // Known "good" cases indicating the read is done
break; return len;
case MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY: case MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY:
DEBUG_PRINT("TLS", " connection was closed gracefully\n"); DEBUG_PRINT("TLS", " connection was closed gracefully\n");

Loading…
Cancel
Save