]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Pull request #3854: Handle return code from daq
authorOleksii Shumeiko -X (oshumeik - SOFTSERVE INC at Cisco) <oshumeik@cisco.com>
Mon, 29 May 2023 11:03:02 +0000 (11:03 +0000)
committerOleksii Shumeiko -X (oshumeik - SOFTSERVE INC at Cisco) <oshumeik@cisco.com>
Mon, 29 May 2023 11:03:02 +0000 (11:03 +0000)
Merge in SNORT/snort3 from ~YVELYKOZ/snort3:return_error_daq_handling to master

Squashed commit of the following:

commit 48dbb1120a85078f6eaefbf4ee824d08f684d619
Author: Yehor Velykozhon <yvelykoz@cisco.com>
Date:   Wed May 17 15:32:47 2023 +0300

    main: add Pig destructor to free dynamic memory

commit 07073ca724c9f6dea8d7d352b3503b157b530c25
Author: Yehor Velykozhon <yvelykoz@cisco.com>
Date:   Fri May 5 16:00:32 2023 +0300

    main: handling the return code in case of error in creation of daq instance

src/main.cc

index 22345410b50d6506ce887d8d7ed88648c615d655..850732bdeb0f2bd1aa924bae69396e198d5d021a 100644 (file)
@@ -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.