]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
fix: Fix log file locking on Windows
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 13 Mar 2025 15:37:18 +0000 (16:37 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 15 Mar 2025 12:54:53 +0000 (13:54 +0100)
Fixes #1575.

src/ccache/util/filelock.cpp

index e6874966f8be207663aab0297e3bcdc74f19aa21..379afa5ef27ebfd49113e8ffa8d607b8fd9d9e10 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2024 Joel Rosdahl and other contributors
+// Copyright (C) 2024-2025 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -64,7 +64,11 @@ FileLock::acquire()
   if (handle == INVALID_HANDLE_VALUE) {
     return false;
   }
-  m_acquired = LockFile(handle, 0, 0, MAXDWORD, MAXDWORD) != 0;
+  OVERLAPPED overlapped{};
+  m_acquired =
+    LockFileEx(
+      handle, LOCKFILE_EXCLUSIVE_LOCK, 0, MAXDWORD, MAXDWORD, &overlapped)
+    != 0;
 #else
   struct flock lock;
   memset(&lock, 0, sizeof(lock));