aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/cpp/blaze_util_posix.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/cpp/blaze_util_posix.cc')
-rw-r--r--src/main/cpp/blaze_util_posix.cc14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/main/cpp/blaze_util_posix.cc b/src/main/cpp/blaze_util_posix.cc
index 947faba021..139fc21ade 100644
--- a/src/main/cpp/blaze_util_posix.cc
+++ b/src/main/cpp/blaze_util_posix.cc
@@ -622,7 +622,7 @@ uint64_t AcquireLock(const string& output_base, bool batch_mode, bool block,
// ones) mention that the Blaze invocation hangs on a non-existent PID. This
// should help troubleshoot those scenarios in case there really is a bug
// somewhere.
- size_t attempts = 0;
+ bool multiple_attempts = false;
string owner;
const uint64_t start_time = GetMillisecondsMonotonic();
while (setlk(lockfd, &lock) == -1) {
@@ -636,13 +636,10 @@ uint64_t AcquireLock(const string& output_base, bool batch_mode, bool block,
if (owner != buffer) {
// Each time we learn a new lock owner, print it out.
owner = buffer;
- if (attempts > 0) {
- fprintf(stderr, " client lock owner changed\n");
- }
fprintf(stderr, "Another command holds the client lock: \n%s\n",
owner.c_str());
if (block) {
- fprintf(stderr, "Waiting for it to complete...");
+ fprintf(stderr, "Waiting for it to complete...\n");
fflush(stderr);
}
}
@@ -653,10 +650,7 @@ uint64_t AcquireLock(const string& output_base, bool batch_mode, bool block,
}
TrySleep(500);
- attempts += 1;
- }
- if (attempts > 0) {
- fprintf(stderr, " done!\n");
+ multiple_attempts = true;
}
const uint64_t end_time = GetMillisecondsMonotonic();
@@ -664,7 +658,7 @@ uint64_t AcquireLock(const string& output_base, bool batch_mode, bool block,
// avoid unnecessary noise in the logs. In this metric, we are only
// interested in knowing how long it took for other commands to complete, not
// how fast acquiring a lock is.
- const uint64_t wait_time = attempts == 0 ? 0 : end_time - start_time;
+ const uint64_t wait_time = !multiple_attempts ? 0 : end_time - start_time;
// Identify ourselves in the lockfile.
// The contents are printed for human consumption when another client