diff options
Diffstat (limited to 'libs/libcurl/src/socketpair.c')
-rw-r--r-- | libs/libcurl/src/socketpair.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/libs/libcurl/src/socketpair.c b/libs/libcurl/src/socketpair.c index a7cf171a97..b194831312 100644 --- a/libs/libcurl/src/socketpair.c +++ b/libs/libcurl/src/socketpair.c @@ -27,10 +27,9 @@ #include "urldata.h"
#include "rand.h"
-#ifdef HAVE_EVENTFD
-#ifdef HAVE_SYS_EVENTFD_H
+#ifdef USE_EVENTFD
+
#include <sys/eventfd.h>
-#endif
int Curl_eventfd(curl_socket_t socks[2], bool nonblocking)
{
@@ -42,13 +41,20 @@ int Curl_eventfd(curl_socket_t socks[2], bool nonblocking) socks[0] = socks[1] = efd;
return 0;
}
+
#elif defined(HAVE_PIPE)
+
#ifdef HAVE_FCNTL
#include <fcntl.h>
#endif
int Curl_pipe(curl_socket_t socks[2], bool nonblocking)
{
+#ifdef HAVE_PIPE2
+ int flags = nonblocking ? O_NONBLOCK | O_CLOEXEC : O_CLOEXEC;
+ if(pipe2(socks, flags))
+ return -1;
+#else
if(pipe(socks))
return -1;
#ifdef HAVE_FCNTL
@@ -69,11 +75,12 @@ int Curl_pipe(curl_socket_t socks[2], bool nonblocking) return -1;
}
}
+#endif
return 0;
}
-#endif
+#endif /* USE_EVENTFD */
#ifndef CURL_DISABLE_SOCKETPAIR
#ifdef HAVE_SOCKETPAIR
@@ -121,8 +128,8 @@ int Curl_socketpair(int domain, int type, int protocol, #endif /* !INADDR_LOOPBACK */
#endif /* !_WIN32 */
-#include "nonblock.h" /* for curlx_nonblock */
-#include "timeval.h" /* needed before select.h */
+#include "curlx/nonblock.h" /* for curlx_nonblock */
+#include "curlx/timeval.h" /* needed before select.h */
#include "select.h" /* for Curl_poll */
/* The last 3 #include files should be in this order */
@@ -196,7 +203,7 @@ int Curl_socketpair(int domain, int type, int protocol, if(socks[1] == CURL_SOCKET_BAD)
goto error;
else {
- struct curltime start = Curl_now();
+ struct curltime start = curlx_now();
char rnd[9];
char check[sizeof(rnd)];
char *p = &check[0];
@@ -220,7 +227,7 @@ int Curl_socketpair(int domain, int type, int protocol, if(nread == -1) {
int sockerr = SOCKERRNO;
/* Do not block forever */
- if(Curl_timediff(Curl_now(), start) > (60 * 1000))
+ if(curlx_timediff(curlx_now(), start) > (60 * 1000))
goto error;
if(
#ifdef USE_WINSOCK
|