1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-12 04:25:08 -05:00

lib: drop USE_SOCKETPAIR in favor of CURL_DISABLE_SOCKETPAIR

.. since the former is undocumented and they both do the same thing.

Closes https://github.com/curl/curl/pull/6517
This commit is contained in:
Jay Satiro 2021-01-25 01:27:13 -05:00
parent b48db908e0
commit b9f11ae875
3 changed files with 11 additions and 15 deletions

View File

@ -163,7 +163,7 @@ struct thread_sync_data {
int port; int port;
char *hostname; /* hostname to resolve, Curl_async.hostname char *hostname; /* hostname to resolve, Curl_async.hostname
duplicate */ duplicate */
#ifdef USE_SOCKETPAIR #ifndef CURL_DISABLE_SOCKETPAIR
struct Curl_easy *data; struct Curl_easy *data;
curl_socket_t sock_pair[2]; /* socket pair */ curl_socket_t sock_pair[2]; /* socket pair */
#endif #endif
@ -201,7 +201,7 @@ void destroy_thread_sync_data(struct thread_sync_data *tsd)
if(tsd->res) if(tsd->res)
Curl_freeaddrinfo(tsd->res); Curl_freeaddrinfo(tsd->res);
#ifdef USE_SOCKETPAIR #ifndef CURL_DISABLE_SOCKETPAIR
/* /*
* close one end of the socket pair (may be done in resolver thread); * close one end of the socket pair (may be done in resolver thread);
* the other end (for reading) is always closed in the parent thread. * the other end (for reading) is always closed in the parent thread.
@ -243,7 +243,7 @@ int init_thread_sync_data(struct thread_data *td,
Curl_mutex_init(tsd->mtx); Curl_mutex_init(tsd->mtx);
#ifdef USE_SOCKETPAIR #ifndef CURL_DISABLE_SOCKETPAIR
/* create socket pair, avoid AF_LOCAL since it doesn't build on Solaris */ /* create socket pair, avoid AF_LOCAL since it doesn't build on Solaris */
if(Curl_socketpair(AF_UNIX, SOCK_STREAM, 0, &tsd->sock_pair[0]) < 0) { if(Curl_socketpair(AF_UNIX, SOCK_STREAM, 0, &tsd->sock_pair[0]) < 0) {
tsd->sock_pair[0] = CURL_SOCKET_BAD; tsd->sock_pair[0] = CURL_SOCKET_BAD;
@ -297,7 +297,7 @@ static unsigned int CURL_STDCALL getaddrinfo_thread(void *arg)
struct thread_data *td = tsd->td; struct thread_data *td = tsd->td;
char service[12]; char service[12];
int rc; int rc;
#ifdef USE_SOCKETPAIR #ifndef CURL_DISABLE_SOCKETPAIR
char buf[1]; char buf[1];
#endif #endif
@ -322,7 +322,7 @@ static unsigned int CURL_STDCALL getaddrinfo_thread(void *arg)
free(td); free(td);
} }
else { else {
#ifdef USE_SOCKETPAIR #ifndef CURL_DISABLE_SOCKETPAIR
if(tsd->sock_pair[1] != CURL_SOCKET_BAD) { if(tsd->sock_pair[1] != CURL_SOCKET_BAD) {
/* DNS has been resolved, signal client task */ /* DNS has been resolved, signal client task */
buf[0] = 1; buf[0] = 1;
@ -382,7 +382,7 @@ static void destroy_async_data(struct Curl_async *async)
if(async->tdata) { if(async->tdata) {
struct thread_data *td = async->tdata; struct thread_data *td = async->tdata;
int done; int done;
#ifdef USE_SOCKETPAIR #ifndef CURL_DISABLE_SOCKETPAIR
curl_socket_t sock_rd = td->tsd.sock_pair[0]; curl_socket_t sock_rd = td->tsd.sock_pair[0];
struct Curl_easy *data = td->tsd.data; struct Curl_easy *data = td->tsd.data;
#endif #endif
@ -407,7 +407,7 @@ static void destroy_async_data(struct Curl_async *async)
free(async->tdata); free(async->tdata);
} }
#ifdef USE_SOCKETPAIR #ifndef CURL_DISABLE_SOCKETPAIR
/* /*
* ensure CURLMOPT_SOCKETFUNCTION fires CURL_POLL_REMOVE * ensure CURLMOPT_SOCKETFUNCTION fires CURL_POLL_REMOVE
* before the FD is invalidated to avoid EBADF on EPOLL_CTL_DEL * before the FD is invalidated to avoid EBADF on EPOLL_CTL_DEL
@ -654,13 +654,13 @@ int Curl_resolver_getsock(struct Curl_easy *data, curl_socket_t *socks)
timediff_t milli; timediff_t milli;
timediff_t ms; timediff_t ms;
struct resdata *reslv = (struct resdata *)data->state.async.resolver; struct resdata *reslv = (struct resdata *)data->state.async.resolver;
#ifdef USE_SOCKETPAIR #ifndef CURL_DISABLE_SOCKETPAIR
struct thread_data *td = data->state.async.tdata; struct thread_data *td = data->state.async.tdata;
#else #else
(void)socks; (void)socks;
#endif #endif
#ifdef USE_SOCKETPAIR #ifndef CURL_DISABLE_SOCKETPAIR
if(td) { if(td) {
/* return read fd to client for polling the DNS resolution status */ /* return read fd to client for polling the DNS resolution status */
socks[0] = td->tsd.sock_pair[0]; socks[0] = td->tsd.sock_pair[0];
@ -679,7 +679,7 @@ int Curl_resolver_getsock(struct Curl_easy *data, curl_socket_t *socks)
else else
milli = 200; milli = 200;
Curl_expire(data, milli, EXPIRE_ASYNC_NAME); Curl_expire(data, milli, EXPIRE_ASYNC_NAME);
#ifdef USE_SOCKETPAIR #ifndef CURL_DISABLE_SOCKETPAIR
} }
#endif #endif

View File

@ -71,8 +71,7 @@ typedef enum {
#define CURLPIPE_ANY (CURLPIPE_MULTIPLEX) #define CURLPIPE_ANY (CURLPIPE_MULTIPLEX)
#if defined(USE_SOCKETPAIR) && !defined(USE_BLOCKING_SOCKETS) && \ #if !defined(CURL_DISABLE_SOCKETPAIR) && !defined(USE_BLOCKING_SOCKETS)
!defined(CURL_DISABLE_SOCKETPAIR)
#define ENABLE_WAKEUP #define ENABLE_WAKEUP
#endif #endif

View File

@ -30,7 +30,4 @@ int Curl_socketpair(int domain, int type, int protocol,
#define Curl_socketpair(a,b,c,d) socketpair(a,b,c,d) #define Curl_socketpair(a,b,c,d) socketpair(a,b,c,d)
#endif #endif
/* Defined here to allow specific build configs to disable it completely */
#define USE_SOCKETPAIR 1
#endif /* HEADER_CURL_SOCKETPAIR_H */ #endif /* HEADER_CURL_SOCKETPAIR_H */