[Openvpn-devel,v2,4/6] Remove support for blocking connect()

Message ID 20210422152939.2134046-4-arne@rfc2549.org
State Changes Requested
Headers show
Series [Openvpn-devel,v2,1/6] Avoid failing_test unused warning in example_test | expand

Commit Message

Arne Schwabe April 22, 2021, 5:29 a.m. UTC
It is hard to imagine that we still have any supported OS that does
not support non-blocking connect while still supporting non-blocking
sockets in general.

Patch V2: remove epoll.h removal that should have been in other patch.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
---
 src/openvpn/socket.c  | 8 --------
 src/openvpn/syshead.h | 7 -------
 2 files changed, 15 deletions(-)

Comments

Gert Doering May 2, 2021, 8:14 p.m. UTC | #1
Hi,

On Thu, Apr 22, 2021 at 05:29:37PM +0200, Arne Schwabe wrote:
> It is hard to imagine that we still have any supported OS that does
> not support non-blocking connect while still supporting non-blocking
> sockets in general.
> 
> Patch V2: remove epoll.h removal that should have been in other patch.

Feature-ACK, but you missed one

socket.c:

socket_connect(socket_descriptor_t *sd,
...
#ifdef CONNECT_NONBLOCK
    msg(M_INFO, "Attempting to establish TCP connection with %s [nonblock]",
        print_sockaddr(dest, &gc));


v3, please :-)

gert

Patch

diff --git a/src/openvpn/socket.c b/src/openvpn/socket.c
index 8a6e42cc6..4e13c65e8 100644
--- a/src/openvpn/socket.c
+++ b/src/openvpn/socket.c
@@ -1459,7 +1459,6 @@  openvpn_connect(socket_descriptor_t sd,
     protect_fd_nonlocal(sd, remote);
 #endif
 
-#ifdef CONNECT_NONBLOCK
     set_nonblock(sd);
     status = connect(sd, remote, af_addr_size(remote->sa_family));
     if (status)
@@ -1540,13 +1539,6 @@  openvpn_connect(socket_descriptor_t sd,
             }
         }
     }
-#else  /* ifdef CONNECT_NONBLOCK */
-    status = connect(sd, remote, af_addr_size(remote->sa_family));
-    if (status)
-    {
-        status = openvpn_errno();
-    }
-#endif /* ifdef CONNECT_NONBLOCK */
 
     return status;
 }
diff --git a/src/openvpn/syshead.h b/src/openvpn/syshead.h
index f29c63c73..3f2e563b7 100644
--- a/src/openvpn/syshead.h
+++ b/src/openvpn/syshead.h
@@ -545,13 +545,6 @@  socket_defined(const socket_descriptor_t sd)
 #define EPOLL 0
 #endif
 
-/*
- * Is non-blocking connect() supported?
- */
-#if defined(SOL_SOCKET) && defined(SO_ERROR) && defined(EINPROGRESS) && defined(ETIMEDOUT)
-#define CONNECT_NONBLOCK
-#endif
-
 /*
  * Compression support
  */