Files
scylladb/utils/http.cc
Calle Wilund 4a98c258f6 http: Add missing thread_local specifier for static
Refs #24447

Patch adding this somehow managed to leave out the thread_local
specifier. While gnutls cert object can be shared across shards
just fine, the actual shared_ptr here cannot, thus we could
cause memory errors.

Closes scylladb/scylladb#24514
2025-06-17 10:23:52 +03:00

21 lines
656 B
C++

/*
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
*/
/*
* Copyright (C) 2025-present ScyllaDB
*/
#include "http.hh"
future<shared_ptr<tls::certificate_credentials>> utils::http::dns_connection_factory::system_trust_credentials() {
static thread_local shared_ptr<tls::certificate_credentials> system_trust_credentials;
if (!system_trust_credentials) {
// can race, and overwrite the object. that is fine.
auto cred = make_shared<tls::certificate_credentials>();
co_await cred->set_system_trust();
system_trust_credentials = std::move(cred);
}
co_return system_trust_credentials;
}