aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/mhd_itc.c
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2016-08-23 20:13:26 +0000
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2016-08-23 20:13:26 +0000
commit76a4a10d96c8efb424bfac6cc16b1d14ec5a94dc (patch)
treeceb25c44466bfa53cb87e42dd46ca7d7827cfde9 /src/microhttpd/mhd_itc.c
parentb6d29e0cb35aeb2df21f2e959a93ca0552951009 (diff)
downloadlibmicrohttpd-76a4a10d96c8efb424bfac6cc16b1d14ec5a94dc.tar.gz
libmicrohttpd-76a4a10d96c8efb424bfac6cc16b1d14ec5a94dc.zip
Moved make_nonblocking() to mhd_sockets.c, added MHD_itc_nonblocking() for pipes.
Diffstat (limited to 'src/microhttpd/mhd_itc.c')
-rw-r--r--src/microhttpd/mhd_itc.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/microhttpd/mhd_itc.c b/src/microhttpd/mhd_itc.c
index cd0e5371..71e54a0d 100644
--- a/src/microhttpd/mhd_itc.c
+++ b/src/microhttpd/mhd_itc.c
@@ -26,6 +26,11 @@
26 26
27#include "mhd_itc.h" 27#include "mhd_itc.h"
28 28
29#ifdef HAVE_UNISTD_H
30#include <unistd.h>
31#endif /* HAVE_UNISTD_H */
32#include <fcntl.h>
33
29#if defined(_WIN32) && !defined(__CYGWIN__) 34#if defined(_WIN32) && !defined(__CYGWIN__)
30/** 35/**
31 * Create pair of mutually connected TCP/IP sockets on loopback address 36 * Create pair of mutually connected TCP/IP sockets on loopback address
@@ -106,3 +111,31 @@ int MHD_W32_pair_of_sockets_(SOCKET sockets_pair[2])
106} 111}
107 112
108#endif /* _WIN32 && ! __CYGWIN__ */ 113#endif /* _WIN32 && ! __CYGWIN__ */
114
115#ifndef MHD_DONT_USE_PIPES
116#if !defined(_WIN32) || defined(__CYGWIN__)
117
118
119/**
120 * Change itc FD options to be non-blocking.
121 *
122 * @param fd the FD to manipulate
123 * @return non-zero if succeeded, zero otherwise
124 */
125int
126MHD_itc_nonblocking_ (MHD_pipe fd)
127{
128 int flags;
129
130 flags = fcntl (fd, F_GETFL);
131 if (-1 == flags)
132 return 0;
133
134 if ( ((flags | O_NONBLOCK) != flags) &&
135 (0 != fcntl (fd, F_SETFL, flags | O_NONBLOCK)) )
136 return 0;
137
138 return !0;
139}
140#endif /* _WIN32 && ! __CYGWIN__ */
141#endif /* ! MHD_DONT_USE_PIPES */