From 258096c56bd9c3176a7210b29c18412bb93ed99a Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Mon, 3 Feb 2025 12:30:47 +0200 Subject: Use fully qualified calls for fs2 lock functions Fixes warning about https://github.com/rust-lang/rust/issues/48919 --- log_db/src/lib.rs | 1 - log_db/src/lock.rs | 16 ++++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) (limited to 'log_db/src') 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 { // 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(()) } -- cgit v1.3