From 9038ea018aceb9276b560b29d811ca2e12b09228 Mon Sep 17 00:00:00 2001 From: Chris Conlon Date: Fri, 24 Jul 2015 15:06:58 -0600 Subject: [PATCH] Freescale/RTCS fixes for io.c --- src/io.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/io.c b/src/io.c index 195056665..a55fa8450 100644 --- a/src/io.c +++ b/src/io.c @@ -210,6 +210,10 @@ static INLINE int TranslateReturnCode(int old, int sd) errno = RTCS_geterror(sd); if (errno == RTCSERR_TCP_CONN_CLOSING) return 0; /* convert to BSD style closing */ + if (errno == RTCSERR_TCP_CONN_RLSD) + errno = SOCKET_ECONNRESET; + if (errno == RTCSERR_TCP_TIMED_OUT) + errno = SOCKET_EAGAIN; } #endif @@ -316,6 +320,8 @@ int EmbedSend(WOLFSSL* ssl, char *buf, int sz, void *ctx) sent = (int)SEND_FUNCTION(sd, &buf[sz - len], len, ssl->wflags); + sent = TranslateReturnCode(sent, sd); + if (sent < 0) { err = LastError(); WOLFSSL_MSG("Embed Send error"); @@ -454,6 +460,9 @@ int EmbedSendTo(WOLFSSL* ssl, char *buf, int sz, void *ctx) sent = (int)SENDTO_FUNCTION(sd, &buf[sz - len], len, ssl->wflags, (const struct sockaddr*)dtlsCtx->peer.sa, dtlsCtx->peer.sz); + + sent = TranslateReturnCode(sent, sd); + if (sent < 0) { err = LastError(); WOLFSSL_MSG("Embed Send To error");