mirror of
https://github.com/rustic-rs/rustic.git
synced 2025-10-26 11:18:51 +00:00
fix possible deadlock in archiver
This commit is contained in:
parent
222cb38c35
commit
e67e025c02
@ -109,8 +109,13 @@ impl<BE: DecryptWriteBackend> Packer<BE> {
|
||||
/// adds the blob to the packfile, allows specifying a size limit for the pack file
|
||||
pub fn add_with_sizelimit(&self, data: &[u8], id: &Id, size_limit: Option<u32>) -> Result<()> {
|
||||
// only add if this blob is not present
|
||||
if self.indexer.read().unwrap().has(id) || self.raw_packer.read().unwrap().has(id) {
|
||||
return Ok(());
|
||||
if self.indexer.read().unwrap().has(id) {
|
||||
// Note: This is within two if clauses , because here the indexer lock is already released.
|
||||
// using "if self.indexer.read().unwrap().has(id) || self.raw_packer.read().unwrap().has(id)"
|
||||
// can lead to a deadlock as the indexer lock is hold too long (and also needed within raw_packer!)
|
||||
if self.raw_packer.read().unwrap().has(id) {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
let key = self.key.clone();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user