From 3508c95850738807a925230080f2a600f4a525aa Mon Sep 17 00:00:00 2001 From: Brendon Fish Date: Fri, 22 Mar 2024 14:07:11 -0400 Subject: [PATCH] don't loop forever in DHT poll --- .../src/network/behaviours/dht/mod.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/libp2p-networking/src/network/behaviours/dht/mod.rs b/crates/libp2p-networking/src/network/behaviours/dht/mod.rs index 0cbdbba462..caa9f9ee34 100644 --- a/crates/libp2p-networking/src/network/behaviours/dht/mod.rs +++ b/crates/libp2p-networking/src/network/behaviours/dht/mod.rs @@ -589,7 +589,10 @@ impl NetworkBehaviour for DHTBehaviour { } // retry put/gets if they are ready - while let Some(req) = self.queued_get_record_queries.pop_front() { + for _i in 0..self.queued_get_record_queries.len() { + let Some(req) = self.queued_get_record_queries.pop_front() else { + continue; + }; if req.backoff.is_expired() { self.get_record( req.key, @@ -603,7 +606,10 @@ impl NetworkBehaviour for DHTBehaviour { } } - while let Some(req) = self.queued_put_record_queries.pop_front() { + for _i in 0..self.queued_put_record_queries.len() { + let Some(req) = self.queued_put_record_queries.pop_front() else { + continue; + }; if req.backoff.is_expired() { self.put_record(req); } else {