From: Yehor Velykozhon -X (yvelykoz - SOFTSERVE INC at Cisco) Date: Mon, 26 Feb 2024 13:43:04 +0000 (+0000) Subject: Pull request #4185: main: make "reset_stats" command ignore SnortModule peg counters X-Git-Tag: 3.1.82.0~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dcb5a6b4440cdec27b11f490f55ff041ab524f59;p=thirdparty%2Fsnort3.git Pull request #4185: main: make "reset_stats" command ignore SnortModule peg counters Merge in SNORT/snort3 from ~YVELYKOZ/snort3:global_counters to master Squashed commit of the following: commit 650effed988e6f87f2d7d5c19c6fc9e7f13ee3a8 Author: Yehor Velykozhon Date: Tue Jan 30 16:05:15 2024 +0200 main: reset main-thread stats from the main thread --- diff --git a/src/main/analyzer_command.cc b/src/main/analyzer_command.cc index 0c594b39d..8e5dc8023 100644 --- a/src/main/analyzer_command.cc +++ b/src/main/analyzer_command.cc @@ -139,8 +139,14 @@ ACResetStats::ACResetStats(clear_counter_type_t requested_type_l) : requested_ty ACResetStats::~ACResetStats() { + // Destructor is called only from main thread, + // main-thread stats are reset here. + if (requested_type == TYPE_MODULE or requested_type == TYPE_ALL) ModuleManager::reset_module_stats("memory"); + + if (requested_type == TYPE_SNORT or requested_type == TYPE_ALL) + ModuleManager::reset_module_stats("snort"); } bool ACSwap::execute(Analyzer& analyzer, void** ac_state) diff --git a/src/main/snort_module.cc b/src/main/snort_module.cc index 54c189b82..3c7069d28 100644 --- a/src/main/snort_module.cc +++ b/src/main/snort_module.cc @@ -690,6 +690,12 @@ public: void sum_stats(bool) override { } // accumulate externally + void reset_stats() override + { + if (snort::in_main_thread()) + Module::reset_stats(); + } + ProfileStats* get_profile(unsigned, const char*&, const char*&) const override; Usage get_usage() const override