From: Lukasz Czarnik -X (lczarnik - SOFTSERVE INC at Cisco) Date: Tue, 26 Mar 2024 18:55:14 +0000 (+0000) Subject: Pull request #4253: appid: remove locks from peg counts X-Git-Tag: 3.1.84.0~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=edad74b5ab8988d0b60d6e984eef45731275bdfc;p=thirdparty%2Fsnort3.git Pull request #4253: appid: remove locks from peg counts Merge in SNORT/snort3 from ~LCZARNIK/snort3:remove_locks to master Squashed commit of the following: commit 4d73601f9df627b208115605398b400d8218b1b9 Author: Lukasz Czarnik Date: Thu Mar 21 09:01:14 2024 -0400 appid: remove locks from peg counts --- diff --git a/src/network_inspectors/appid/appid_peg_counts.cc b/src/network_inspectors/appid/appid_peg_counts.cc index 9234ee196..92bab107f 100644 --- a/src/network_inspectors/appid/appid_peg_counts.cc +++ b/src/network_inspectors/appid/appid_peg_counts.cc @@ -108,12 +108,10 @@ static AppIdDynamicPeg appid_dynamic_sum[SF_APPID_MAX + 1]; static AppIdDynamicPeg zeroed_peg; static std::mutex dynamic_stats_mutex; -static std::shared_mutex appid_peg_ids_mutex; void AppIdPegCounts::init_pegs() { assert(!appid_thread_pegs); - const std::shared_lock _lock(appid_peg_ids_mutex); appid_thread_pegs = new AppIdThreadPegs(appid_peg_ids); for (auto& appid : *appid_thread_pegs->peg_ids) @@ -122,20 +120,17 @@ void AppIdPegCounts::init_pegs() void AppIdPegCounts::cleanup_pegs() { - const std::shared_lock _lock(appid_peg_ids_mutex); delete appid_thread_pegs; appid_thread_pegs = nullptr; } void AppIdPegCounts::init_peg_info() { - const std::unique_lock _lock(appid_peg_ids_mutex); appid_peg_ids = std::make_shared(); } void AppIdPegCounts::cleanup_peg_info() { - const std::unique_lock _lock(appid_peg_ids_mutex); appid_peg_ids.reset(); } @@ -162,7 +157,6 @@ void AppIdPegCounts::add_app_peg_info(std::string app_name, AppId app_id) std::replace(app_name.begin(), app_name.end(), ' ', '_'); assert(appid_peg_ids); - const std::unique_lock _lock(appid_peg_ids_mutex); appid_peg_ids->emplace(app_id, std::make_pair(app_name, appid_peg_ids->size())); } @@ -171,7 +165,6 @@ void AppIdPegCounts::sum_stats() if (!appid_thread_pegs) return; - const std::shared_lock _ids_lock(appid_peg_ids_mutex); const std::lock_guard _lock(dynamic_stats_mutex); for (auto& peg : appid_thread_pegs->peg_counts)