Skip to content

Commit

Permalink
fix(kad): compute jobs_query_capacity accurately
Browse files Browse the repository at this point in the history
Fixes: #4191.

Pull-Request: #5148.
  • Loading branch information
junekhan authored and guillaumemichel committed Mar 28, 2024
1 parent 29c4200 commit e5346ec
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions protocols/kad/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2502,14 +2502,14 @@ where
// Run the periodic provider announcement job.
if let Some(mut job) = self.add_provider_job.take() {
let num = usize::min(JOBS_MAX_NEW_QUERIES, jobs_query_capacity);
for _ in 0..num {
for i in 0..num {
if let Poll::Ready(r) = job.poll(cx, &mut self.store, now) {
self.start_add_provider(r.key, AddProviderContext::Republish)
} else {
jobs_query_capacity -= i;
break;
}
}
jobs_query_capacity -= num;
self.add_provider_job = Some(job);
}

Expand Down

0 comments on commit e5346ec

Please sign in to comment.