Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -724,9 +724,9 @@ if(APPLE)
if(NOT CURL_USE_OPENSSL AND NOT CURL_USE_GNUTLS)
message(FATAL_ERROR "Apple SecTrust is only supported with Openssl/GnuTLS")
endif()
find_library(COREFOUNDATION_FRAMEWORK NAMES "Security")
mark_as_advanced(COREFOUNDATION_FRAMEWORK)
if(NOT COREFOUNDATION_FRAMEWORK)
find_library(SECURITY_FRAMEWORK NAMES "Security")
mark_as_advanced(SECURITY_FRAMEWORK)
if(NOT SECURITY_FRAMEWORK)
message(FATAL_ERROR "Security framework not found")
endif()
list(APPEND CURL_LIBS "-framework Security")
Expand Down
1 change: 0 additions & 1 deletion REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ SPDX-PackageDownloadLocation = "https://curl.se/"
path = [
"docs/INSTALL",
"docs/libcurl/symbols-in-versions",
"docs/MAIL-ETIQUETTE",
"docs/options-in-versions",
"docs/THANKS",
"lib/libcurl.vers.in",
Expand Down
8 changes: 8 additions & 0 deletions docs/INSTALL-CMAKE.md
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,14 @@ Examples:
which directory (typically) contains `include` and `lib` subdirectories.
No ending slash or backslash is necessary.

## Dependency options (Apple frameworks)

- `COREFOUNDATION_FRAMEWORK`: Absolute path to `CoreFoundation` framework. (for IPv6 non-c-ares, SecTrust, wolfSSL)
- `CORESERVICES_FRAMEWORK`: Absolute path to `CoreServices` framework. (for IPv6 non-c-ares, SecTrust)
- `FOUNDATION_FRAMEWORK`: Absolute path to `Foundation` framework. (for Rustls)
- `SECURITY_FRAMEWORK`: Absolute path to `Security` framework. (for Rustls, SecTrust, wolfSSL)
- `SYSTEMCONFIGURATION_FRAMEWORK`: Absolute path to `SystemConfiguration` framework. (for IPv6 non-c-ares)

## Test tools

- `APXS`: Default: `apxs`
Expand Down
9 changes: 5 additions & 4 deletions lib/conncache.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,22 +235,23 @@ void Curl_cpool_destroy(struct cpool *cpool)
{
if(cpool && cpool->initialised && cpool->idata) {
struct connectdata *conn;
SIGPIPE_VARIABLE(pipe_st);
struct Curl_sigpipe_ctx pipe_ctx;

CURL_TRC_M(cpool->idata, "%s[CPOOL] destroy, %zu connections",
cpool->share ? "[SHARE] " : "", cpool->num_conn);
/* Move all connections to the shutdown list */
sigpipe_init(&pipe_st);
sigpipe_init(&pipe_ctx);
CPOOL_LOCK(cpool, cpool->idata);
conn = cpool_get_first(cpool);
if(conn)
sigpipe_apply(cpool->idata, &pipe_ctx);
while(conn) {
cpool_remove_conn(cpool, conn);
sigpipe_apply(cpool->idata, &pipe_st);
cpool_discard_conn(cpool, cpool->idata, conn, FALSE);
conn = cpool_get_first(cpool);
}
CPOOL_UNLOCK(cpool, cpool->idata);
sigpipe_restore(&pipe_st);
sigpipe_restore(&pipe_ctx);
Curl_hash_destroy(&cpool->dest2bundle);
}
}
Expand Down
52 changes: 13 additions & 39 deletions lib/cshutdn.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,13 @@ static bool cshutdn_destroy_oldest(struct cshutdn *cshutdn,
}

if(e) {
SIGPIPE_VARIABLE(pipe_st);
struct Curl_sigpipe_ctx sigpipe_ctx;
conn = Curl_node_elem(e);
Curl_node_remove(e);
sigpipe_init(&pipe_st);
sigpipe_apply(data, &pipe_st);
sigpipe_init(&sigpipe_ctx);
sigpipe_apply(data, &sigpipe_ctx);
Curl_cshutdn_terminate(data, conn, FALSE);
sigpipe_restore(&pipe_st);
sigpipe_restore(&sigpipe_ctx);
return TRUE;
}
return FALSE;
Expand Down Expand Up @@ -222,7 +222,8 @@ static CURLcode cshutdn_wait(struct cshutdn *cshutdn,
}

static void cshutdn_perform(struct cshutdn *cshutdn,
struct Curl_easy *data)
struct Curl_easy *data,
struct Curl_sigpipe_ctx *sigpipe_ctx)
{
struct Curl_llist_node *e = Curl_llist_head(&cshutdn->list);
struct Curl_llist_node *enext;
Expand All @@ -235,6 +236,7 @@ static void cshutdn_perform(struct cshutdn *cshutdn,

CURL_TRC_M(data, "[SHUTDOWN] perform on %zu connections",
Curl_llist_count(&cshutdn->list));
sigpipe_apply(data, sigpipe_ctx);
while(e) {
enext = Curl_node_next(e);
conn = Curl_node_elem(e);
Expand Down Expand Up @@ -263,20 +265,19 @@ static void cshutdn_terminate_all(struct cshutdn *cshutdn,
{
struct curltime started = *Curl_pgrs_now(data);
struct Curl_llist_node *e;
SIGPIPE_VARIABLE(pipe_st);
struct Curl_sigpipe_ctx sigpipe_ctx;

DEBUGASSERT(cshutdn);
DEBUGASSERT(data);

CURL_TRC_M(data, "[SHUTDOWN] shutdown all");
sigpipe_init(&pipe_st);
sigpipe_apply(data, &pipe_st);
sigpipe_init(&sigpipe_ctx);

while(Curl_llist_head(&cshutdn->list)) {
timediff_t spent_ms;
int remain_ms;

cshutdn_perform(cshutdn, data);
cshutdn_perform(cshutdn, data, &sigpipe_ctx);

if(!Curl_llist_head(&cshutdn->list)) {
CURL_TRC_M(data, "[SHUTDOWN] shutdown finished cleanly");
Expand Down Expand Up @@ -308,7 +309,7 @@ static void cshutdn_terminate_all(struct cshutdn *cshutdn,
}
DEBUGASSERT(!Curl_llist_count(&cshutdn->list));

sigpipe_restore(&pipe_st);
sigpipe_restore(&sigpipe_ctx);
}

int Curl_cshutdn_init(struct cshutdn *cshutdn,
Expand Down Expand Up @@ -418,38 +419,11 @@ void Curl_cshutdn_add(struct cshutdn *cshutdn,
conn->connection_id, Curl_llist_count(&cshutdn->list));
}

static void cshutdn_multi_socket(struct cshutdn *cshutdn,
struct Curl_easy *data,
curl_socket_t s)
{
struct Curl_llist_node *e;
struct connectdata *conn;
bool done;

DEBUGASSERT(cshutdn->multi->socket_cb);
e = Curl_llist_head(&cshutdn->list);
while(e) {
conn = Curl_node_elem(e);
if(s == conn->sock[FIRSTSOCKET] || s == conn->sock[SECONDARYSOCKET]) {
Curl_cshutdn_run_once(data, conn, &done);
if(done || cshutdn_update_ev(cshutdn, data, conn)) {
Curl_node_remove(e);
Curl_cshutdn_terminate(data, conn, FALSE);
}
break;
}
e = Curl_node_next(e);
}
}

void Curl_cshutdn_perform(struct cshutdn *cshutdn,
struct Curl_easy *data,
curl_socket_t s)
struct Curl_sigpipe_ctx *sigpipe_ctx)
{
if((s == CURL_SOCKET_TIMEOUT) || (!cshutdn->multi->socket_cb))
cshutdn_perform(cshutdn, data);
else
cshutdn_multi_socket(cshutdn, data, s);
cshutdn_perform(cshutdn, data, sigpipe_ctx);
}

/* return fd_set info about the shutdown connections */
Expand Down
6 changes: 3 additions & 3 deletions lib/cshutdn.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct curl_pollfds;
struct Curl_waitfds;
struct Curl_multi;
struct Curl_share;
struct Curl_sigpipe_ctx;

/* Run the shutdown of the connection once.
* Will shortly attach/detach `data` to `conn` while doing so.
Expand Down Expand Up @@ -97,10 +98,9 @@ void Curl_cshutdn_setfds(struct cshutdn *cshutdn,
fd_set *read_fd_set, fd_set *write_fd_set,
int *maxfd);

/* Run shut down connections using socket. If socket is CURL_SOCKET_TIMEOUT,
* run maintenance on all connections. */
/* Run maintenance on all connections. */
void Curl_cshutdn_perform(struct cshutdn *cshutdn,
struct Curl_easy *data,
curl_socket_t s);
struct Curl_sigpipe_ctx *sigpipe_ctx);

#endif /* HEADER_CURL_CSHUTDN_H */
20 changes: 10 additions & 10 deletions lib/easy.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ static CURLcode easy_perform(struct Curl_easy *data, bool events)
struct Curl_multi *multi;
CURLMcode mresult;
CURLcode result = CURLE_OK;
SIGPIPE_VARIABLE(pipe_st);
struct Curl_sigpipe_ctx sigpipe_ctx;

if(!data)
return CURLE_BAD_FUNCTION_ARGUMENT;
Expand Down Expand Up @@ -807,8 +807,8 @@ static CURLcode easy_perform(struct Curl_easy *data, bool events)
/* assign this after curl_multi_add_handle() */
data->multi_easy = multi;

sigpipe_init(&pipe_st);
sigpipe_apply(data, &pipe_st);
sigpipe_init(&sigpipe_ctx);
sigpipe_apply(data, &sigpipe_ctx);

/* run the transfer */
result = events ? easy_events(multi) : easy_transfer(multi);
Expand All @@ -817,7 +817,7 @@ static CURLcode easy_perform(struct Curl_easy *data, bool events)
a failure here, room for future improvement! */
(void)curl_multi_remove_handle(multi, data);

sigpipe_restore(&pipe_st);
sigpipe_restore(&sigpipe_ctx);

/* The multi handle is kept alive, owned by the easy handle */
return result;
Expand Down Expand Up @@ -851,10 +851,10 @@ void curl_easy_cleanup(CURL *ptr)
{
struct Curl_easy *data = ptr;
if(GOOD_EASY_HANDLE(data)) {
SIGPIPE_VARIABLE(pipe_st);
sigpipe_ignore(data, &pipe_st);
struct Curl_sigpipe_ctx sigpipe_ctx;
sigpipe_ignore(data, &sigpipe_ctx);
Curl_close(&data);
sigpipe_restore(&pipe_st);
sigpipe_restore(&sigpipe_ctx);
}
}

Expand Down Expand Up @@ -1287,7 +1287,7 @@ CURLcode Curl_senddata(struct Curl_easy *data, const void *buffer,
{
CURLcode result;
struct connectdata *c = NULL;
SIGPIPE_VARIABLE(pipe_st);
struct Curl_sigpipe_ctx sigpipe_ctx;

*n = 0;
result = easy_connection(data, &c);
Expand All @@ -1299,9 +1299,9 @@ CURLcode Curl_senddata(struct Curl_easy *data, const void *buffer,
needs to be reattached */
Curl_attach_connection(data, c);

sigpipe_ignore(data, &pipe_st);
sigpipe_ignore(data, &sigpipe_ctx);
result = Curl_conn_send(data, FIRSTSOCKET, buffer, buflen, FALSE, n);
sigpipe_restore(&pipe_st);
sigpipe_restore(&sigpipe_ctx);

if(result && result != CURLE_AGAIN)
return CURLE_SEND_ERROR;
Expand Down
Loading