Skip to content

Commit b9db125

Browse files
committed
A lock another holder has is 'again', not an input-output failure
⚠️⚠️ THE TRANSLATION TABLE HAD NO ENTRY FOR A LOCK CONFLICT, because nothing in this implementation took a lock until openkal 0.10. `kal_fs_lock' without KAL_LOCK_WAIT reports `kal_err_again' where the range is held --- that is the answer a caller POLLS UPON, and openkal says so. Without the entry, `ERROR_LOCK_VIOLATION' fell to the default arm and became `kal_err_io': a failure of the DEVICE rather than a conflict with another holder. A caller reading that stops; a caller reading `again' retries. ⭐ IT IS DISTINCT FROM `ERROR_SHARING_VIOLATION', WHICH STAYS `permission'. That one is a conflict over how a file was OPENED and is not resolved by asking again. Two errors that look adjacent and mean opposite things for a caller. Found by the specification's own conformance suite, on the observation added with the operation --- which is the argument for adding the observation with the operation.
1 parent bdd0794 commit b9db125

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/win.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@ int translate_win32(unsigned long e) {
5555
case ERROR_ALREADY_EXISTS: return kal_err_exists;
5656
case ERROR_DIR_NOT_EMPTY: return kal_err_not_empty;
5757
case ERROR_DIRECTORY: return kal_err_not_directory;
58+
// ⚠️⚠️ A LOCK THAT ANOTHER HOLDER HAS IS `AGAIN' AND NOT AN
59+
// INPUT-OUTPUT FAILURE, and this line is missing from every earlier
60+
// release because nothing here took a lock until openkal 0.10.
61+
//
62+
// `kal_fs_lock' without KAL_LOCK_WAIT reports kal_err_again where the
63+
// range is held, which is the answer a caller POLLS UPON. Falling to
64+
// the arm below would have reported kal_err_io --- a failure of the
65+
// device rather than a conflict with another holder --- and a caller
66+
// reading that would stop rather than retry.
67+
//
68+
// ⭐ It is distinct from ERROR_SHARING_VIOLATION above, which stays
69+
// `permission': that one is a conflict over how a file was OPENED and
70+
// is not resolved by asking again.
71+
case ERROR_LOCK_VIOLATION: return kal_err_again;
5872
case ERROR_IO_PENDING: return kal_err_again;
5973
default: return kal_err_io;
6074
}

src/win32.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ enum : DWORD {
216216
ERROR_OUTOFMEMORY = 14,
217217
ERROR_WRITE_PROTECT = 19,
218218
ERROR_SHARING_VIOLATION = 32,
219+
ERROR_LOCK_VIOLATION = 33,
219220
ERROR_HANDLE_EOF = 38,
220221
ERROR_HANDLE_DISK_FULL = 39,
221222
ERROR_NOT_SUPPORTED = 50,

0 commit comments

Comments
 (0)