flock: a bit of cleanup
This commit is contained in:
parent
50d51fb1bf
commit
5af27e4617
@ -12,6 +12,13 @@
|
||||
use crate::shims::unix::*;
|
||||
use crate::*;
|
||||
|
||||
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
||||
pub(crate) enum FlockOp {
|
||||
SharedLock { nonblocking: bool },
|
||||
ExclusiveLock { nonblocking: bool },
|
||||
Unlock,
|
||||
}
|
||||
|
||||
/// Represents an open file descriptor.
|
||||
pub trait FileDescription: std::fmt::Debug + Any {
|
||||
fn name(&self) -> &'static str;
|
||||
@ -567,10 +574,3 @@ fn write(
|
||||
Ok(Scalar::from_target_isize(this.try_unwrap_io_result(result)?, this))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
||||
pub(crate) enum FlockOp {
|
||||
SharedLock { nonblocking: bool },
|
||||
ExclusiveLock { nonblocking: bool },
|
||||
Unlock,
|
||||
}
|
||||
|
@ -198,8 +198,8 @@ fn flock<'tcx>(
|
||||
let code: u32 = err.raw_os_error().unwrap().try_into().unwrap();
|
||||
if matches!(code, ERROR_IO_PENDING | ERROR_LOCK_VIOLATION) {
|
||||
if lock_nb {
|
||||
// Replace error with a custom WouldBlock error, which later will be
|
||||
// mapped in the `helpers` module
|
||||
// The io error mapping does not know about these error codes,
|
||||
// so we translate it to `WouldBlock` manually.
|
||||
let desc = format!("LockFileEx wouldblock error: {err}");
|
||||
err = io::Error::new(io::ErrorKind::WouldBlock, desc);
|
||||
} else {
|
||||
|
@ -1,4 +1,3 @@
|
||||
// Flock tests are separate since they don't in general work on a Windows host.
|
||||
//@ignore-target-windows: File handling is not implemented yet
|
||||
//@compile-flags: -Zmiri-disable-isolation
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user