aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Klaus Aehlig <aehlig@google.com>2016-07-11 12:19:07 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-07-11 12:25:08 +0000
commita3381b6ac136a0cab3ba86020c739fe16b42cee9 (patch)
treeeb5582712fbc935f2f99c9864bbd24b88c5827cf
parent276a8cd19d4cde6245ed3323cee695e7834a0b9d (diff)
Fix default for temporary directories to honor TMPDIR
...and only use the hard-coded "/tmp" as default for the default. Note that is unchanged that blaze.rpcserver.tmpdir still overrides. -- Change-Id: I2ad6b9904b7cde3917968090e85cf2d6c8ad88ab Reviewed-on: https://bazel-review.googlesource.com/#/c/3962 MOS_MIGRATED_REVID=127076270
-rw-r--r--src/main/java/com/google/devtools/build/lib/server/AfUnixServer.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/server/AfUnixServer.java b/src/main/java/com/google/devtools/build/lib/server/AfUnixServer.java
index f615d04cd7..8c5d316210 100644
--- a/src/main/java/com/google/devtools/build/lib/server/AfUnixServer.java
+++ b/src/main/java/com/google/devtools/build/lib/server/AfUnixServer.java
@@ -329,7 +329,14 @@ public final class AfUnixServer extends RPCServer {
// (All this extra complexity is just used in tests... *sigh*).
if (socketFile.toString().length() >= 104) { // = UNIX_PATH_MAX
Path socketLink = socketFile;
- String tmpDir = System.getProperty("blaze.rpcserver.tmpdir", "/tmp");
+ String tmpDirDefault = System.getenv("TMPDIR");
+ if (tmpDirDefault == null
+ || tmpDirDefault.length() > 104 - "/blaze-4294967296/server.socket".length()) {
+ // Default for unset TMPDIR, or if TMPDIR is so that the resulting
+ // path would be too long.
+ tmpDirDefault = "/tmp";
+ }
+ String tmpDir = System.getProperty("blaze.rpcserver.tmpdir", tmpDirDefault);
socketFile = createTempSocketDirectory(socketFile.getRelative(tmpDir)).
getRelative("server.socket");
LOG.info("Using symlinked socket at " + socketFile);