From 5a38f5f6a3f2eb0dfc3c9ad70012e3c9f59ee3ee Mon Sep 17 00:00:00 2001 From: vector-of-bool Date: Fri, 8 Nov 2019 23:39:51 -0700 Subject: [PATCH] Fix Windows file locks to actually _work_ --- src/dds/util/flock.win.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/dds/util/flock.win.cpp b/src/dds/util/flock.win.cpp index e2a35719..0692a4ad 100644 --- a/src/dds/util/flock.win.cpp +++ b/src/dds/util/flock.win.cpp @@ -28,7 +28,9 @@ struct lock_data { auto lockflags = lm == exclusive ? LOCKFILE_EXCLUSIVE_LOCK : 0; auto failflags = fm == nonblocking ? LOCKFILE_FAIL_IMMEDIATELY : 0; auto flags = lockflags | failflags; - const auto okay = ::LockFileEx(file.get(), flags, 0, 0, 0, nullptr); + auto hndl = file.get(); + OVERLAPPED ovr = {}; + const auto okay = ::LockFileEx(hndl, flags, 0, 0, 0, &ovr); if (!okay) { cancellation_point(); if (::GetLastError() == ERROR_IO_PENDING) { @@ -41,7 +43,8 @@ struct lock_data { } void unlock(path_ref p) { - const auto okay = ::UnlockFileEx(file.get(), 0, 0, 0, nullptr); + OVERLAPPED ovr = {}; + const auto okay = ::UnlockFileEx(file.get(), 0, 0, 0, &ovr); if (!okay) { cancellation_point(); throw std::system_error(std::error_code(::GetLastError(), std::system_category()),