Procházet zdrojové kódy

Fix Windows file locks to actually _work_

default_compile_flags
vector-of-bool před 5 roky
rodič
revize
5a38f5f6a3
1 změnil soubory, kde provedl 5 přidání a 2 odebrání
  1. +5
    -2
      src/dds/util/flock.win.cpp

+ 5
- 2
src/dds/util/flock.win.cpp Zobrazit soubor

auto lockflags = lm == exclusive ? LOCKFILE_EXCLUSIVE_LOCK : 0; auto lockflags = lm == exclusive ? LOCKFILE_EXCLUSIVE_LOCK : 0;
auto failflags = fm == nonblocking ? LOCKFILE_FAIL_IMMEDIATELY : 0; auto failflags = fm == nonblocking ? LOCKFILE_FAIL_IMMEDIATELY : 0;
auto flags = lockflags | failflags; 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) { if (!okay) {
cancellation_point(); cancellation_point();
if (::GetLastError() == ERROR_IO_PENDING) { if (::GetLastError() == ERROR_IO_PENDING) {
} }


void unlock(path_ref p) { 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) { if (!okay) {
cancellation_point(); cancellation_point();
throw std::system_error(std::error_code(::GetLastError(), std::system_category()), throw std::system_error(std::error_code(::GetLastError(), std::system_category()),

Načítá se…
Zrušit
Uložit