pub struct LockManager {
held: Mutex<HashMap<String, Vec<HeldLock>>>,
released: Notify,
}Expand description
Server-wide byte-range lock manager ([MS-SMB2] §2.2.26 / [MS-FSA] §2.1.4.10). Locks are keyed by the file’s on-disk path so opens from different connections contend correctly.
Fields§
§held: Mutex<HashMap<String, Vec<HeldLock>>>§released: NotifyImplementations§
Source§impl LockManager
impl LockManager
Sourcefn conflicts(existing: &HeldLock, off: u64, len: u64, excl: bool) -> bool
fn conflicts(existing: &HeldLock, off: u64, len: u64, excl: bool) -> bool
A new lock on [off, off+len) conflicts with existing when the ranges
overlap and either lock is exclusive. An exclusive lock conflicts even
with the same open’s overlapping lock ([MS-FSA] §2.1.5.9); two shared
locks never conflict.
Sourcepub fn try_acquire(
&self,
path: &str,
ranges: &[(u64, u64, bool)],
owner: LockOwner,
) -> bool
pub fn try_acquire( &self, path: &str, ranges: &[(u64, u64, bool)], owner: LockOwner, ) -> bool
Atomically acquire every range, or acquire none. ranges are
(offset, length, exclusive). Returns true on success.
Sourcepub fn write_conflict(
&self,
path: &str,
off: u64,
len: u64,
owner: LockOwner,
) -> bool
pub fn write_conflict( &self, path: &str, off: u64, len: u64, owner: LockOwner, ) -> bool
A write to [off, off+len) is blocked when it overlaps any shared lock
(a read lock forbids writes by every open, [MS-FSA] §2.1.5.9) or an
exclusive lock held by a different open.
Sourcepub fn read_conflict(
&self,
path: &str,
off: u64,
len: u64,
owner: LockOwner,
) -> bool
pub fn read_conflict( &self, path: &str, off: u64, len: u64, owner: LockOwner, ) -> bool
A read overlaps a conflicting lock only when another open holds an exclusive lock on the range.
Sourcepub fn release(&self, path: &str, ranges: &[(u64, u64)], owner: LockOwner)
pub fn release(&self, path: &str, ranges: &[(u64, u64)], owner: LockOwner)
Release specific (offset, length) ranges held by owner.
Sourcepub fn release_owner(&self, owner: LockOwner)
pub fn release_owner(&self, owner: LockOwner)
Drop every lock held by owner (on handle close or session teardown).
Sourcepub fn release_session(&self, session_id: u64)
pub fn release_session(&self, session_id: u64)
Drop every lock held by any open of session_id (logoff/disconnect).