fix
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
BlockStorage/repertory/pipeline/pr-master This commit looks good

This commit is contained in:
2025-07-23 12:26:40 -05:00
parent b3d1ed789b
commit 7eff93efaf
2 changed files with 3 additions and 7 deletions

View File

@@ -46,7 +46,6 @@ public:
private:
static curl_sh_t cache_;
static std::unique_ptr<unique_recur_mutex_lock> lock_;
static std::recursive_mutex mtx_;
private:

View File

@@ -24,23 +24,20 @@
namespace repertory {
dns_cache::curl_sh_t dns_cache::cache_;
std::unique_ptr<unique_recur_mutex_lock> dns_cache::lock_;
std::recursive_mutex dns_cache::mtx_;
void dns_cache::cleanup() { cache_.reset(nullptr); }
void dns_cache::init() {
lock_ = std::make_unique<unique_recur_mutex_lock>(mtx_);
auto *cache = curl_share_init();
if (cache == nullptr) {
return;
}
cache_.reset(cache);
curl_share_setopt(cache, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
curl_share_setopt(cache, CURLSHOPT_LOCKFUNC, lock_callback);
curl_share_setopt(cache, CURLSHOPT_UNLOCKFUNC, unlock_callback);
cache_.reset(cache);
}
void dns_cache::lock_callback(CURL * /* curl */, curl_lock_data data,
@@ -49,7 +46,7 @@ void dns_cache::lock_callback(CURL * /* curl */, curl_lock_data data,
return;
}
lock_->lock();
mtx_.lock();
}
void dns_cache::set_cache(CURL *curl) {
@@ -63,6 +60,6 @@ void dns_cache::unlock_callback(CURL * /* curl */, curl_lock_data data,
return;
}
lock_->unlock();
mtx_.unlock();
}
} // namespace repertory