mirror of
https://github.com/curl/curl.git
synced 2026-04-14 22:31:41 +03:00
socketpair: cleaner interface
Declutter the ifdefs in socketpair.h. Introduce Curl_wakeup_*() function that encapsulate the details about how the socketpair is implemented. This moves the EVENTFD specials from the using code into socketpair implemenatation, avoiding duplications in three places. Closes #20340
This commit is contained in:
parent
1a57302d1a
commit
6c8956c1cb
4 changed files with 144 additions and 138 deletions
|
|
@ -133,12 +133,7 @@ static void addr_ctx_unlink(struct async_thrdd_addr_ctx **paddr_ctx,
|
|||
curlx_free(addr_ctx->hostname);
|
||||
if(addr_ctx->res)
|
||||
Curl_freeaddrinfo(addr_ctx->res);
|
||||
#ifndef CURL_DISABLE_SOCKETPAIR
|
||||
#ifndef USE_EVENTFD
|
||||
wakeup_close(addr_ctx->sock_pair[1]);
|
||||
#endif
|
||||
wakeup_close(addr_ctx->sock_pair[0]);
|
||||
#endif
|
||||
Curl_wakeup_destroy(addr_ctx->sock_pair);
|
||||
curlx_free(addr_ctx);
|
||||
}
|
||||
*paddr_ctx = NULL;
|
||||
|
|
@ -169,7 +164,7 @@ addr_ctx_create(struct Curl_easy *data,
|
|||
|
||||
#ifndef CURL_DISABLE_SOCKETPAIR
|
||||
/* create socket pair or pipe */
|
||||
if(wakeup_create(addr_ctx->sock_pair, FALSE) < 0) {
|
||||
if(Curl_wakeup_init(addr_ctx->sock_pair, FALSE) < 0) {
|
||||
addr_ctx->sock_pair[0] = CURL_SOCKET_BAD;
|
||||
addr_ctx->sock_pair[1] = CURL_SOCKET_BAD;
|
||||
goto err_exit;
|
||||
|
|
@ -231,15 +226,11 @@ static CURL_THREAD_RETURN_T CURL_STDCALL getaddrinfo_thread(void *arg)
|
|||
Curl_mutex_release(&addr_ctx->mutx);
|
||||
#ifndef CURL_DISABLE_SOCKETPAIR
|
||||
if(!do_abort) {
|
||||
#ifdef USE_EVENTFD
|
||||
const uint64_t buf[1] = { 1 };
|
||||
#else
|
||||
const char buf[1] = { 1 };
|
||||
#endif
|
||||
/* Thread is done, notify transfer */
|
||||
if(wakeup_write(addr_ctx->sock_pair[1], buf, sizeof(buf)) < 0) {
|
||||
int err = Curl_wakeup_signal(addr_ctx->sock_pair);
|
||||
if(err) {
|
||||
/* update sock_error to errno */
|
||||
addr_ctx->sock_error = SOCKERRNO;
|
||||
addr_ctx->sock_error = err;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -276,15 +267,10 @@ static CURL_THREAD_RETURN_T CURL_STDCALL gethostbyname_thread(void *arg)
|
|||
Curl_mutex_release(&addr_ctx->mutx);
|
||||
#ifndef CURL_DISABLE_SOCKETPAIR
|
||||
if(!do_abort) {
|
||||
#ifdef USE_EVENTFD
|
||||
const uint64_t buf[1] = { 1 };
|
||||
#else
|
||||
const char buf[1] = { 1 };
|
||||
#endif
|
||||
/* Thread is done, notify transfer */
|
||||
if(wakeup_write(addr_ctx->sock_pair[1], buf, sizeof(buf)) < 0) {
|
||||
int err = Curl_wakeup_signal(addr_ctx->sock_pair);
|
||||
if(err) {
|
||||
/* update sock_error to errno */
|
||||
addr_ctx->sock_error = SOCKERRNO;
|
||||
addr_ctx->sock_error = err;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue