Skip to content

Commit

Permalink
List iterators: hold lock when calling find_true_head/tail
Browse files Browse the repository at this point in the history
  • Loading branch information
tomerfiliba committed Aug 17, 2024
1 parent 351c909 commit b54d503
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ impl<'a> Iterator for LinkedListIterator<'a> {
type Item = Result<Option<KVPair>>;
fn next(&mut self) -> Option<Self::Item> {
if self.fph.is_none() {
let _guard = self.store._list_lock(self.list_ph);
let buf = match self.store.get_raw(&self.list_key) {
Ok(buf) => buf,
Err(e) => return Some(Err(e)),
Expand Down Expand Up @@ -193,6 +194,7 @@ impl<'a> Iterator for RevLinkedListIterator<'a> {
type Item = Result<Option<KVPair>>;
fn next(&mut self) -> Option<Self::Item> {
if self.fph.is_none() {
let _guard = self.store._list_lock(self.list_ph);
let buf = match self.store.get_raw(&self.list_key) {
Ok(buf) => buf,
Err(e) => return Some(Err(e)),
Expand Down

0 comments on commit b54d503

Please sign in to comment.