File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,10 +32,17 @@ namespace {
3232constexpr unsigned int kMinimumLibcurlVersionForEcCurves =
3333 (7U << 16 ) | (73U << 8 ) | 0U ;
3434
35+ // `curl_version_info()` is not thread-safe as libcurl constructs version
36+ // string details in internal static buffers without locks. Using a block-scope
37+ // static ensures thread-safe initialization exactly once via C++11 magic
38+ // statics, preventing data races when multiple threads create REST clients.
3539bool SupportsSslEcCurves () {
36- auto * vinfo = curl_version_info (CURLVERSION_NOW );
37- return vinfo != nullptr &&
38- vinfo->version_num >= kMinimumLibcurlVersionForEcCurves ;
40+ static bool const kSupports = [] {
41+ auto * vinfo = curl_version_info (CURLVERSION_NOW );
42+ return vinfo != nullptr &&
43+ vinfo->version_num >= kMinimumLibcurlVersionForEcCurves ;
44+ }();
45+ return kSupports ;
3946}
4047
4148} // namespace
You can’t perform that action at this time.
0 commit comments