Skip to content

Commit

Permalink
don't loop forever in DHT poll
Browse files Browse the repository at this point in the history
  • Loading branch information
bfish713 committed Mar 22, 2024
1 parent d64446b commit 3508c95
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions crates/libp2p-networking/src/network/behaviours/dht/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down

0 comments on commit 3508c95

Please sign in to comment.