aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/cpp
diff options
context:
space:
mode:
authorGravatar Lukacs Berki <lberki@google.com>2016-09-09 09:23:36 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-09-09 14:16:43 +0000
commit4de9894021d98d74512324f50e0b99a2f9086ebe (patch)
tree67e47061a7ea877562f1d9e4da91f1722bc67b65 /src/main/cpp
parente7e55bb3ab5ab4f3d81cdae2635f08a3772e20b5 (diff)
Various minor fixes in the client:
- Don't call setrlimit() (it was needed to make 32-bit JVMs work with >3GB heaps) - Remove a non-functional way to tweak the Linux scheduler - Cosmetic fixes -- MOS_MIGRATED_REVID=132653426
Diffstat (limited to 'src/main/cpp')
-rw-r--r--src/main/cpp/blaze.cc31
-rw-r--r--src/main/cpp/blaze_util.cc4
-rw-r--r--src/main/cpp/blaze_util_linux.cc13
3 files changed, 7 insertions, 41 deletions
diff --git a/src/main/cpp/blaze.cc b/src/main/cpp/blaze.cc
index 833d9087e2..25eae2f166 100644
--- a/src/main/cpp/blaze.cc
+++ b/src/main/cpp/blaze.cc
@@ -1510,14 +1510,10 @@ static ATTRIBUTE_NORETURN void SendServerRequest(BlazeServer* server) {
StartServerAndConnect(server);
}
- // Check for deleted server cwd:
+ // Check for the case when the workspace directory deleted and then gets
+ // recreated while the server is running
+
string server_cwd = GetProcessCWD(globals->server_pid);
- // TODO(bazel-team): Is this check even necessary? If someone deletes or
- // moves the server directory, the client cannot connect to the server
- // anymore. IOW, the client finds the server based on the output base,
- // so if a server is found, it should be by definition at the correct output
- // base.
- //
// If server_cwd is empty, GetProcessCWD failed. This notably occurs when
// running under Docker because then readlink(/proc/[pid]/cwd) returns
// EPERM.
@@ -1722,26 +1718,6 @@ static void SetupStreams() {
if (fcntl(2, F_GETFL) == -1) open("/dev/null", O_WRONLY);
}
-// Set an 8MB stack for Blaze. When the stack max is unbounded, it changes the
-// layout in the JVM's address space, and we are unable to instantiate the
-// default 3000MB heap.
-static void EnsureFiniteStackLimit() {
- struct rlimit limit;
- const int default_stack = 8 * 1024 * 1024; // 8MB.
- if (getrlimit(RLIMIT_STACK, &limit)) {
- pdie(blaze_exit_code::LOCAL_ENVIRONMENTAL_ERROR, "getrlimit() failed");
- }
-
- if (default_stack < limit.rlim_cur) {
- limit.rlim_cur = default_stack;
- if (setrlimit(RLIMIT_STACK, &limit)) {
- perror("setrlimit() failed: If the stack limit is too high, "
- "this can cause the JVM to be unable to allocate enough "
- "contiguous address space for its heap");
- }
- }
-}
-
static void CheckBinaryPath(const string& argv0) {
if (argv0[0] == '/') {
globals->binary_path = argv0;
@@ -1842,7 +1818,6 @@ int Main(int argc, const char *argv[], OptionProcessor *option_processor) {
globals->command_wait_time = blaze_server->AcquireLock();
WarnFilesystemType(globals->options->output_base);
- EnsureFiniteStackLimit();
ExtractData(self_path);
VerifyJavaVersionAndSetJvm();
diff --git a/src/main/cpp/blaze_util.cc b/src/main/cpp/blaze_util.cc
index 84c69a899f..6ba27b5165 100644
--- a/src/main/cpp/blaze_util.cc
+++ b/src/main/cpp/blaze_util.cc
@@ -421,9 +421,7 @@ uint64_t AcquireLock(const string& output_base, bool batch_mode, bool block,
}
// Identify ourselves in the lockfile.
- if (ftruncate(lockfd, 0)) {
- // Placate the compiler.
- }
+ (void) ftruncate(lockfd, 0);
const char *tty = ttyname(STDIN_FILENO); // NOLINT (single-threaded)
string msg = "owner=launcher\npid="
+ ToString(getpid()) + "\ntty=" + (tty ? tty : "") + "\n";
diff --git a/src/main/cpp/blaze_util_linux.cc b/src/main/cpp/blaze_util_linux.cc
index b94b79fae8..4bc2224dc9 100644
--- a/src/main/cpp/blaze_util_linux.cc
+++ b/src/main/cpp/blaze_util_linux.cc
@@ -14,6 +14,7 @@
#include <errno.h> // errno, ENAMETOOLONG
#include <limits.h>
+#include <linux/magic.h>
#include <pwd.h>
#include <signal.h>
#include <stdio.h>
@@ -72,7 +73,7 @@ void WarnFilesystemType(const string& output_base) {
return;
}
- if (buf.f_type == 0x00006969) { // NFS_SUPER_MAGIC
+ if (buf.f_type == NFS_SUPER_MAGIC) {
fprintf(stderr, "WARNING: Output base '%s' is on NFS. This may lead "
"to surprising failures and undetermined behavior.\n",
output_base.c_str());
@@ -117,14 +118,6 @@ uint64_t ProcessClock() {
}
void SetScheduling(bool batch_cpu_scheduling, int io_nice_level) {
- // Move ourself into a low priority CPU scheduling group if the
- // machine is configured appropriately. Fail silently, because this
- // isn't available on all kernels.
- if (FILE *f = fopen("/dev/cgroup/cpu/batch/tasks", "w")) {
- fprintf(f, "%d", getpid());
- fclose(f);
- }
-
if (batch_cpu_scheduling) {
sched_param param = {};
param.sched_priority = 0;
@@ -280,7 +273,7 @@ bool KillServerProcess(
&recorded_start_time);
// start time file got deleted, but PID file didn't. This is strange.
- // Assume that this is an old Blaze process that doesn't know how to write
+ // Assume that this is an old Blaze process that doesn't know how to write
// start time files yet.
if (file_present && recorded_start_time != start_time) {
// This is a different process.