about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2015-10-06T15·33+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-10-06T15·33+0200
commit1abda8e17311fbfc27b751b90aff4f691f496b0f (patch)
treef5ea0a3faa048610cffddcebfa0ee9f022a21440
parent9ffc4f4363d9596e2477645eab94e4140cd47c19 (diff)
nix-store --serve: Implement log size limit
-rw-r--r--src/libstore/build.cc3
-rw-r--r--src/libstore/store-api.hh3
-rw-r--r--src/nix-store/nix-store.cc4
-rw-r--r--src/nix-store/serve-protocol.hh2
4 files changed, 8 insertions, 4 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 70278a8785d6..3adad662d072 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -2854,7 +2854,8 @@ void DerivationGoal::handleChildOutput(int fd, const string & data)
             printMsg(lvlError,
                 format("%1% killed after writing more than %2% bytes of log output")
                 % getName() % settings.maxLogSize);
-            timedOut(); // not really a timeout, but close enough
+            killChild();
+            done(BuildResult::LogLimitExceeded);
             return;
         }
         if (verbosity >= settings.buildVerbosity)
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index 235017503213..485209d7a8b7 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -112,7 +112,8 @@ struct BuildResult
         CachedFailure,
         TimedOut,
         MiscFailure,
-        DependencyFailed
+        DependencyFailed,
+        LogLimitExceeded,
     } status = MiscFailure;
     std::string errorMsg;
     //time_t startTime = 0, stopTime = 0;
diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc
index d541b7b7d00a..89518bfb1bd3 100644
--- a/src/nix-store/nix-store.cc
+++ b/src/nix-store/nix-store.cc
@@ -853,7 +853,7 @@ static void opServe(Strings opFlags, Strings opArgs)
     if (magic != SERVE_MAGIC_1) throw Error("protocol mismatch");
     out << SERVE_MAGIC_2 << SERVE_PROTOCOL_VERSION;
     out.flush();
-    readInt(in); // Client version, unused for now
+    unsigned int clientVersion = readInt(in);
 
     auto getBuildSettings = [&]() {
         // FIXME: changing options here doesn't work if we're
@@ -863,6 +863,8 @@ static void opServe(Strings opFlags, Strings opArgs)
         settings.useSubstitutes = false;
         settings.maxSilentTime = readInt(in);
         settings.buildTimeout = readInt(in);
+        if (GET_PROTOCOL_MINOR(clientVersion) >= 2)
+            settings.maxLogSize = readInt(in);
     };
 
     while (true) {
diff --git a/src/nix-store/serve-protocol.hh b/src/nix-store/serve-protocol.hh
index f7f151d4603f..c4e2a370300b 100644
--- a/src/nix-store/serve-protocol.hh
+++ b/src/nix-store/serve-protocol.hh
@@ -5,7 +5,7 @@ namespace nix {
 #define SERVE_MAGIC_1 0x390c9deb
 #define SERVE_MAGIC_2 0x5452eecb
 
-#define SERVE_PROTOCOL_VERSION 0x201
+#define SERVE_PROTOCOL_VERSION 0x202
 #define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00)
 #define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff)