From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH backup 08/13] snapshot_reader: use Rc for structs that are not Send+Sync
Date: Mon, 12 Feb 2024 14:17:33 +0100 [thread overview]
Message-ID: <20240212131734.454966-8-m.sandoval@proxmox.com> (raw)
In-Reply-To: <20240212131734.454966-1-m.sandoval@proxmox.com>
Fixes the clippy lint:
```
warning: usage of an `Arc` that is not `Send` and `Sync`
--> pbs-datastore/src/snapshot_reader.rs:156:52
|
156 | self.current_index = Some((Arc::new(index), 0, order));
| ^^^^^^^^^^^^^^^
|
= note: `Arc<Box<dyn IndexFile + Send>>` is not `Send` and `Sync` as:
= note: - the trait `Sync` is not implemented for `Box<dyn IndexFile + Send>`
= help: consider using an `Rc` instead. `Arc` does not provide benefits for non `Send` and `Sync` types
= note: if you intend to use `Arc` with `Send` and `Sync` traits
= note: wrap the inner type with a `Mutex` or implement `Send` and `Sync` for `Box<dyn IndexFile + Send>`
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#arc_with_non_send_sync
= note: `#[warn(clippy::arc_with_non_send_sync)]` on by default
```
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
pbs-datastore/src/snapshot_reader.rs | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/pbs-datastore/src/snapshot_reader.rs b/pbs-datastore/src/snapshot_reader.rs
index ec7a48e5..816df310 100644
--- a/pbs-datastore/src/snapshot_reader.rs
+++ b/pbs-datastore/src/snapshot_reader.rs
@@ -1,6 +1,7 @@
use std::fs::File;
use std::os::unix::io::{AsRawFd, FromRawFd};
use std::path::Path;
+use std::rc::Rc;
use std::sync::Arc;
use anyhow::{bail, Error};
@@ -126,7 +127,7 @@ pub struct SnapshotChunkIterator<'a, F: Fn(&[u8; 32]) -> bool> {
todo_list: Vec<String>,
skip_fn: F,
#[allow(clippy::type_complexity)]
- current_index: Option<(Arc<Box<dyn IndexFile + Send>>, usize, Vec<(usize, u64)>)>,
+ current_index: Option<(Rc<Box<dyn IndexFile + Send>>, usize, Vec<(usize, u64)>)>,
}
impl<'a, F: Fn(&[u8; 32]) -> bool> Iterator for SnapshotChunkIterator<'a, F> {
@@ -153,7 +154,7 @@ impl<'a, F: Fn(&[u8; 32]) -> bool> Iterator for SnapshotChunkIterator<'a, F> {
let order =
datastore.get_chunks_in_order(&*index, &self.skip_fn, |_| Ok(()))?;
- self.current_index = Some((Arc::new(index), 0, order));
+ self.current_index = Some((Rc::new(index), 0, order));
} else {
return Ok(None);
}
--
2.39.2
next prev parent reply other threads:[~2024-02-12 13:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-12 13:17 [pbs-devel] [PATCH backup 01/13] docs: remove redundant explicit link target Maximiliano Sandoval
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 02/13] remove redundant guards Maximiliano Sandoval
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 03/13] remove needless borrows Maximiliano Sandoval
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 04/13] media_catalog: use stream_position Maximiliano Sandoval
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 05/13] use or_default instead of or_insert_with(Default::default) Maximiliano Sandoval
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 06/13] access first element with first() rather than get(0) Maximiliano Sandoval
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 07/13] datastore: use is_{err, some} rather than match {Ok, Some}(_) Maximiliano Sandoval
2024-02-12 13:17 ` Maximiliano Sandoval [this message]
2024-02-13 9:20 ` [pbs-devel] [PATCH backup 08/13] snapshot_reader: use Rc for structs that are not Send+Sync Fabian Grünbichler
2024-02-12 13:17 ` [pbs-devel] [PATCH backup 09/13] pxar: elide explicit lifetime Maximiliano Sandoval
2024-02-13 9:04 ` [pbs-devel] [PATCH backup 01/13] docs: remove redundant explicit link target Maximiliano Sandoval
2024-02-13 9:28 ` [pbs-devel] partially-applied: " Fabian Grünbichler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240212131734.454966-8-m.sandoval@proxmox.com \
--to=m.sandoval@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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