Remove unnecessary handling of ERROR_IO_PENDING
try_lock() and try_lock_shared() do not need to handle these per the discussion in https://github.com/rust-lang/rust/pull/140718#discussion_r2076678485
This commit is contained in:
parent
1a95cc6f9d
commit
9febbf8270
2 changed files with 24 additions and 8 deletions
|
|
@ -366,6 +366,28 @@ fn file_lock_blocking_async() {
|
|||
t.join().unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(windows)]
|
||||
fn file_try_lock_async() {
|
||||
const FILE_FLAG_OVERLAPPED: u32 = 0x40000000;
|
||||
|
||||
let tmpdir = tmpdir();
|
||||
let filename = &tmpdir.join("file_try_lock_async.txt");
|
||||
let f1 = check!(File::create(filename));
|
||||
let f2 =
|
||||
check!(OpenOptions::new().custom_flags(FILE_FLAG_OVERLAPPED).write(true).open(filename));
|
||||
|
||||
// Check that shared locks block exclusive locks
|
||||
check!(f1.lock_shared());
|
||||
assert_matches!(f2.try_lock(), Err(TryLockError::WouldBlock));
|
||||
check!(f1.unlock());
|
||||
|
||||
// Check that exclusive locks block all locks
|
||||
check!(f1.lock());
|
||||
assert_matches!(f2.try_lock(), Err(TryLockError::WouldBlock));
|
||||
assert_matches!(f2.try_lock_shared(), Err(TryLockError::WouldBlock));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn file_test_io_seek_shakedown() {
|
||||
// 01234567890123
|
||||
|
|
|
|||
|
|
@ -415,10 +415,7 @@ impl File {
|
|||
|
||||
match result {
|
||||
Ok(_) => Ok(()),
|
||||
Err(err)
|
||||
if err.raw_os_error() == Some(c::ERROR_IO_PENDING as i32)
|
||||
|| err.raw_os_error() == Some(c::ERROR_LOCK_VIOLATION as i32) =>
|
||||
{
|
||||
Err(err) if err.raw_os_error() == Some(c::ERROR_LOCK_VIOLATION as i32) => {
|
||||
Err(TryLockError::WouldBlock)
|
||||
}
|
||||
Err(err) => Err(TryLockError::Error(err)),
|
||||
|
|
@ -440,10 +437,7 @@ impl File {
|
|||
|
||||
match result {
|
||||
Ok(_) => Ok(()),
|
||||
Err(err)
|
||||
if err.raw_os_error() == Some(c::ERROR_IO_PENDING as i32)
|
||||
|| err.raw_os_error() == Some(c::ERROR_LOCK_VIOLATION as i32) =>
|
||||
{
|
||||
Err(err) if err.raw_os_error() == Some(c::ERROR_LOCK_VIOLATION as i32) => {
|
||||
Err(TryLockError::WouldBlock)
|
||||
}
|
||||
Err(err) => Err(TryLockError::Error(err)),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue