summaryrefslogtreecommitdiffstats
path: root/vendor/fd-lock/src/sys/windows
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:39 +0000
commit1376c5a617be5c25655d0d7cb63e3beaa5a6e026 (patch)
tree3bb8d61aee02bc7a15eab3f36e3b921afc2075d0 /vendor/fd-lock/src/sys/windows
parentReleasing progress-linux version 1.69.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.tar.xz
rustc-1376c5a617be5c25655d0d7cb63e3beaa5a6e026.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/fd-lock/src/sys/windows')
-rw-r--r--vendor/fd-lock/src/sys/windows/read_guard.rs3
-rw-r--r--vendor/fd-lock/src/sys/windows/rw_lock.rs17
-rw-r--r--vendor/fd-lock/src/sys/windows/write_guard.rs3
3 files changed, 15 insertions, 8 deletions
diff --git a/vendor/fd-lock/src/sys/windows/read_guard.rs b/vendor/fd-lock/src/sys/windows/read_guard.rs
index 28f09bb95..98a2e2c9b 100644
--- a/vendor/fd-lock/src/sys/windows/read_guard.rs
+++ b/vendor/fd-lock/src/sys/windows/read_guard.rs
@@ -25,7 +25,6 @@ impl<T: AsRawHandle> Drop for RwLockReadGuard<'_, T> {
#[inline]
fn drop(&mut self) {
let handle = self.lock.inner.as_raw_handle() as HANDLE;
- syscall(unsafe { UnlockFile(handle, 0, 0, 1, 0) })
- .expect("Could not unlock the file descriptor");
+ let _ = syscall(unsafe { UnlockFile(handle, 0, 0, 1, 0) });
}
}
diff --git a/vendor/fd-lock/src/sys/windows/rw_lock.rs b/vendor/fd-lock/src/sys/windows/rw_lock.rs
index 778b79100..02723e6e4 100644
--- a/vendor/fd-lock/src/sys/windows/rw_lock.rs
+++ b/vendor/fd-lock/src/sys/windows/rw_lock.rs
@@ -1,6 +1,7 @@
use std::io::{self, Error, ErrorKind};
use std::os::windows::io::AsRawHandle;
+use windows_sys::Win32::Foundation::ERROR_LOCK_VIOLATION;
use windows_sys::Win32::Foundation::HANDLE;
use windows_sys::Win32::Storage::FileSystem::{
LockFileEx, LOCKFILE_EXCLUSIVE_LOCK, LOCKFILE_FAIL_IMMEDIATELY,
@@ -36,8 +37,12 @@ impl<T: AsRawHandle> RwLock<T> {
let overlapped = Overlapped::zero();
let flags = LOCKFILE_FAIL_IMMEDIATELY;
- syscall(unsafe { LockFileEx(handle, flags, 0, 1, 0, overlapped.raw()) })
- .map_err(|_| Error::from(ErrorKind::WouldBlock))?;
+ syscall(unsafe { LockFileEx(handle, flags, 0, 1, 0, overlapped.raw()) }).map_err(
+ |error| match error.raw_os_error().map(|error_code| error_code as u32) {
+ Some(ERROR_LOCK_VIOLATION) => Error::from(ErrorKind::WouldBlock),
+ _ => error,
+ },
+ )?;
Ok(RwLockReadGuard { lock: self })
}
@@ -57,8 +62,12 @@ impl<T: AsRawHandle> RwLock<T> {
let overlapped = Overlapped::zero();
let flags = LOCKFILE_FAIL_IMMEDIATELY | LOCKFILE_EXCLUSIVE_LOCK;
- syscall(unsafe { LockFileEx(handle, flags, 0, 1, 0, overlapped.raw()) })
- .map_err(|_| Error::from(ErrorKind::WouldBlock))?;
+ syscall(unsafe { LockFileEx(handle, flags, 0, 1, 0, overlapped.raw()) }).map_err(
+ |error| match error.raw_os_error().map(|error_code| error_code as u32) {
+ Some(ERROR_LOCK_VIOLATION) => Error::from(ErrorKind::WouldBlock),
+ _ => error,
+ },
+ )?;
Ok(RwLockWriteGuard { lock: self })
}
diff --git a/vendor/fd-lock/src/sys/windows/write_guard.rs b/vendor/fd-lock/src/sys/windows/write_guard.rs
index 5494bd99e..ec66049a8 100644
--- a/vendor/fd-lock/src/sys/windows/write_guard.rs
+++ b/vendor/fd-lock/src/sys/windows/write_guard.rs
@@ -32,7 +32,6 @@ impl<T: AsRawHandle> Drop for RwLockWriteGuard<'_, T> {
#[inline]
fn drop(&mut self) {
let handle = self.lock.inner.as_raw_handle() as HANDLE;
- syscall(unsafe { UnlockFile(handle, 0, 0, 1, 0) })
- .expect("Could not unlock the file descriptor");
+ let _ = syscall(unsafe { UnlockFile(handle, 0, 0, 1, 0) });
}
}