]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
dns: convert transaction list to vecdeque
authorJason Ish <jason.ish@oisf.net>
Tue, 26 Apr 2022 19:25:40 +0000 (13:25 -0600)
committerVictor Julien <vjulien@oisf.net>
Sat, 10 Jun 2023 08:01:06 +0000 (10:01 +0200)
Allows for more efficient removal from front of the list.

Ticket: #5277
(cherry picked from commit 31894147884af3e7151b4d653e5268a0b0477db8)

rust/src/dns/dns.rs

index 460c97def1e17b15e63f25a05485a818a9036a07..4b09cc2988125884fec7d03f6df27448b40a6127 100644 (file)
@@ -407,7 +407,7 @@ pub struct DNSState {
     pub tx_id: u64,
 
     // Transactions.
-    pub transactions: Vec<DNSTransaction>,
+    pub transactions: VecDeque<DNSTransaction>,
 
     config: Option<ConfigTracker>,
 
@@ -419,7 +419,7 @@ impl DNSState {
     pub fn new() -> DNSState {
         return DNSState{
             tx_id: 0,
-            transactions: Vec::new(),
+            transactions: VecDeque::new(),
             config: None,
             gap: false,
         };
@@ -428,7 +428,7 @@ impl DNSState {
     pub fn new_tcp() -> DNSState {
         return DNSState{
             tx_id: 0,
-            transactions: Vec::new(),
+            transactions: VecDeque::new(),
             config: None,
             gap: false,
         };
@@ -530,7 +530,7 @@ impl DNSState {
                 let mut tx = self.new_tx();
                 tx.request = Some(request);
                 tx.tx_data.set_inspect_direction(STREAM_TOSERVER);
-                self.transactions.push(tx);
+                self.transactions.push_back(tx);
 
                 if z_flag {
                     SCLogDebug!("Z-flag set on DNS response");
@@ -594,7 +594,7 @@ impl DNSState {
                 }
                 tx.response = Some(response);
                 tx.tx_data.set_inspect_direction(STREAM_TOCLIENT);
-                self.transactions.push(tx);
+                self.transactions.push_back(tx);
 
                 if z_flag {
                     SCLogDebug!("Z-flag set on DNS response");