Skip to content

Commit

Permalink
fix last infinite loop
Browse files Browse the repository at this point in the history
  • Loading branch information
menghaoyu2002 committed Jun 10, 2024
1 parent 6a0d9ab commit f5d5edb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,11 @@ impl Client {
fn keep_alive(&self) -> JoinHandle<()> {
let peers = Arc::clone(&self.peers);
let send_queue = Arc::clone(&self.send_queue);
let total_length = self.tracker.get_metainfo().get_length();
let total_downloaded = Arc::clone(&self.total_downloaded);

tokio::spawn(async move {
loop {
while *total_downloaded.lock().await < total_length {
for (peer_id, peer) in peers.read().await.iter() {
if (Utc::now() - peer.lock().await.last_touch).num_seconds() > 60 {
send_queue.lock().await.push_back((
Expand Down

0 comments on commit f5d5edb

Please sign in to comment.