aboutsummaryrefslogtreecommitdiff
path: root/fdmisc.c
diff options
context:
space:
mode:
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2006-02-16 18:12:24 +0000
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2006-02-16 18:12:24 +0000
commit6add6b2fe78c549d174729869e26cee917e31d5f (patch)
tree7b0786b12c40853bd9742d61e07417ade430f3d2 /fdmisc.c
parentAdded "bytecount" command to management interface. (diff)
downloadopenvpn-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.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/fdmisc.c b/fdmisc.c
index 8c8b91e..eb7a6fc 100644
--- a/fdmisc.c
+++ b/fdmisc.c
@@ -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");
}