Fix possible w-lock panic

for a detailed explanation of the issue this commit tries to solve have
a look at

    7b5d37a039

which explains the issue in detail.
This commit is contained in:
Matthias Beyer 2016-08-01 20:31:11 +02:00
parent ea17755ad4
commit 84ae516dc3

View file

@ -428,7 +428,8 @@ impl Store {
.map_err_into(SEK::RetrieveCallError)
}
let entry = try!(self.entries
let entry = try!({
self.entries
.write()
.map_err(|_| SE::new(SEK::LockPoisoned, None))
.and_then(|mut es| {
@ -437,7 +438,8 @@ impl Store {
se.status = StoreEntryStatus::Borrowed;
entry
})
.map_err_into(SEK::RetrieveCallError));
.map_err_into(SEK::RetrieveCallError)
});
let mut fle = FileLockEntry::new(self, entry);
self.execute_hooks_for_mut_file(self.post_retrieve_aspects.clone(), &mut fle)
@ -598,6 +600,7 @@ impl Store {
.map_err_into(SEK::DeleteCallError)
}
{
let mut entries = match self.entries.write() {
Err(_) => return Err(SE::new(SEK::LockPoisoned, None))
.map_err_into(SEK::DeleteCallError),
@ -616,6 +619,7 @@ impl Store {
return Err(SEK::FileError.into_error_with_cause(Box::new(e)))
.map_err_into(SEK::DeleteCallError);
}
}
self.execute_hooks_for_id(self.post_delete_aspects.clone(), &id)
.map_err_into(SEK::PostHookExecuteError)