Skip to content

Commit

Permalink
inaccuracy in try_unlock
Browse files Browse the repository at this point in the history
  • Loading branch information
nameexhaustion committed Jun 5, 2024
1 parent 3ca891c commit 62afca6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions crates/polars-io/src/file_cache/cache_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,14 @@ impl GlobalLock {
/// * `Some(false)` - Unlocked (already previously unlocked)
fn try_unlock(&self) -> Option<bool> {
if let Ok(mut this) = self.inner.try_write() {
if Arc::strong_count(&self.access_tracker.0) <= 2 && this.state.take().is_some() {
this.file.unlock().unwrap();
return Some(true);
if Arc::strong_count(&self.access_tracker.0) <= 2 {
return if this.state.take().is_some() {
this.file.unlock().unwrap();
Some(true)
} else {
Some(false)
};
}

return this.state.is_none().then_some(false);
}
None
}
Expand Down

0 comments on commit 62afca6

Please sign in to comment.