diff options
author | 2017-06-02 13:47:28 +0200 | |
---|---|---|
committer | 2017-06-02 15:27:25 +0200 | |
commit | 956810b6ee24289e457a4b8d0a84ff56eb32c264 (patch) | |
tree | fa8f94d135f284e12096599011424cb43ab1d4f9 /src | |
parent | 171314b2ef9a7fd361a889b88dea20b493d77bf7 (diff) |
Windows, jvm.out: create with deletion sharing
This allows `bazel clean` to delete this file.
See https://github.com/bazelbuild/bazel/issues/1586
See https://github.com/bazelbuild/bazel/issues/1906
See https://github.com/bazelbuild/bazel/issues/2480
See https://github.com/bazelbuild/bazel/issues/3043
Change-Id: I245f368c2f2564511bbe6f06193a3ead49724d7b
PiperOrigin-RevId: 157818284
Diffstat (limited to 'src')
-rw-r--r-- | src/main/cpp/blaze_util_windows.cc | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/src/main/cpp/blaze_util_windows.cc b/src/main/cpp/blaze_util_windows.cc index 38b0f1690b..fb4f3ecb85 100644 --- a/src/main/cpp/blaze_util_windows.cc +++ b/src/main/cpp/blaze_util_windows.cc @@ -447,11 +447,6 @@ static void CreateCommandLine(CmdLine* result, const string& exe, cmdline << '\"'; } - // TODO(bazel-team): get rid of the code to append character by character, - // because each time a new buffer is allocated and the old one copied, so - // this means N allocations (of O(N) size each) and N copies. - // If possible, get rid of the whole CreateCommandLine method and do the - // logic on the caller side. std::string::const_iterator it = s.begin(); while (it != s.end()) { char ch = *it++; @@ -497,7 +492,6 @@ static void CreateCommandLine(CmdLine* result, const string& exe, } // namespace string GetJvmVersion(const string& java_exe) { - // TODO(bazel-team): implement IPipe for Windows and use that here. HANDLE pipe_read, pipe_write; SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE}; @@ -634,17 +628,12 @@ static HANDLE CreateJvmOutputFile(const wstring& path, HANDLE handle = ::CreateFileW( /* lpFileName */ path.c_str(), /* dwDesiredAccess */ GENERIC_READ | GENERIC_WRITE, - // TODO(laszlocsomor): add FILE_SHARE_DELETE, that allows deleting - // jvm.out and maybe fixes - // https://github.com/bazelbuild/bazel/issues/2326 . Unfortunately - // however if a file that we opened with FILE_SHARE_DELETE is deleted - // while its still open, write operations will still succeed but have no - // effect, the file won't be recreated. (I haven't tried what happens - // with read operations.) - // - // FILE_SHARE_READ: So that the file can be read while the server is - // running - /* dwShareMode */ FILE_SHARE_READ, + // Share for reading and also for deletion, so `bazel clean + // --expunge/--expunge_async` can delete this file while the JVM holds + // an open file descriptor to it (via stdout). Although subsequent + // writes would not recreate the file after it's deleted, this is fine + // because --expunge/--expunge_async shut down the Bazel server. + /* dwShareMode */ FILE_SHARE_READ | FILE_SHARE_DELETE, /* lpSecurityAttributes */ sa, /* dwCreationDisposition */ CREATE_ALWAYS, /* dwFlagsAndAttributes */ FILE_ATTRIBUTE_NORMAL, |