Do not attempt to speak a newer version of the protocol

Both sides need to agree on a version (with `std::min`) for anything to
work. Somehow... we've never done this.

With this comment, the next commit succeeds. Without this commit, the
next commit fails. This is because the next commit exposes serializers
which do different things for proto version 2.7, and we're currently
requesting 2.6.

Opened https://github.com/NixOS/nix/issues/9584 to track this issue
This commit is contained in:
John Ericson 2023-12-07 14:30:44 -05:00
parent 2bd67562b5
commit b56d2383c1

View file

@ -203,7 +203,9 @@ static std::pair<Path, AutoCloseFD> openLogFile(const std::string & logDir, cons
*/
static void handshake(Machine::Connection & conn, unsigned int repeats)
{
conn.to << SERVE_MAGIC_1 << 0x206;
constexpr ServeProto::Version our_version = 0x206;
conn.to << SERVE_MAGIC_1 << our_version;
conn.to.flush();
unsigned int magic = readInt(conn.from);
@ -215,6 +217,9 @@ static void handshake(Machine::Connection & conn, unsigned int repeats)
throw Error("unsupported nix-store --serve protocol version on %1%", conn.machine->sshName);
if (GET_PROTOCOL_MINOR(conn.remoteVersion) < 3 && repeats > 0)
throw Error("machine %1% does not support repeating a build; please upgrade it to Nix 1.12", conn.machine->sshName);
// Do not attempt to speak a newer version of the protocol
conn.remoteVersion = std::min(conn.remoteVersion, our_version);
}
static BasicDerivation sendInputs(