Skip to content

Commit

Permalink
Merge pull request #2 from SeeedJP/dev-matsujirushi
Browse files Browse the repository at this point in the history
Fix to freeze when receive MQTTS
  • Loading branch information
Pillar1989 committed Jul 31, 2020
2 parents 80b3582 + b141ed6 commit 1d79311
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/port/net_sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,24 +339,23 @@ int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len )
{
int ret;
int fd = ((mbedtls_net_context *) ctx)->fd;
int error = 0;

if ( fd < 0 ) {
return ( MBEDTLS_ERR_NET_INVALID_CONTEXT );
}

ret = (int) atu_recv_r( fd, buf, len, 0 );
ret = (int) atu_recv_r( fd, buf, len, MSG_DONTWAIT);

if ( ret < 0 ) {
if ( net_would_block( ctx, &error ) != 0 ) {
if (errno == EWOULDBLOCK) {
return ( MBEDTLS_ERR_SSL_WANT_READ );
}

if ( error == EPIPE || error == ECONNRESET ) {
if (errno == EPIPE || errno == ECONNRESET) {
return ( MBEDTLS_ERR_NET_CONN_RESET );
}

if ( error == EINTR ) {
if (errno == EINTR) {
return ( MBEDTLS_ERR_SSL_WANT_READ );
}

Expand Down

0 comments on commit 1d79311

Please sign in to comment.