Skip to content

Commit

Permalink
Close old page before partially opening next one to help shutdown con…
Browse files Browse the repository at this point in the history
…sistency
  • Loading branch information
diondokter committed Dec 29, 2023
1 parent 1a781e5 commit ccbb670
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ pub fn push<S: NorFlash>(
let next_page = next_page::<S>(flash_range.clone(), current_page);
match get_page_state(flash, flash_range.clone(), next_page)? {
PageState::Open => {
close_page(flash, flash_range.clone(), current_page)?;
partial_close_page(flash, flash_range.clone(), next_page)?;
next_address = Some(
calculate_page_address::<S>(flash_range.clone(), next_page)
Expand Down Expand Up @@ -130,6 +131,7 @@ pub fn push<S: NorFlash>(
backtrace: std::backtrace::Backtrace::capture(),
})?;

close_page(flash, flash_range.clone(), current_page)?;
partial_close_page(flash, flash_range.clone(), next_page)?;
next_address = Some(next_page_data_start_address);
}
Expand All @@ -143,8 +145,6 @@ pub fn push<S: NorFlash>(
});
}
}

close_page(flash, flash_range.clone(), current_page)?;
}

Item::write_new(flash, next_address.unwrap(), data)?;
Expand Down

0 comments on commit ccbb670

Please sign in to comment.