summaryrefslogtreecommitdiffstats
path: root/vendor/fd-lock
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:20:29 +0000
commit631cd5845e8de329d0e227aaa707d7ea228b8f8f (patch)
treea1b87c8f8cad01cf18f7c5f57a08f102771ed303 /vendor/fd-lock
parentAdding debian version 1.69.0+dfsg1-1. (diff)
downloadrustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.tar.xz
rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.zip
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/fd-lock')
-rw-r--r--vendor/fd-lock/.cargo-checksum.json2
-rw-r--r--vendor/fd-lock/Cargo.toml6
-rw-r--r--vendor/fd-lock/src/read_guard.rs4
-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
-rw-r--r--vendor/fd-lock/src/write_guard.rs4
-rw-r--r--vendor/fd-lock/tests/test.rs61
8 files changed, 80 insertions, 20 deletions
diff --git a/vendor/fd-lock/.cargo-checksum.json b/vendor/fd-lock/.cargo-checksum.json
index d5827e2e6..565f4d1d8 100644
--- a/vendor/fd-lock/.cargo-checksum.json
+++ b/vendor/fd-lock/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"556675a155ffa2e1115f66998af43b009f2e9c120b710266370387e5ce8ec569","LICENSE-APACHE":"b00ec75cd7ef2a62ff1f26c0ddafbc508282d15dce149506f983ce6c8e7a4876","LICENSE-MIT":"ce688e08d0454a032063ff701c4e88051ed89f0c5c9c391cbe58e4099769ae5d","README.md":"ede6ce06722fa6bc718ef44ba9605ef1ff4f0d13551dfb648f889c2d08826f01","src/lib.rs":"1bb896e8d6be4e0a344132cd3cbfd89b08a8ee84414be2151fe1ecbdba88cb6d","src/read_guard.rs":"09dec78e58bc222b195122158c0164f5b03a0bbf4beebff3a9dfa6171cd3919b","src/rw_lock.rs":"a5360aba83a03e25d7fee58b4e56ce8e18aaa360f6458a7b45b4a9af8fc85f4f","src/sys/mod.rs":"af808ccf3e9a2e480b2113915a9018bc5698b1156eec16ced69131ff22010a04","src/sys/unix/mod.rs":"af44a486cd53b0367b2466cf4e4240ad9ebfb77274ed7dd73a8b722be9f1fb0d","src/sys/unix/read_guard.rs":"debf4cbdbbbf5d1f31b2f420e7ef85cadb56d5d63b6be0101ff60970aa23af4d","src/sys/unix/rw_lock.rs":"695cf947892b4f6cf24ed80151d485edfc3ae48d1111df7e028f1590000ce1cd","src/sys/unix/write_guard.rs":"8b1249e51aba8e6812277856cb449e27433ff14c1e761c53e43a4fc81d79324d","src/sys/unsupported/mod.rs":"da50072981243d69b2f3cd43d0d314184d9fe32f4d1f83f9d65ffa56be591d35","src/sys/unsupported/read_guard.rs":"996e4137fd5f6a4ee586d3988f399c01886a4ff517caf605b0b15b15ec1d1921","src/sys/unsupported/rw_lock.rs":"0ab0291a20cd802099e9330140ad81778f60656185df1b3bd35b1aaabcd3476d","src/sys/unsupported/utils.rs":"c0c608a32b8686f4242d3639b8d490efcfbc2385910f369e1dac741fb173e83d","src/sys/unsupported/write_guard.rs":"b2c02e43c4a939370a65ec33b949246d4486118631e1178b79d8d8c83fc59d13","src/sys/windows/mod.rs":"299c760cfd51ac2905750b29ae9662fb5c637ad43edd7f0d738955d52002faa3","src/sys/windows/read_guard.rs":"67789ae766d2e29688f1e580bccb1bd49cb046462f5b88d6cc7f5519a67d261f","src/sys/windows/rw_lock.rs":"715da53c6593d56d94e1ebd901369c7036e21ae5d43d1bea466cc289e869ecc8","src/sys/windows/utils.rs":"908f71e686f835ccddfb338fdea22e56b58685a6b90036aea60bcfa693d19f39","src/sys/windows/write_guard.rs":"e8bce84cb22476cc3468f45a278260b6299f753c91174f702cfeb86aa358f0b6","src/write_guard.rs":"67a8f4328620f2f4f5f373115cad1cb6372e56a841480f67d6a96bf6a151a9cc","tests/test.rs":"a4ac6ed7ca76556da0e324bf32b4f47dde15b9c818963f7a88f41e07bc72994b"},"package":"bb21c69b9fea5e15dbc1049e4b77145dd0ba1c84019c488102de0dc4ea4b0a27"} \ No newline at end of file
+{"files":{"Cargo.toml":"8c183b851ee565c1b50aea2b41ff378c4143f5ea5d6c5e7b1cbba5a94b217088","LICENSE-APACHE":"b00ec75cd7ef2a62ff1f26c0ddafbc508282d15dce149506f983ce6c8e7a4876","LICENSE-MIT":"ce688e08d0454a032063ff701c4e88051ed89f0c5c9c391cbe58e4099769ae5d","README.md":"ede6ce06722fa6bc718ef44ba9605ef1ff4f0d13551dfb648f889c2d08826f01","src/lib.rs":"1bb896e8d6be4e0a344132cd3cbfd89b08a8ee84414be2151fe1ecbdba88cb6d","src/read_guard.rs":"ebe8f40501456a127dfe96625cb78ed3647489a9b570c0b527cc504a9b87a3e2","src/rw_lock.rs":"a5360aba83a03e25d7fee58b4e56ce8e18aaa360f6458a7b45b4a9af8fc85f4f","src/sys/mod.rs":"af808ccf3e9a2e480b2113915a9018bc5698b1156eec16ced69131ff22010a04","src/sys/unix/mod.rs":"af44a486cd53b0367b2466cf4e4240ad9ebfb77274ed7dd73a8b722be9f1fb0d","src/sys/unix/read_guard.rs":"debf4cbdbbbf5d1f31b2f420e7ef85cadb56d5d63b6be0101ff60970aa23af4d","src/sys/unix/rw_lock.rs":"695cf947892b4f6cf24ed80151d485edfc3ae48d1111df7e028f1590000ce1cd","src/sys/unix/write_guard.rs":"8b1249e51aba8e6812277856cb449e27433ff14c1e761c53e43a4fc81d79324d","src/sys/unsupported/mod.rs":"da50072981243d69b2f3cd43d0d314184d9fe32f4d1f83f9d65ffa56be591d35","src/sys/unsupported/read_guard.rs":"996e4137fd5f6a4ee586d3988f399c01886a4ff517caf605b0b15b15ec1d1921","src/sys/unsupported/rw_lock.rs":"0ab0291a20cd802099e9330140ad81778f60656185df1b3bd35b1aaabcd3476d","src/sys/unsupported/utils.rs":"c0c608a32b8686f4242d3639b8d490efcfbc2385910f369e1dac741fb173e83d","src/sys/unsupported/write_guard.rs":"b2c02e43c4a939370a65ec33b949246d4486118631e1178b79d8d8c83fc59d13","src/sys/windows/mod.rs":"299c760cfd51ac2905750b29ae9662fb5c637ad43edd7f0d738955d52002faa3","src/sys/windows/read_guard.rs":"7d11990c5f5e16305ee62dd305eeb94494649dcba83556035336934017382bc0","src/sys/windows/rw_lock.rs":"f7afca581d24eed33f1f5163ea66830a09201c4e72b0fefffe1b186433e7fa87","src/sys/windows/utils.rs":"908f71e686f835ccddfb338fdea22e56b58685a6b90036aea60bcfa693d19f39","src/sys/windows/write_guard.rs":"a1b31035ad8a02dc62a81101698e073c930222ce4108757530c352014274a7a3","src/write_guard.rs":"84126fcfe536f51c9fd97c86c4abf0dd55ff28a165652d75f78e546331590bee","tests/test.rs":"ccf921d67af1a2197077b5a4c37d87e096f97658e5d663b4e312e133d8b4b236"},"package":"9799aefb4a2e4a01cc47610b1dd47c18ab13d991f27bbcaed9296f5a53d5cbad"} \ No newline at end of file
diff --git a/vendor/fd-lock/Cargo.toml b/vendor/fd-lock/Cargo.toml
index 8a9a4b664..d995177bf 100644
--- a/vendor/fd-lock/Cargo.toml
+++ b/vendor/fd-lock/Cargo.toml
@@ -12,7 +12,7 @@
[package]
edition = "2018"
name = "fd-lock"
-version = "3.0.8"
+version = "3.0.11"
authors = ["Yoshua Wuyts <yoshuawuyts@gmail.com>"]
description = "Advisory cross-platform lock on a file using a file descriptor to it."
documentation = "https://docs.rs/fd-lock"
@@ -41,11 +41,11 @@ version = "1.0.0"
version = "3.0.8"
[target."cfg(unix)".dependencies.rustix]
-version = "0.36.0"
+version = "0.37.0"
features = ["fs"]
[target."cfg(windows)".dependencies.windows-sys]
-version = "0.42.0"
+version = "0.45.0"
features = [
"Win32_Foundation",
"Win32_Storage_FileSystem",
diff --git a/vendor/fd-lock/src/read_guard.rs b/vendor/fd-lock/src/read_guard.rs
index 29ed06da3..50bf9d5b5 100644
--- a/vendor/fd-lock/src/read_guard.rs
+++ b/vendor/fd-lock/src/read_guard.rs
@@ -11,10 +11,6 @@ use crate::sys;
/// [`read`]: crate::RwLock::read
/// [`try_read`]: crate::RwLock::try_read
/// [`RwLock`]: crate::RwLock
-///
-/// # Panics
-///
-/// Dropping this type may panic if the lock fails to unlock.
#[must_use = "if unused the RwLock will immediately unlock"]
#[derive(Debug)]
pub struct RwLockReadGuard<'lock, T: sys::AsRaw> {
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) });
}
}
diff --git a/vendor/fd-lock/src/write_guard.rs b/vendor/fd-lock/src/write_guard.rs
index e218e3842..78a0b834d 100644
--- a/vendor/fd-lock/src/write_guard.rs
+++ b/vendor/fd-lock/src/write_guard.rs
@@ -11,10 +11,6 @@ use crate::sys;
/// [`write`]: crate::RwLock::write
/// [`try_write`]: crate::RwLock::try_write
/// [`RwLock`]: crate::RwLock
-///
-/// # Panics
-///
-/// Dropping this type may panic if the lock fails to unlock.
#[must_use = "if unused the RwLock will immediately unlock"]
#[derive(Debug)]
pub struct RwLockWriteGuard<'lock, T: sys::AsRaw> {
diff --git a/vendor/fd-lock/tests/test.rs b/vendor/fd-lock/tests/test.rs
index 35fd5b33b..dc43ae073 100644
--- a/vendor/fd-lock/tests/test.rs
+++ b/vendor/fd-lock/tests/test.rs
@@ -31,3 +31,64 @@ fn double_write_lock() {
drop(g0);
}
+
+#[test]
+fn read_and_write_lock() {
+ let dir = tempdir().unwrap();
+ let path = dir.path().join("lockfile");
+
+ let l0 = RwLock::new(File::create(&path).unwrap());
+ let mut l1 = RwLock::new(File::open(path).unwrap());
+
+ let g0 = l0.try_read().unwrap();
+
+ let err = l1.try_write().unwrap_err();
+ assert!(matches!(err.kind(), ErrorKind::WouldBlock));
+
+ drop(g0);
+}
+
+#[test]
+fn write_and_read_lock() {
+ let dir = tempdir().unwrap();
+ let path = dir.path().join("lockfile");
+
+ let mut l0 = RwLock::new(File::create(&path).unwrap());
+ let l1 = RwLock::new(File::open(path).unwrap());
+
+ let g0 = l0.try_write().unwrap();
+
+ let err = l1.try_read().unwrap_err();
+ assert!(matches!(err.kind(), ErrorKind::WouldBlock));
+
+ drop(g0);
+}
+
+#[cfg(windows)]
+mod windows {
+ use super::*;
+ use std::os::windows::fs::OpenOptionsExt;
+
+ #[test]
+ fn try_lock_error() {
+ let dir = tempdir().unwrap();
+ let path = dir.path().join("lockfile");
+
+ // On Windows, opening with an access_mode as 0 will prevent all locking operations from succeeding, simulating an I/O error.
+ let mut l0 = RwLock::new(
+ File::options()
+ .create(true)
+ .read(true)
+ .write(true)
+ .access_mode(0)
+ .open(path)
+ .unwrap(),
+ );
+
+ let err1 = l0.try_read().unwrap_err();
+ assert!(matches!(err1.kind(), ErrorKind::PermissionDenied));
+
+ let err2 = l0.try_write().unwrap_err();
+ assert!(matches!(err2.kind(), ErrorKind::PermissionDenied));
+ }
+}