Skip to content

Commit

Permalink
fix(client): avoid dead lock with less chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
maqi authored and joshuef committed Jan 12, 2024
1 parent eee302d commit 66b77b8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions sn_client/src/files/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,6 @@ impl FilesUpload {
return Ok(());
}

if chunks.is_empty() && !on_going_pay_for_chunk.is_empty() {
// Fire None to trigger a forced round of making leftover payments.
let paying_work_sender_clone = paying_work_sender.clone();
let _handle = tokio::spawn(async move {
let _ = paying_work_sender_clone.send(None).await;
});
}

while !chunks.is_empty()
&& on_going_get_cost.len() < batch_size
&& pending_to_pay.len() < batch_size
Expand Down Expand Up @@ -298,6 +290,14 @@ impl FilesUpload {
}
}

if chunks.is_empty() && !on_going_pay_for_chunk.is_empty() {
// Fire None to trigger a forced round of making leftover payments.
let paying_work_sender_clone = paying_work_sender.clone();
let _handle = tokio::spawn(async move {
let _ = paying_work_sender_clone.send(None).await;
});
}

let task_result = if let Some(result) = progress_tasks(
&mut get_store_cost_receiver,
&mut paid_chunk_receiver,
Expand Down

0 comments on commit 66b77b8

Please sign in to comment.