From: Joel Rosdahl Date: Thu, 13 Mar 2025 15:37:18 +0000 (+0100) Subject: fix: Fix log file locking on Windows X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1581d9a3c9f7894334aa5e0745fc4d3d3bbdacd3;p=thirdparty%2Fccache.git fix: Fix log file locking on Windows Fixes #1575. --- diff --git a/src/ccache/util/filelock.cpp b/src/ccache/util/filelock.cpp index e6874966..379afa5e 100644 --- a/src/ccache/util/filelock.cpp +++ b/src/ccache/util/filelock.cpp @@ -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));