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 <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2021-05-10 13:54:09 +02:00 committed by Dietmar Maurer
parent c9c07445b7
commit 2d5d264f99

View File

@ -51,7 +51,7 @@ impl NewChunksIterator {
loop { loop {
let digest = match chunk_iter.next() { let digest = match chunk_iter.next() {
None => { None => {
tx.send(Ok(None)).unwrap(); let _ = tx.send(Ok(None)); // ignore send error
break; break;
} }
Some(digest) => digest?, Some(digest) => digest?,
@ -67,7 +67,13 @@ impl NewChunksIterator {
let blob = datastore.load_chunk(&digest)?; let blob = datastore.load_chunk(&digest)?;
//println!("LOAD CHUNK {}", proxmox::tools::digest_to_hex(&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); chunk_index.insert(digest);
} }
@ -75,7 +81,9 @@ impl NewChunksIterator {
Ok(()) Ok(())
}); });
if let Err(err) = result { 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);
}
} }
}); });