diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-08-28 18:54:23 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-08-28 18:54:23 +0200 |
commit | cfc813239128fc69a9228b39b5c0abb7e7a67b11 (patch) | |
tree | b6ca354a72f9ae7fc09695f1f423e252762bdfa6 /src | |
parent | fe34b91289793178323b4924ee63c9e3ed636d11 (diff) |
Don't send progress messages to older clients
Diffstat (limited to 'src')
-rw-r--r-- | src/libstore/worker-protocol.hh | 2 | ||||
-rw-r--r-- | src/nix-daemon/nix-daemon.cc | 29 |
2 files changed, 19 insertions, 12 deletions
diff --git a/src/libstore/worker-protocol.hh b/src/libstore/worker-protocol.hh index 9daeb46ad..996e1d253 100644 --- a/src/libstore/worker-protocol.hh +++ b/src/libstore/worker-protocol.hh @@ -6,7 +6,7 @@ namespace nix { #define WORKER_MAGIC_1 0x6e697863 #define WORKER_MAGIC_2 0x6478696f -#define PROTOCOL_VERSION 0x113 +#define PROTOCOL_VERSION 0x114 #define GET_PROTOCOL_MAJOR(x) ((x) & 0xff00) #define GET_PROTOCOL_MINOR(x) ((x) & 0x00ff) diff --git a/src/nix-daemon/nix-daemon.cc b/src/nix-daemon/nix-daemon.cc index 65c88562c..9f1d619e5 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)); |