use crate::core::{AppProto, Flow, ALPROTO_FAILED, ALPROTO_UNKNOWN, IPPROTO_TCP};
use nom7::{Err, IResult};
use std;
+use std::collections::VecDeque;
use std::ffi::CString;
pub const PGSQL_CONFIG_DEFAULT_STREAM_DEPTH: u32 = 0;
#[derive(Debug)]
pub struct PgsqlState {
tx_id: u64,
- transactions: Vec<PgsqlTransaction>,
+ transactions: VecDeque<PgsqlTransaction>,
request_gap: bool,
response_gap: bool,
backend_secret_key: u32,
pub fn new() -> Self {
Self {
tx_id: 0,
- transactions: Vec::new(),
+ transactions: VecDeque::new(),
request_gap: false,
response_gap: false,
backend_secret_key: 0,
|| self.state_progress == PgsqlStateProgress::ConnectionTerminated
{
let tx = self.new_tx();
- self.transactions.push(tx);
+ self.transactions.push_back(tx);
}
// If we don't need a new transaction, just return the current one
SCLogDebug!("find_or_create state is {:?}", &self.state_progress);
- return self.transactions.last_mut();
+ return self.transactions.back_mut();
}
/// Process State progress to decide if PgsqlTransaction is finished
PgsqlBEMessage::RowDescription(_) => Some(PgsqlStateProgress::RowDescriptionReceived),
PgsqlBEMessage::ConsolidatedDataRow(msg) => {
// Increment tx.data_size here, since we know msg type, so that we can later on log that info
- self.transactions.last_mut()?.sum_data_size(msg.data_size);
+ self.transactions.back_mut()?.sum_data_size(msg.data_size);
Some(PgsqlStateProgress::DataRowReceived)
}
PgsqlBEMessage::CommandComplete(_) => {
let tx0 = state.new_tx(item0);
let tx1 = state.new_tx(item1);
let tx2 = state.new_tx(item2);
- state.transactions.push(tx0);
- state.transactions.push(tx1);
- state.transactions.push(tx2);
+ state.transactions.push_back(tx0);
+ state.transactions.push_back(tx1);
+ state.transactions.push_back(tx2);
assert_eq!(Some(&state.transactions[1]), state.get_tx(2));
}