diff options
| author | thegeorg <[email protected]> | 2024-10-11 21:07:18 +0300 |
|---|---|---|
| committer | thegeorg <[email protected]> | 2024-10-11 21:17:24 +0300 |
| commit | 1df197e6035ea9826bfedee7d48812e318ba9c7a (patch) | |
| tree | 76b8e9de41820755adf209854d06a84a8b5a1988 /contrib/libs/curl/lib/socketpair.c | |
| parent | f9c007ea1b59b960201def74990810b26ecdfd48 (diff) | |
Revert "Update contrib/libs/curl to 8.10.1" to fix
Revert "Update contrib/libs/curl to 8.10.1"
This reverts commit 428ef806a15515cdaa325530aa8cc6903fac5fb6, reversing
changes made to 40e46e6394df409d1545a3771c8a47a86ed55eac.
Revert "Fix formatting after rXXXXXX"
This reverts commit a73689311a92e195d14136c5a0049ef1e40b1f3e, reversing
changes made to 17980b8756d1f74d3dacddc7ca4945c30f35611c.
commit_hash:5c5194831e5455b61fbee61619066396626beab1
Diffstat (limited to 'contrib/libs/curl/lib/socketpair.c')
| -rw-r--r-- | contrib/libs/curl/lib/socketpair.c | 91 |
1 files changed, 10 insertions, 81 deletions
diff --git a/contrib/libs/curl/lib/socketpair.c b/contrib/libs/curl/lib/socketpair.c index b14f5a5f145..e3d40ff94eb 100644 --- a/contrib/libs/curl/lib/socketpair.c +++ b/contrib/libs/curl/lib/socketpair.c @@ -27,82 +27,15 @@ #include "urldata.h" #include "rand.h" -#if defined(USE_EVENTFD) -#ifdef HAVE_SYS_EVENTFD_H -#include <sys/eventfd.h> -#endif - -int Curl_eventfd(curl_socket_t socks[2], bool nonblocking) -{ - int efd = eventfd(0, nonblocking ? EFD_CLOEXEC | EFD_NONBLOCK : EFD_CLOEXEC); - if(efd == -1) { - socks[0] = socks[1] = CURL_SOCKET_BAD; - return -1; - } - 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) -{ - if(pipe(socks)) - return -1; -#ifdef HAVE_FCNTL - if(fcntl(socks[0], F_SETFD, FD_CLOEXEC) || - fcntl(socks[1], F_SETFD, FD_CLOEXEC) ) { - close(socks[0]); - close(socks[1]); - socks[0] = socks[1] = CURL_SOCKET_BAD; - return -1; - } -#endif - if(nonblocking) { - if(curlx_nonblock(socks[0], TRUE) < 0 || - curlx_nonblock(socks[1], TRUE) < 0) { - close(socks[0]); - close(socks[1]); - socks[0] = socks[1] = CURL_SOCKET_BAD; - return -1; - } - } - - return 0; -} -#endif - - -#ifndef CURL_DISABLE_SOCKETPAIR -#ifdef HAVE_SOCKETPAIR -int Curl_socketpair(int domain, int type, int protocol, - curl_socket_t socks[2], bool nonblocking) -{ -#ifdef SOCK_NONBLOCK - type = nonblocking ? type | SOCK_NONBLOCK : type; -#endif - if(socketpair(domain, type, protocol, socks)) - return -1; -#ifndef SOCK_NONBLOCK - if(nonblocking) { - if(curlx_nonblock(socks[0], TRUE) < 0 || - curlx_nonblock(socks[1], TRUE) < 0) { - close(socks[0]); - close(socks[1]); - return -1; - } - } -#endif - return 0; -} -#else /* !HAVE_SOCKETPAIR */ +#if !defined(HAVE_SOCKETPAIR) && !defined(CURL_DISABLE_SOCKETPAIR) #ifdef _WIN32 /* * This is a socketpair() implementation for Windows. */ #include <string.h> +#include <winsock2.h> +#include <ws2tcpip.h> +#include <windows.h> #include <io.h> #else #ifdef HAVE_NETDB_H @@ -129,7 +62,7 @@ int Curl_socketpair(int domain, int type, int protocol, #include "memdebug.h" int Curl_socketpair(int domain, int type, int protocol, - curl_socket_t socks[2], bool nonblocking) + curl_socket_t socks[2]) { union { struct sockaddr_in inaddr; @@ -155,7 +88,7 @@ int Curl_socketpair(int domain, int type, int protocol, socks[0] = socks[1] = CURL_SOCKET_BAD; #if defined(_WIN32) || defined(__CYGWIN__) - /* do not set SO_REUSEADDR on Windows */ + /* don't set SO_REUSEADDR on Windows */ (void)reuse; #ifdef SO_EXCLUSIVEADDRUSE { @@ -183,7 +116,7 @@ int Curl_socketpair(int domain, int type, int protocol, if(connect(socks[0], &a.addr, sizeof(a.inaddr)) == -1) goto error; - /* use non-blocking accept to make sure we do not block forever */ + /* use non-blocking accept to make sure we don't block forever */ if(curlx_nonblock(listener, TRUE) < 0) goto error; pfd[0].fd = listener; @@ -217,7 +150,7 @@ int Curl_socketpair(int domain, int type, int protocol, nread = sread(socks[1], p, s); if(nread == -1) { int sockerr = SOCKERRNO; - /* Do not block forever */ + /* Don't block forever */ if(Curl_timediff(Curl_now(), start) > (60 * 1000)) goto error; if( @@ -247,10 +180,6 @@ int Curl_socketpair(int domain, int type, int protocol, } while(1); } - if(nonblocking) - if(curlx_nonblock(socks[0], TRUE) < 0 || - curlx_nonblock(socks[1], TRUE) < 0) - goto error; sclose(listener); return 0; @@ -260,5 +189,5 @@ error: sclose(socks[1]); return -1; } -#endif -#endif /* !CURL_DISABLE_SOCKETPAIR */ + +#endif /* ! HAVE_SOCKETPAIR */ |
