1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-27 01:57:52 +00:00

perf: tell curl_share to share everything (#2802)

This commit is contained in:
Charles Kerr 2022-03-23 22:02:18 -05:00 committed by GitHub
parent 791f59e8ba
commit 6db3fbfe64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -116,6 +116,8 @@ public:
tr_free(bundle);
}
shareEverything();
if (curl_ssl_verify)
{
auto const* bundle = std::empty(curl_ca_bundle) ? "none" : curl_ca_bundle.c_str();
@ -535,6 +537,26 @@ private:
return curlsh_.get();
}
void shareEverything()
{
// Tell curl to share whatever it can.
// https://curl.se/libcurl/c/CURLSHOPT_SHARE.html
//
// The user's system probably has a different version of curl than
// we're compiling with; so instead of listing fields by name, just
// loop until curl says we've exhausted the list.
auto* const sh = shared();
for (long type = CURL_LOCK_DATA_COOKIE;; ++type)
{
if (curl_share_setopt(sh, CURLSHOPT_SHARE, type) != CURLSHE_OK)
{
tr_logAddDebug(fmt::format("CURLOPT_SHARE ended at {}", type));
return;
}
}
}
static std::once_flag curl_init_flag;
bool is_closed_ = false;