MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / is_lock_contended

Function is_lock_contended

atomic-agent/src/turn/orchestrator/mod.rs:77–81  ·  view source on GitHub ↗

True if a `try_lock*` error means the file lock is currently held by another process, rather than a genuine I/O failure. On Unix a contended non-blocking lock surfaces as `WouldBlock`, but on Windows the OS returns `ERROR_LOCK_VIOLATION` (code 33), which maps to `ErrorKind::Uncategorized` rather than `WouldBlock`. Comparing the raw OS error against `fs2::lock_contended_error()` handles both platf

(e: &std::io::Error)

Source from the content-addressed store, hash-verified

75/// `ErrorKind::Uncategorized` rather than `WouldBlock`. Comparing the raw OS
76/// error against `fs2::lock_contended_error()` handles both platforms.
77pub(crate) fn is_lock_contended(e: &std::io::Error) -> bool {
78 e.kind() == std::io::ErrorKind::WouldBlock
79 || (e.raw_os_error().is_some()
80 && e.raw_os_error() == fs2::lock_contended_error().raw_os_error())
81}
82
83use std::path::{Path, PathBuf};
84

Callers 3

try_turn_end_lockMethod · 0.70
with_accumulatorMethod · 0.70
save_accumulatorMethod · 0.70

Calls 1

kindMethod · 0.45

Tested by

no test coverage detected