From 2d5d264f99b6d6086593b1763da8864ed322fd15 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Mon, 10 May 2021 13:54:09 +0200 Subject: [PATCH] tape/pool_writer: do not unwrap on channel send if the reader thread is already gone here, we panic here, resulting in a nondescript error message, so simply ignore/warn in that case and return gracefully Signed-off-by: Dominik Csapak --- src/tape/pool_writer/new_chunks_iterator.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/tape/pool_writer/new_chunks_iterator.rs b/src/tape/pool_writer/new_chunks_iterator.rs index 56491356..64472902 100644 --- a/src/tape/pool_writer/new_chunks_iterator.rs +++ b/src/tape/pool_writer/new_chunks_iterator.rs @@ -51,7 +51,7 @@ impl NewChunksIterator { loop { let digest = match chunk_iter.next() { None => { - tx.send(Ok(None)).unwrap(); + let _ = tx.send(Ok(None)); // ignore send error break; } Some(digest) => digest?, @@ -67,7 +67,13 @@ impl NewChunksIterator { let blob = datastore.load_chunk(&digest)?; //println!("LOAD CHUNK {}", proxmox::tools::digest_to_hex(&digest)); - tx.send(Ok(Some((digest, blob)))).unwrap(); + match tx.send(Ok(Some((digest, blob)))) { + Ok(()) => {}, + Err(err) => { + eprintln!("could not send chunk to reader thread: {}", err); + break; + } + } chunk_index.insert(digest); } @@ -75,7 +81,9 @@ impl NewChunksIterator { Ok(()) }); if let Err(err) = result { - tx.send(Err(err)).unwrap(); + if let Err(err) = tx.send(Err(err)) { + eprintln!("error sending result to reader thread: {}", err); + } } });