From c5f6d180ddbef54728a0eeea976e1f76a25e6a78 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Fri, 24 Nov 2017 11:47:13 +0800 Subject: [PATCH] mbedtls: handle NET_SEND_FAILED Under the condition the associated client went away (turn off WLAN at the client), we can spin forever mistaking NET_SEND_FAILED for WANT_WRITE, which was also true. This makes sure we understand that was fatal immediately. --- lib/tls/mbedtls/wrapper/platform/ssl_pm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/tls/mbedtls/wrapper/platform/ssl_pm.c b/lib/tls/mbedtls/wrapper/platform/ssl_pm.c index 8445bfe81..354b0c7f3 100755 --- a/lib/tls/mbedtls/wrapper/platform/ssl_pm.c +++ b/lib/tls/mbedtls/wrapper/platform/ssl_pm.c @@ -377,8 +377,10 @@ int ssl_pm_read(SSL *ssl, void *buffer, int len) ret = mbedtls_ssl_read(&ssl_pm->ssl, buffer, len); if (ret < 0) { + //printf("%s: mbedtls_ssl_read says -0x%x\n", __func__, -ret); SSL_DEBUG(SSL_PLATFORM_ERROR_LEVEL, "mbedtls_ssl_read() return -0x%x", -ret); - if (ret == MBEDTLS_ERR_NET_CONN_RESET) + if (ret == MBEDTLS_ERR_NET_CONN_RESET || + ret <= MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE) /* fatal errors */ ssl->err = SSL_ERROR_SYSCALL; ret = -1; } @@ -418,6 +420,7 @@ int ssl_pm_send(SSL *ssl, const void *buffer, int len) if (ret < 0) { SSL_DEBUG(SSL_PLATFORM_ERROR_LEVEL, "mbedtls_ssl_write() return -0x%x", -ret); switch (ret) { + case MBEDTLS_ERR_NET_SEND_FAILED: case MBEDTLS_ERR_NET_CONN_RESET: ssl->err = SSL_ERROR_SYSCALL; break;