index file readers: aquire shared lock

This commit is contained in:
Dietmar Maurer 2019-03-27 10:11:14 +01:00
parent 0465218953
commit c597a92c81
2 changed files with 8 additions and 0 deletions

View File

@ -58,6 +58,10 @@ impl DynamicIndexReader {
let mut file = std::fs::File::open(&full_path)?; let mut file = std::fs::File::open(&full_path)?;
if let Err(err) = nix::fcntl::flock(file.as_raw_fd(), nix::fcntl::FlockArg::LockSharedNonblock) {
bail!("unable to get shared lock on {:?} - {}", full_path, err);
}
let header_size = std::mem::size_of::<DynamicIndexHeader>(); let header_size = std::mem::size_of::<DynamicIndexHeader>();
// todo: use static assertion when available in rust // todo: use static assertion when available in rust

View File

@ -57,6 +57,10 @@ impl FixedIndexReader {
let mut file = std::fs::File::open(&full_path)?; let mut file = std::fs::File::open(&full_path)?;
if let Err(err) = nix::fcntl::flock(file.as_raw_fd(), nix::fcntl::FlockArg::LockSharedNonblock) {
bail!("unable to get shared lock on {:?} - {}", full_path, err);
}
let header_size = std::mem::size_of::<FixedIndexHeader>(); let header_size = std::mem::size_of::<FixedIndexHeader>();
// todo: use static assertion when available in rust // todo: use static assertion when available in rust