From 9b058ec3a2a2d51ea68dfeac4f76cb6c10f7b499 Mon Sep 17 00:00:00 2001 From: David Garske Date: Fri, 17 May 2024 12:51:12 -0700 Subject: [PATCH] Fixes for EMNET with non-blocking to handle want read/want write. ZD 18012 --- src/wolfio.c | 7 ++++++- wolfssl/wolfio.h | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/wolfio.c b/src/wolfio.c index 8893e44f2..72e8dda7f 100644 --- a/src/wolfio.c +++ b/src/wolfio.c @@ -153,6 +153,11 @@ static WC_INLINE int TranslateReturnCode(int old, int sd) if (errno == RTCSERR_TCP_TIMED_OUT) errno = SOCKET_EAGAIN; } +#elif defined(WOLFSSL_EMNET) + if (old < 0) { /* SOCKET_ERROR */ + /* Get the real socket error */ + IP_SOCK_getsockopt(sd, SOL_SOCKET, SO_ERROR, &old, (int)sizeof(old)); + } #endif return old; @@ -166,7 +171,7 @@ static WC_INLINE int wolfSSL_LastError(int err) return WSAGetLastError(); #elif defined(EBSNET) return xn_getlasterror(); -#elif defined(WOLFSSL_LINUXKM) +#elif defined(WOLFSSL_LINUXKM) || defined(WOLFSSL_EMNET) return err; /* Return provided error value */ #elif defined(FUSION_RTOS) #include diff --git a/wolfssl/wolfio.h b/wolfssl/wolfio.h index 5ebb44fb0..e2a1c887e 100644 --- a/wolfssl/wolfio.h +++ b/wolfssl/wolfio.h @@ -150,6 +150,8 @@ #include #include #include + #elif defined(WOLFSSL_EMNET) + #include #elif !defined(WOLFSSL_NO_SOCK) #include #include @@ -305,7 +307,7 @@ #define SOCKET_ECONNREFUSED ERR_CONN #define SOCKET_ECONNABORTED ERR_ABRT #elif defined(WOLFSSL_EMNET) - #include + #define XSOCKLENT int #define SOCKET_EWOULDBLOCK IP_ERR_WOULD_BLOCK #define SOCKET_EAGAIN IP_ERR_WOULD_BLOCK #define SOCKET_ECONNRESET IP_ERR_CONN_RESET