about summary refs log tree commit diff
path: root/src/nix-daemon
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-08-28T16·54+0200
committerEelco Dolstra <edolstra@gmail.com>2017-08-28T16·54+0200
commitcfc813239128fc69a9228b39b5c0abb7e7a67b11 (patch)
treeb6ca354a72f9ae7fc09695f1f423e252762bdfa6 /src/nix-daemon
parentfe34b91289793178323b4924ee63c9e3ed636d11 (diff)
Don't send progress messages to older clients
Diffstat (limited to 'src/nix-daemon')
-rw-r--r--src/nix-daemon/nix-daemon.cc29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/nix-daemon/nix-daemon.cc b/src/nix-daemon/nix-daemon.cc
index 65c88562cf09..9f1d619e59bf 100644
--- a/src/nix-daemon/nix-daemon.cc
+++ b/src/nix-daemon/nix-daemon.cc
@@ -84,6 +84,10 @@ struct TunnelLogger : public Logger
 
     Sync<State> state_;
 
+    unsigned int clientVersion;
+
+    TunnelLogger(unsigned int clientVersion) : clientVersion(clientVersion) { }
+
     void enqueueMsg(const std::string & s)
     {
         auto state(state_.lock());
@@ -148,6 +152,7 @@ struct TunnelLogger : public Logger
     void startActivity(ActivityId act, ActivityType type,
         const std::string & s, const Fields & fields, ActivityId parent) override
     {
+        if (GET_PROTOCOL_MINOR(clientVersion) < 20) return;
         StringSink buf;
         buf << STDERR_START_ACTIVITY << act << type << s << fields << parent;
         enqueueMsg(*buf.s);
@@ -155,6 +160,7 @@ struct TunnelLogger : public Logger
 
     void stopActivity(ActivityId act) override
     {
+        if (GET_PROTOCOL_MINOR(clientVersion) < 20) return;
         StringSink buf;
         buf << STDERR_STOP_ACTIVITY << act;
         enqueueMsg(*buf.s);
@@ -162,6 +168,7 @@ struct TunnelLogger : public Logger
 
     void result(ActivityId act, ResultType type, const Fields & fields) override
     {
+        if (GET_PROTOCOL_MINOR(clientVersion) < 20) return;
         StringSink buf;
         buf << STDERR_RESULT << act << type << fields;
         enqueueMsg(*buf.s);
@@ -710,17 +717,6 @@ static void processConnection(bool trusted)
 {
     MonitorFdHup monitor(from.fd);
 
-    auto tunnelLogger = new TunnelLogger();
-    auto prevLogger = nix::logger;
-    logger = tunnelLogger;
-
-    unsigned int opCount = 0;
-
-    Finally finally([&]() {
-        _isInterrupted = false;
-        prevLogger->log(lvlDebug, fmt("%d operations", opCount));
-    });
-
     /* Exchange the greeting. */
     unsigned int magic = readInt(from);
     if (magic != WORKER_MAGIC_1) throw Error("protocol mismatch");
@@ -731,6 +727,17 @@ static void processConnection(bool trusted)
     if (clientVersion < 0x10a)
         throw Error("the Nix client version is too old");
 
+    auto tunnelLogger = new TunnelLogger(clientVersion);
+    auto prevLogger = nix::logger;
+    logger = tunnelLogger;
+
+    unsigned int opCount = 0;
+
+    Finally finally([&]() {
+        _isInterrupted = false;
+        prevLogger->log(lvlDebug, fmt("%d operations", opCount));
+    });
+
     if (GET_PROTOCOL_MINOR(clientVersion) >= 14 && readInt(from))
         setAffinityTo(readInt(from));