summaryrefslogtreecommitdiff
path: root/src/openvpn/fdmisc.c
diff options
context:
space:
mode:
authorAlberto Gonzalez Iniesta <agi@inittab.org>2016-12-27 18:25:47 +0100
committerAlberto Gonzalez Iniesta <agi@inittab.org>2016-12-27 18:25:47 +0100
commit3a2bbdb05ca6a6996e424c9fb225cb0d53804125 (patch)
treef29063da5bec4caf3853d49a22a09c8619eebd21 /src/openvpn/fdmisc.c
parentd53dba59e78da865c4fe820386ff2f4f76925f3b (diff)
New upstream version 2.4.0upstream/2.4.0
Diffstat (limited to 'src/openvpn/fdmisc.c')
-rw-r--r--src/openvpn/fdmisc.c48
1 files changed, 29 insertions, 19 deletions
diff --git a/src/openvpn/fdmisc.c b/src/openvpn/fdmisc.c
index ce01319..401069d 100644
--- a/src/openvpn/fdmisc.c
+++ b/src/openvpn/fdmisc.c
@@ -5,7 +5,7 @@
* packet encryption, packet authentication, and
* packet compression.
*
- * Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2002-2017 OpenVPN Technologies, Inc. <sales@openvpn.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -37,42 +37,52 @@
/* Set a file descriptor to non-blocking */
bool
-set_nonblock_action (int fd)
+set_nonblock_action(int fd)
{
#ifdef _WIN32
- u_long arg = 1;
- if (ioctlsocket (fd, FIONBIO, &arg))
- return false;
-#else
- if (fcntl (fd, F_SETFL, O_NONBLOCK) < 0)
- return false;
+ u_long arg = 1;
+ if (ioctlsocket(fd, FIONBIO, &arg))
+ {
+ return false;
+ }
+#else /* ifdef _WIN32 */
+ if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0)
+ {
+ return false;
+ }
#endif
- return true;
+ return true;
}
/* Set a file descriptor to not be passed across execs */
bool
-set_cloexec_action (int fd)
+set_cloexec_action(int fd)
{
#ifndef _WIN32
- if (fcntl (fd, F_SETFD, FD_CLOEXEC) < 0)
- return false;
+ if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0)
+ {
+ return false;
+ }
#endif
- return true;
+ return true;
}
/* Set a file descriptor to non-blocking */
void
-set_nonblock (int fd)
+set_nonblock(int fd)
{
- if (!set_nonblock_action (fd))
- msg (M_ERR, "Set socket to non-blocking mode failed");
+ if (!set_nonblock_action(fd))
+ {
+ msg(M_ERR, "Set socket to non-blocking mode failed");
+ }
}
/* Set a file descriptor to not be passed across execs */
void
-set_cloexec (int fd)
+set_cloexec(int fd)
{
- if (!set_cloexec_action (fd))
- msg (M_ERR, "Set FD_CLOEXEC flag on file descriptor failed");
+ if (!set_cloexec_action(fd))
+ {
+ msg(M_ERR, "Set FD_CLOEXEC flag on file descriptor failed");
+ }
}