From d8c33c55518772a99f4010e105d4756b3e7ea7c9 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Thu, 17 May 2018 15:53:38 -0700 Subject: [PATCH] Fix TCP with Timeout 1. Take out DTLS support from EmbedReceive(). DTLS uses EmbedReceiveFrom(). 2. Modify EmbedReceive() to return TIMEOUT if the session is set to blocking mode. --- src/wolfio.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/src/wolfio.c b/src/wolfio.c index 053d7f453..03f62be6d 100644 --- a/src/wolfio.c +++ b/src/wolfio.c @@ -194,34 +194,13 @@ int EmbedReceive(WOLFSSL *ssl, char *buf, int sz, void *ctx) int sd = *(int*)ctx; int recvd; -#ifdef WOLFSSL_DTLS - { - int dtls_timeout = wolfSSL_dtls_get_current_timeout(ssl); - if (wolfSSL_dtls(ssl) - && !wolfSSL_get_using_nonblock(ssl) - && dtls_timeout != 0) { - #ifdef USE_WINDOWS_API - DWORD timeout = dtls_timeout * 1000; - #else - struct timeval timeout; - XMEMSET(&timeout, 0, sizeof(timeout)); - timeout.tv_sec = dtls_timeout; - #endif - if (setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, - sizeof(timeout)) != 0) { - WOLFSSL_MSG("setsockopt rcvtimeo failed"); - } - } - } -#endif - recvd = wolfIO_Recv(sd, buf, sz, ssl->rflags); if (recvd < 0) { int err = wolfSSL_LastError(); WOLFSSL_MSG("Embed Receive error"); if (err == SOCKET_EWOULDBLOCK || err == SOCKET_EAGAIN) { - if (!wolfSSL_dtls(ssl) || wolfSSL_get_using_nonblock(ssl)) { + if (wolfSSL_get_using_nonblock(ssl)) { WOLFSSL_MSG("\tWould block"); return WOLFSSL_CBIO_ERR_WANT_READ; }