From: Jason Ish Date: Wed, 27 Apr 2022 15:38:51 +0000 (-0600) Subject: http2: convert transaction list to vecdeque X-Git-Tag: suricata-6.0.13~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20952ba8e0744caaa1ecaaf48e168bcab6f6d9b3;p=thirdparty%2Fsuricata.git http2: convert transaction list to vecdeque Allows for more efficient removal from front of the list. Ticket: #5296 (cherry picked from commit 2db84726ad3445a0b55ca145489103483f61c6b0) --- diff --git a/rust/src/http2/http2.rs b/rust/src/http2/http2.rs index 6917e054cb..ee285ad1ee 100644 --- a/rust/src/http2/http2.rs +++ b/rust/src/http2/http2.rs @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 Open Information Security Foundation +/* Copyright (C) 2020-2022 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -29,6 +29,7 @@ use crate::filetracker::*; use nom; use std; use std::ffi::{CStr, CString}; +use std::collections::VecDeque; use std::fmt; use std::io; use std::mem::transmute; @@ -379,7 +380,7 @@ pub struct HTTP2State { response_frame_size: u32, dynamic_headers_ts: HTTP2DynTable, dynamic_headers_tc: HTTP2DynTable, - transactions: Vec, + transactions: VecDeque, progress: HTTP2ConnectionState, pub files: HTTP2Files, } @@ -395,7 +396,7 @@ impl HTTP2State { // a variable number of dynamic headers dynamic_headers_ts: HTTP2DynTable::new(), dynamic_headers_tc: HTTP2DynTable::new(), - transactions: Vec::new(), + transactions: VecDeque::new(), progress: HTTP2ConnectionState::Http2StateInit, files: HTTP2Files::new(), } @@ -474,8 +475,8 @@ impl HTTP2State { self.tx_id += 1; tx.tx_id = self.tx_id; tx.state = HTTP2TransactionState::HTTP2StateGlobal; - self.transactions.push(tx); - return self.transactions.last_mut().unwrap(); + self.transactions.push_back(tx); + return self.transactions.back_mut().unwrap(); } pub fn find_or_create_tx( @@ -515,8 +516,8 @@ impl HTTP2State { tx.tx_id = self.tx_id; tx.stream_id = sid; tx.state = HTTP2TransactionState::HTTP2StateOpen; - self.transactions.push(tx); - return self.transactions.last_mut().unwrap(); + self.transactions.push_back(tx); + return self.transactions.back_mut().unwrap(); } }