Skip to content

Commit 2658c01

Browse files
committed
windows: don't error if unlocking and path isn't locked
Ideally we would, but we're only locking on part of the file so I think we're getting an error when trying to unlock both parts. Maybe we can change to two unlock calls, then boolean OR the results together.
1 parent 2cb0ddf commit 2658c01

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/libstore/windows/pathlocks.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ bool lockFile(Descriptor desc, LockType lockType, bool wait)
5959
OVERLAPPED ov = {0};
6060
if (!UnlockFileEx(desc, 0, 2, 0, &ov)) {
6161
WinError winError("Failed to unlock file desc %s", desc);
62-
throw winError;
62+
// TODO: Not sure this is correct.
63+
// But I have a feeling that because we're trying to release a lock
64+
// on both read AND write, when only one has been taken at a time,
65+
// we get the "not locked" error. But does that mean we're not
66+
// unlocking at all?
67+
if (winError.lastError != ERROR_NOT_LOCKED)
68+
throw winError;
6369
}
6470
return true;
6571
}

0 commit comments

Comments
 (0)