From b3fabf1f5afa6728debf3cfe072124be0a3eee0f Mon Sep 17 00:00:00 2001 From: chanderlud Date: Wed, 29 Nov 2023 21:44:39 -0800 Subject: [PATCH] tiny refactor --- src/sender/mod.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/sender/mod.rs b/src/sender/mod.rs index 9bffe95..b4a492d 100644 --- a/src/sender/mod.rs +++ b/src/sender/mod.rs @@ -21,8 +21,7 @@ mod reader; type JobQueue = UnlimitedQueue; type JobCache = Arc>>; -#[derive(Clone)] -pub(crate) struct Job { +struct Job { data: Vec, // index (8 bytes) + the file chunk index: u64, // the index of the file chunk cached_at: Option, @@ -123,7 +122,7 @@ pub(crate) async fn main(options: Options, stats: TransferStats) -> Result<()> { async fn sender(queue: JobQueue, socket: UdpSocket, cache: JobCache, send: Arc) { let mut retries = 0; - loop { + while retries < MAX_RETRIES { let permit = send.acquire().await.unwrap(); // acquire a permit let mut job = queue.pop().await; // get the next job @@ -131,13 +130,7 @@ async fn sender(queue: JobQueue, socket: UdpSocket, cache: JobCache, send: Arc