aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/cpp
diff options
context:
space:
mode:
authorGravatar Laszlo Csomor <laszlocsomor@google.com>2017-03-14 15:25:13 +0000
committerGravatar Yun Peng <pcloudy@google.com>2017-03-14 19:51:03 +0000
commit5fa18d12d95cd945d5ca76aba45f1b797527a95b (patch)
tree969d0ad59cc4309b4efa9b0584f44a132367bfb3 /src/main/cpp
parent6140817ad14fbc2a80c9f6e8556657d5156fb1b1 (diff)
Bazel client, Windows: can connect to fresh server
Fix the bug that the MSYS-less client couldn't connect to the freshly started server and had to be started again. Fixes https://github.com/bazelbuild/bazel/issues/2672 See https://github.com/bazelbuild/bazel/issues/2107 -- PiperOrigin-RevId: 150069285 MOS_MIGRATED_REVID=150069285
Diffstat (limited to 'src/main/cpp')
-rw-r--r--src/main/cpp/blaze_util_windows.cc13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/main/cpp/blaze_util_windows.cc b/src/main/cpp/blaze_util_windows.cc
index 5e68544317..41a99d00b7 100644
--- a/src/main/cpp/blaze_util_windows.cc
+++ b/src/main/cpp/blaze_util_windows.cc
@@ -520,6 +520,7 @@ string GetJvmVersion(const string& java_exe) {
return ReadJvmVersion(result);
}
+#ifndef COMPILER_MSVC
// If we pass DETACHED_PROCESS to CreateProcess(), cmd.exe appropriately
// returns the command prompt when the client terminates. msys2, however, in
// its infinite wisdom, waits until the *server* terminates and cannot be
@@ -528,10 +529,6 @@ string GetJvmVersion(const string& java_exe) {
// So, we first pretend to be a POSIX daemon so that msys2 knows about our
// intentions and *then* we call CreateProcess(). Life ain't easy.
static bool DaemonizeOnWindows() {
-#ifdef COMPILER_MSVC
- // TODO(bazel-team) 2016-11-18: implement this.
- return false;
-#else // not COMPILER_MSVC
if (fork() > 0) {
// We are the original client process.
return true;
@@ -548,8 +545,8 @@ static bool DaemonizeOnWindows() {
// descriptors here. CreateProcess() will take care of that and it's useful
// to see the error messages in ExecuteDaemon() on the console of the client.
return false;
-#endif // COMPILER_MSVC
}
+#endif // not COMPILER_MSVC
// Keeping an eye on the server process on Windows is not implemented yet.
// TODO(lberki): Implement this, because otherwise if we can't start up a server
@@ -564,11 +561,15 @@ class DummyBlazeServerStartup : public BlazeServerStartup {
void ExecuteDaemon(const string& exe, const std::vector<string>& args_vector,
const string& daemon_output, const string& server_dir,
BlazeServerStartup** server_startup) {
+#ifdef COMPILER_MSVC
+ *server_startup = new DummyBlazeServerStartup();
+#else // not COMPILER_MSVC
if (DaemonizeOnWindows()) {
// We are the client process
*server_startup = new DummyBlazeServerStartup();
return;
}
+#endif // COMPILER_MSVC
wstring wdaemon_output;
if (!blaze_util::AsWindowsPathWithUncPrefix(daemon_output, &wdaemon_output)) {
@@ -661,7 +662,9 @@ void ExecuteDaemon(const string& exe, const std::vector<string>& args_vector,
CloseHandle(processInfo.hProcess);
CloseHandle(processInfo.hThread);
+#ifndef COMPILER_MSVC
exit(0);
+#endif // COMPILER_MSVC
}
void BatchWaiterThread(HANDLE java_handle) {