Skip to content

Commit

Permalink
Open direct dir first so the open FDs are contiguous
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Saveau <[email protected]>
  • Loading branch information
SUPERCILEX committed Jul 28, 2024
1 parent 4e44d11 commit 15c2d0c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions client-sdk/src/ring_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,12 @@ pub struct EntryReader {

impl EntryReader {
pub fn open(database_dir: &mut PathBuf) -> Result<Self, ringboard_core::Error> {
let direct_dir = {
let file = PathView::new(database_dir, "direct");
openat(CWD, &*file, OFlags::DIRECTORY | OFlags::PATH, Mode::empty())
.map_io_err(|| format!("Failed to open directory: {file:?}"))
}?;

let buckets = {
let mut buckets = PathView::new(database_dir, "buckets");
let (buckets, lengths) = open_buckets(|name| {
Expand All @@ -512,12 +518,6 @@ impl EntryReader {
maps.into_inner().unwrap()
};

let direct_dir = {
let file = PathView::new(database_dir, "direct");
openat(CWD, &*file, OFlags::DIRECTORY | OFlags::PATH, Mode::empty())
.map_io_err(|| format!("Failed to open directory: {file:?}"))
}?;

Ok(Self {
buckets,
direct: direct_dir,
Expand Down

0 comments on commit 15c2d0c

Please sign in to comment.