diff --git a/libtransmission/web.cc b/libtransmission/web.cc index dd5cae1fc..5164b411c 100644 --- a/libtransmission/web.cc +++ b/libtransmission/web.cc @@ -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;