From 7d3aa91bf4c3b68442b92d6da7a4692ef1e64e6a Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Tue, 30 May 2023 12:08:25 +0200 Subject: [PATCH] mqtt: fix quadratic complexity get_tx_by_pkt_id loops only over the last transactions in case there is a transaction flood Ticket: #6100 --- rust/src/mqtt/mqtt.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/src/mqtt/mqtt.rs b/rust/src/mqtt/mqtt.rs index 6149ce5982..f1c37d83c8 100644 --- a/rust/src/mqtt/mqtt.rs +++ b/rust/src/mqtt/mqtt.rs @@ -170,7 +170,7 @@ impl MQTTState { } pub fn get_tx_by_pkt_id(&mut self, pkt_id: u32) -> Option<&mut MQTTTransaction> { - for tx in &mut self.transactions { + for tx in &mut self.transactions.range_mut(self.tx_index_completed..) { if !tx.complete { if let Some(mpktid) = tx.pkt_id { if mpktid == pkt_id {