From: Oleksii Shumeiko -X (oshumeik - SOFTSERVE INC at Cisco) Date: Mon, 29 May 2023 11:03:02 +0000 (+0000) Subject: Pull request #3854: Handle return code from daq X-Git-Tag: 3.1.63.0~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=916dc62a925dff6efe9fbfd5a8057674e3fbc726;p=thirdparty%2Fsnort3.git Pull request #3854: Handle return code from daq Merge in SNORT/snort3 from ~YVELYKOZ/snort3:return_error_daq_handling to master Squashed commit of the following: commit 48dbb1120a85078f6eaefbf4ee824d08f684d619 Author: Yehor Velykozhon Date: Wed May 17 15:32:47 2023 +0300 main: add Pig destructor to free dynamic memory commit 07073ca724c9f6dea8d7d352b3503b157b530c25 Author: Yehor Velykozhon Date: Fri May 5 16:00:32 2023 +0300 main: handling the return code in case of error in creation of daq instance --- diff --git a/src/main.cc b/src/main.cc index 22345410b..850732bde 100644 --- a/src/main.cc +++ b/src/main.cc @@ -116,6 +116,7 @@ class Pig { public: Pig() = default; + ~Pig(); void set_index(unsigned index) { idx = index; } @@ -144,6 +145,13 @@ private: unsigned idx = (unsigned)-1; }; +Pig::~Pig() +{ + delete analyzer; + delete swapper; + delete athread; +} + bool Pig::prep(const char* source) { const SnortConfig* sc = SnortConfig::get_conf(); @@ -1035,9 +1043,11 @@ static void main_loop() { for (unsigned i = 0; i < max_pigs; i++) { - if (pigs[i].prep(SFDAQ::get_input_spec(SnortConfig::get_conf()->daq_config, i))) - swine++; + if (!pigs[i].prep(SFDAQ::get_input_spec(SnortConfig::get_conf()->daq_config, i))) + return; } + + swine += max_pigs; } // Iterate over the drove, spawn them as allowed, and handle their deaths.