Skip to content

Commit

Permalink
Merge pull request #7581 from dgarske/embos_emnet
Browse files Browse the repository at this point in the history
Fixes for Segger emNet to handle non-blocking want read/want write
  • Loading branch information
anhu authored May 24, 2024
2 parents a5154b2 + 9b058ec commit 021b573
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/wolfio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 <fclerrno.h>
Expand Down
4 changes: 3 additions & 1 deletion wolfssl/wolfio.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@
#include <sys/fcltypes.h>
#include <fclerrno.h>
#include <fclfcntl.h>
#elif defined(WOLFSSL_EMNET)
#include <IP/IP.h>
#elif !defined(WOLFSSL_NO_SOCK)
#include <sys/types.h>
#include <errno.h>
Expand Down Expand Up @@ -305,7 +307,7 @@
#define SOCKET_ECONNREFUSED ERR_CONN
#define SOCKET_ECONNABORTED ERR_ABRT
#elif defined(WOLFSSL_EMNET)
#include <IP/IP.h>
#define XSOCKLENT int
#define SOCKET_EWOULDBLOCK IP_ERR_WOULD_BLOCK
#define SOCKET_EAGAIN IP_ERR_WOULD_BLOCK
#define SOCKET_ECONNRESET IP_ERR_CONN_RESET
Expand Down

0 comments on commit 021b573

Please sign in to comment.