From 5c1130df9ff4e9508d4dc184a8577f06767fba94 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Wed, 28 Aug 2019 10:33:41 +0200 Subject: [PATCH] implement Sync for DynamicIndexReader and FixedIndexReader hyper's wrap_stream now needs this Signed-off-by: Wolfgang Bumiller --- src/backup/dynamic_index.rs | 1 + src/backup/fixed_index.rs | 1 + src/backup/index.rs | 6 +++--- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/backup/dynamic_index.rs b/src/backup/dynamic_index.rs index ae3b284e..f1d2ba3a 100644 --- a/src/backup/dynamic_index.rs +++ b/src/backup/dynamic_index.rs @@ -49,6 +49,7 @@ pub struct DynamicIndexReader { // `index` is mmap()ed which cannot be thread-local so should be sendable // FIXME: Introduce an mmap wrapper type for this? unsafe impl Send for DynamicIndexReader {} +unsafe impl Sync for DynamicIndexReader {} impl Drop for DynamicIndexReader { diff --git a/src/backup/fixed_index.rs b/src/backup/fixed_index.rs index 526e72f1..61e0a058 100644 --- a/src/backup/fixed_index.rs +++ b/src/backup/fixed_index.rs @@ -45,6 +45,7 @@ pub struct FixedIndexReader { // `index` is mmap()ed which cannot be thread-local so should be sendable unsafe impl Send for FixedIndexReader {} +unsafe impl Sync for FixedIndexReader {} impl Drop for FixedIndexReader { diff --git a/src/backup/index.rs b/src/backup/index.rs index a3ab6097..e58636bf 100644 --- a/src/backup/index.rs +++ b/src/backup/index.rs @@ -7,7 +7,7 @@ use futures::*; /// Trait to get digest list from index files /// /// To allow easy iteration over all used chunks. -pub trait IndexFile: Send { +pub trait IndexFile { fn index_count(&self) -> usize; fn index_digest(&self, pos: usize) -> Option<&[u8; 32]>; fn index_bytes(&self) -> u64; @@ -49,14 +49,14 @@ pub trait IndexFile: Send { /// /// The reader simply returns a birary stream of 32 byte digest values. pub struct DigestListEncoder { - index: Box, + index: Box, pos: usize, count: usize, } impl DigestListEncoder { - pub fn new(index: Box) -> Self { + pub fn new(index: Box) -> Self { let count = index.index_count(); Self { index, pos: 0, count } }