From 673ccaa1e507ace210a7fbf5d9b9a2a56802f4a1 Mon Sep 17 00:00:00 2001 From: Kedar Sovani Date: Mon, 6 Aug 2018 11:36:40 +0530 Subject: [PATCH] Remove check for would_block in mbedtls Basically, in the portability layer, it is checked if the socket is NON-block, and if not, then even the EAGAIN and EWOULDBLOCK errors are diverted to a RECV error. This causes a problem for sockets with receive timeouts set. When such a timeout is set, the condition for NON_BLOCK isn't met and hence a hard error is returned. Searching for EAGAIN and EWOULDBLOCK in lwip returns only 3 results (accept, recvfrom, close) and all of them look to be genuine cases for EWOULDBLOCK. So removing this check to make receive timeout with TLS work. --- components/mbedtls/port/net_sockets.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/components/mbedtls/port/net_sockets.c b/components/mbedtls/port/net_sockets.c index e64510071e..d6ca4b6741 100644 --- a/components/mbedtls/port/net_sockets.c +++ b/components/mbedtls/port/net_sockets.c @@ -198,14 +198,6 @@ static int net_would_block( const mbedtls_net_context *ctx ) { int error = errno; - /* - * Never return 'WOULD BLOCK' on a non-blocking socket - */ - if ( ( fcntl( ctx->fd, F_GETFL, 0) & O_NONBLOCK ) != O_NONBLOCK ) { - errno = error; - return ( 0 ); - } - switch ( errno = error ) { #if defined EAGAIN case EAGAIN: