all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox-backup] tape/pool_writer: do not unwrap on channel send
@ 2021-05-10 11:54 Dominik Csapak
  2021-05-11  7:08 ` [pbs-devel] applied: " Dietmar Maurer
  0 siblings, 1 reply; 2+ messages in thread
From: Dominik Csapak @ 2021-05-10 11:54 UTC (permalink / raw)
  To: pbs-devel

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>
---
 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);
+                }
             }
         });
 
-- 
2.20.1





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pbs-devel] applied: [PATCH proxmox-backup] tape/pool_writer: do not unwrap on channel send
  2021-05-10 11:54 [pbs-devel] [PATCH proxmox-backup] tape/pool_writer: do not unwrap on channel send Dominik Csapak
@ 2021-05-11  7:08 ` Dietmar Maurer
  0 siblings, 0 replies; 2+ messages in thread
From: Dietmar Maurer @ 2021-05-11  7:08 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Dominik Csapak

applied

On 5/10/21 1:54 PM, Dominik Csapak wrote:
> 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>
> ---
>   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);
> +                }
>               }
>           });
>   




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-11  7:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-10 11:54 [pbs-devel] [PATCH proxmox-backup] tape/pool_writer: do not unwrap on channel send Dominik Csapak
2021-05-11  7:08 ` [pbs-devel] applied: " Dietmar Maurer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal