diff options
author | laszlocsomor <laszlocsomor@google.com> | 2017-04-12 10:08:16 +0000 |
---|---|---|
committer | Jakob Buchgraber <buchgr@google.com> | 2017-04-13 09:24:10 +0200 |
commit | ade79a73e74be24d0cd287c58ba1c808289f4317 (patch) | |
tree | 2aa918826c8cc25dc5dd97e205e2cd78df01ba1c /src/main/native | |
parent | 65a15eda1b077827e3f70df01f5cfe2ddc96ea59 (diff) |
Bazel client, Windows: impl. client-level locking
Implement blaze::AcquireLock and ReleaseLock.
These methods implement the Bazel client-level
locking, whose purpose is to detect concurrently
running Bazel instances attempting to write to the
same output directory.
The Bazel server also detects this case (see
BlazeCommandDispatcher) but the client needs to
start the server first, meaning this cannot detect
races between clients that are in the middle of
installing.
You can see this locking in effect if you run
`bazel --output_user_root=/c/foo build src:bazel`
in one terminal, then run
`bazel --output_user_root=/c/foo help` in another
but the same working directory. The
second one will say "Another command is running."
See https://github.com/bazelbuild/bazel/issues/2107
See https://github.com/bazelbuild/bazel/issues/2647
RELNOTES: none
PiperOrigin-RevId: 152919185
Diffstat (limited to 'src/main/native')
-rw-r--r-- | src/main/native/windows_util.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/main/native/windows_util.h b/src/main/native/windows_util.h index d34211f551..05644675d5 100644 --- a/src/main/native/windows_util.h +++ b/src/main/native/windows_util.h @@ -41,6 +41,12 @@ struct AutoHandle { bool IsValid() { return handle != INVALID_HANDLE_VALUE && handle != NULL; } + AutoHandle& operator=(const HANDLE& rhs) { + ::CloseHandle(handle); + handle = rhs; + return *this; + } + operator HANDLE() const { return handle; } HANDLE handle; |