Fix missing return statement ssl_server2 idling

Also, introduce MBEDTLS_EINTR locally in net_sockets.c
for the platform-dependent return code macro used by
the `select` call to indicate that the poll was interrupted
by a signal handler: On Unix, the corresponding macro is EINTR,
while on Windows, it's WSAEINTR.
This commit is contained in:
Hanno Becker 2018-03-15 15:49:24 +00:00
parent 80e06d77d9
commit ef52796537
3 changed files with 7 additions and 8 deletions

View file

@ -45,6 +45,8 @@
#if (defined(_WIN32) || defined(_WIN32_WCE)) && !defined(EFIX64) && \ #if (defined(_WIN32) || defined(_WIN32_WCE)) && !defined(EFIX64) && \
!defined(EFI32) !defined(EFI32)
#define MBEDTLS_EINTR WSAEINTR
#ifdef _WIN32_WINNT #ifdef _WIN32_WINNT
#undef _WIN32_WINNT #undef _WIN32_WINNT
#endif #endif
@ -82,6 +84,8 @@ static int wsa_init_done = 0;
#include <netdb.h> #include <netdb.h>
#include <errno.h> #include <errno.h>
#define MBEDTLS_EINTR EINTR
#endif /* ( _WIN32 || _WIN32_WCE ) && !EFIX64 && !EFI32 */ #endif /* ( _WIN32 || _WIN32_WCE ) && !EFIX64 && !EFI32 */
/* Some MS functions want int and MSVC warns if we pass size_t, /* Some MS functions want int and MSVC warns if we pass size_t,
@ -475,12 +479,7 @@ int mbedtls_net_poll( mbedtls_net_context *ctx, uint32_t rw, uint32_t timeout )
ret = select( fd + 1, &read_fds, &write_fds, NULL, ret = select( fd + 1, &read_fds, &write_fds, NULL,
timeout == (uint32_t) -1 ? NULL : &tv ); timeout == (uint32_t) -1 ? NULL : &tv );
} }
#if ( defined(_WIN32) || defined(_WIN32_WCE) ) && !defined(EFIX64) && \ while( ret == MBEDTLS_EINTR );
!defined(EFI32)
while( ret == WSAEINTR );
#else
while( ret == EINTR );
#endif
if( ret < 0 ) if( ret < 0 )
return( MBEDTLS_ERR_NET_POLL_FAILED ); return( MBEDTLS_ERR_NET_POLL_FAILED );

View file

@ -462,7 +462,7 @@ int idle( mbedtls_net_context *fd,
poll_type = MBEDTLS_NET_POLL_READ; poll_type = MBEDTLS_NET_POLL_READ;
#if !defined(MBEDTLS_TIMING_C) #if !defined(MBEDTLS_TIMING_C)
else else
return; return( 0 );
#endif #endif
while( 1 ) while( 1 )

View file

@ -863,7 +863,7 @@ int idle( mbedtls_net_context *fd,
poll_type = MBEDTLS_NET_POLL_READ; poll_type = MBEDTLS_NET_POLL_READ;
#if !defined(MBEDTLS_TIMING_C) #if !defined(MBEDTLS_TIMING_C)
else else
return; return( 0 );
#endif #endif
while( 1 ) while( 1 )