]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #4253: appid: remove locks from peg counts
authorLukasz Czarnik -X (lczarnik - SOFTSERVE INC at Cisco) <lczarnik@cisco.com>
Tue, 26 Mar 2024 18:55:14 +0000 (18:55 +0000)
committerChris Sherwin (chsherwi) <chsherwi@cisco.com>
Tue, 26 Mar 2024 18:55:14 +0000 (18:55 +0000)
Merge in SNORT/snort3 from ~LCZARNIK/snort3:remove_locks to master

Squashed commit of the following:

commit 4d73601f9df627b208115605398b400d8218b1b9
Author: Lukasz Czarnik <lczarnik@cisco.com>
Date:   Thu Mar 21 09:01:14 2024 -0400

    appid: remove locks from peg counts

src/network_inspectors/appid/appid_peg_counts.cc

index 9234ee196407abea15a24d9d2502ff70abe48fff..92bab107f4d1cabfeb21e4214bba1a4dc5693e94 100644 (file)
@@ -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<std::shared_mutex> _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<std::shared_mutex> _lock(appid_peg_ids_mutex);
     delete appid_thread_pegs;
     appid_thread_pegs = nullptr;
 }
 
 void AppIdPegCounts::init_peg_info()
 {
-    const std::unique_lock<std::shared_mutex> _lock(appid_peg_ids_mutex);
     appid_peg_ids = std::make_shared<AppIdPegCountIdInfo>();
 }
 
 void AppIdPegCounts::cleanup_peg_info()
 {
-    const std::unique_lock<std::shared_mutex> _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<std::shared_mutex> _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<std::shared_mutex> _ids_lock(appid_peg_ids_mutex);
     const std::lock_guard<std::mutex> _lock(dynamic_stats_mutex);
 
     for (auto& peg : appid_thread_pegs->peg_counts)