diff options
author | james <james@e7ae566f-a301-0410-adde-c780ea21d3b5> | 2006-02-16 18:12:24 +0000 |
---|---|---|
committer | james <james@e7ae566f-a301-0410-adde-c780ea21d3b5> | 2006-02-16 18:12:24 +0000 |
commit | 6add6b2fe78c549d174729869e26cee917e31d5f (patch) | |
tree | 7b0786b12c40853bd9742d61e07417ade430f3d2 /fdmisc.c | |
parent | Added "bytecount" command to management interface. (diff) | |
download | openvpn-6add6b2fe78c549d174729869e26cee917e31d5f.tar.xz |
Added --port-share option for allowing OpenVPN and HTTPS
server to share the same port number.
git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@893 e7ae566f-a301-0410-adde-c780ea21d3b5
Diffstat (limited to 'fdmisc.c')
-rw-r--r-- | fdmisc.c | 32 |
1 files changed, 25 insertions, 7 deletions
@@ -36,25 +36,43 @@ #include "memdbg.h" /* Set a file descriptor to non-blocking */ -void -set_nonblock (int fd) +bool +set_nonblock_action (int fd) { #ifdef WIN32 u_long arg = 1; if (ioctlsocket (fd, FIONBIO, &arg)) - msg (M_SOCKERR, "Set socket to non-blocking mode failed"); + return false; #else if (fcntl (fd, F_SETFL, O_NONBLOCK) < 0) - msg (M_ERR, "Set file descriptor to non-blocking mode failed"); + return false; #endif + return true; } /* Set a file descriptor to not be passed across execs */ -void -set_cloexec (int fd) +bool +set_cloexec_action (int fd) { #ifndef WIN32 if (fcntl (fd, F_SETFD, FD_CLOEXEC) < 0) - msg (M_ERR, "Set FD_CLOEXEC flag on file descriptor failed"); + return false; #endif + return true; +} + +/* Set a file descriptor to non-blocking */ +void +set_nonblock (int fd) +{ + if (!set_nonblock_action (fd)) + msg (M_SOCKERR, "Set socket to non-blocking mode failed"); +} + +/* Set a file descriptor to not be passed across execs */ +void +set_cloexec (int fd) +{ + if (!set_cloexec_action (fd)) + msg (M_ERR, "Set FD_CLOEXEC flag on file descriptor failed"); } |