diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2025-02-03 12:30:47 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2025-02-03 12:30:47 +0200 |
| commit | 258096c56bd9c3176a7210b29c18412bb93ed99a (patch) | |
| tree | b0c1565213689cc2750eab9a2047eb70ac7d5383 /log_db | |
| parent | fd191fd9b67794d72ec9c28de9c366d81d29629f (diff) | |
Use fully qualified calls for fs2 lock functions
Fixes warning about https://github.com/rust-lang/rust/issues/48919
Diffstat (limited to 'log_db')
| -rw-r--r-- | log_db/src/lib.rs | 1 | ||||
| -rw-r--r-- | log_db/src/lock.rs | 16 |
2 files changed, 8 insertions, 9 deletions
diff --git a/log_db/src/lib.rs b/log_db/src/lib.rs index 5110aea..33615de 100644 --- a/log_db/src/lib.rs +++ b/log_db/src/lib.rs @@ -1,7 +1,6 @@ #[macro_use] extern crate log; -use fs2::{lock_contended_error, FileExt}; use once_cell::sync::Lazy; use rust_decimal::Decimal; use std::cmp::Ordering; diff --git a/log_db/src/lock.rs b/log_db/src/lock.rs index adb2809..f00429f 100644 --- a/log_db/src/lock.rs +++ b/log_db/src/lock.rs @@ -29,16 +29,16 @@ impl LockManager { fn is_exclusive_lock_requested(&self) -> DBResult<bool> { // Attempt to acquire a shared lock on the lock request file // If the file is already locked, return false - match self.excl_lock_file.try_lock_shared() { + match fs2::FileExt::try_lock_shared(&self.excl_lock_file) { Err(e) => { - if e.kind() == lock_contended_error().kind() { + if e.kind() == fs2::lock_contended_error().kind() { return Ok(true); } return Err(DBError::IOError(e)); } Ok(_) => { - self.excl_lock_file.unlock()?; + fs2::FileExt::unlock(&self.excl_lock_file)?; return Ok(false); } } @@ -71,7 +71,7 @@ impl LockManager { )); } } else { - self.lock_file.lock_shared()?; + fs2::FileExt::lock_shared(&self.lock_file)?; self.state = LockState::Shared; return Ok(()); } @@ -91,14 +91,14 @@ impl LockManager { // Create a lock on the exclusive lock request file to signal to readers that they should wait // This will block until the lock is acquired - self.excl_lock_file.lock_exclusive()?; + fs2::FileExt::lock_exclusive(&self.excl_lock_file)?; // Acquire an exclusive lock on the actual lock files - self.lock_file.lock_exclusive()?; + fs2::FileExt::lock_exclusive(&self.lock_file)?; self.state = LockState::Exclusive; // Unlock the request file - self.excl_lock_file.unlock()?; + fs2::FileExt::unlock(&self.excl_lock_file)?; Ok(()) } @@ -110,7 +110,7 @@ impl LockManager { )); } - self.lock_file.unlock()?; + fs2::FileExt::unlock(&self.lock_file)?; self.state = LockState::NotLocked; Ok(()) } |
