aboutsummaryrefslogtreecommitdiff
path: root/src/block/manager.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-06-02 23:14:10 +0200
committerAlex Auvolat <alex@adnab.me>2022-06-02 23:14:10 +0200
commitc439cb11a908ee5405ed0a3a721e9c8c0e299ad2 (patch)
tree65835f8c9b47d0670d1461fc43f358fc73850414 /src/block/manager.rs
parent364061453cd0a5a2e4f76f4194e6b5887aae7ed8 (diff)
downloadgarage-c439cb11a908ee5405ed0a3a721e9c8c0e299ad2.tar.gz
garage-c439cb11a908ee5405ed0a3a721e9c8c0e299ad2.zip
Sqlite iter with unsafe code
Diffstat (limited to 'src/block/manager.rs')
-rw-r--r--src/block/manager.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/block/manager.rs b/src/block/manager.rs
index 50039d2b..f34d13d0 100644
--- a/src/block/manager.rs
+++ b/src/block/manager.rs
@@ -547,9 +547,7 @@ impl BlockManager {
// - Ok(false) -> no block was processed, but we are ready for the next iteration
// - Err(_) -> a Sled error occurred when reading/writing from resync_queue/resync_errors
async fn resync_iter(&self, must_exit: &mut watch::Receiver<bool>) -> Result<bool, db::Error> {
- if let Some(first_pair_res) = self.resync_queue.iter()?.next() {
- let (time_bytes, hash_bytes) = first_pair_res?;
-
+ if let Some((time_bytes, hash_bytes)) = self.resync_get_next()? {
let time_msec = u64::from_be_bytes(time_bytes[0..8].try_into().unwrap());
let now = now_msec();
@@ -642,6 +640,16 @@ impl BlockManager {
}
}
+ fn resync_get_next(&self) -> Result<Option<(Vec<u8>, Vec<u8>)>, db::Error> {
+ match self.resync_queue.iter()?.next() {
+ None => Ok(None),
+ Some(v) => {
+ let (time_bytes, hash_bytes) = v?;
+ Ok(Some((time_bytes.into_owned(), hash_bytes.into_owned())))
+ }
+ }
+ }
+
async fn resync_block(&self, hash: &Hash) -> Result<(), Error> {
let BlockStatus { exists, needed } = self
.mutation_lock