libtuil: remove deserializing operator>>
they will not work well with async deserialization and are not used consistently anyway. just like the serializing operator<< these are protocol stability hazards: changing the type of a field influences the wire protocol layout and type constraints, which is not amazing Change-Id: I54b20a133048f4ca15a9fb0f4d8b94dc78f62d89
This commit is contained in:
@@ -17,8 +17,11 @@
|
||||
#include "graphml.hh"
|
||||
#include "lix/libcmd/legacy.hh"
|
||||
#include "lix/libstore/path-with-outputs.hh"
|
||||
#include "lix/libutil/serialise.hh"
|
||||
#include "nix-store.hh"
|
||||
|
||||
#include <cstdint>
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1067,7 +1070,9 @@ opServe(std::shared_ptr<Store> store, AsyncIoRoot & aio, Strings opFlags, String
|
||||
if (deriver != "")
|
||||
info.deriver = store->parseStorePath(deriver);
|
||||
info.references = ServeProto::Serialise<StorePathSet>::read(rconn);
|
||||
in >> info.registrationTime >> info.narSize >> info.ultimate;
|
||||
info.registrationTime = readNum<time_t>(in);
|
||||
info.narSize = readNum<uint64_t>(in);
|
||||
info.ultimate = readBool(in);
|
||||
info.sigs = readStrings<StringSet>(in);
|
||||
info.ca = ContentAddress::parseOpt(readString(in));
|
||||
|
||||
|
||||
+15
-9
@@ -13,10 +13,13 @@
|
||||
#include "lix/libutil/finally.hh"
|
||||
#include "lix/libutil/archive.hh"
|
||||
#include "lix/libstore/derivations.hh"
|
||||
#include "lix/libutil/serialise.hh"
|
||||
#include "lix/libutil/strings.hh"
|
||||
#include "lix/libutil/args.hh"
|
||||
|
||||
#include <boost/core/demangle.hpp>
|
||||
#include <cstdint>
|
||||
#include <ctime>
|
||||
#include <sstream>
|
||||
|
||||
namespace nix::daemon {
|
||||
@@ -364,8 +367,7 @@ static void performOp(AsyncIoRoot & aio, TunnelLogger * logger, ref<Store> store
|
||||
auto name = readString(from);
|
||||
auto camStr = readString(from);
|
||||
auto refs = WorkerProto::Serialise<StorePathSet>::read(rconn);
|
||||
bool repairBool;
|
||||
from >> repairBool;
|
||||
bool repairBool = readBool(from);
|
||||
auto repair = RepairFlag{repairBool};
|
||||
|
||||
logger->startWork();
|
||||
@@ -401,8 +403,8 @@ static void performOp(AsyncIoRoot & aio, TunnelLogger * logger, ref<Store> store
|
||||
}
|
||||
|
||||
case WorkerProto::Op::AddMultipleToStore: {
|
||||
bool repair, dontCheckSigs;
|
||||
from >> repair >> dontCheckSigs;
|
||||
bool repair = readBool(from);
|
||||
bool dontCheckSigs = readBool(from);
|
||||
if (!trusted && dontCheckSigs)
|
||||
dontCheckSigs = false;
|
||||
|
||||
@@ -607,7 +609,8 @@ static void performOp(AsyncIoRoot & aio, TunnelLogger * logger, ref<Store> store
|
||||
GCOptions options;
|
||||
options.action = (GCOptions::GCAction) readInt(from);
|
||||
options.pathsToDelete = WorkerProto::Serialise<StorePathSet>::read(rconn);
|
||||
from >> options.ignoreLiveness >> options.maxFreed;
|
||||
options.ignoreLiveness = readBool(from);
|
||||
options.maxFreed = readNum<uint64_t>(from);
|
||||
// obsolete fields
|
||||
readInt(from);
|
||||
readInt(from);
|
||||
@@ -722,8 +725,8 @@ static void performOp(AsyncIoRoot & aio, TunnelLogger * logger, ref<Store> store
|
||||
break;
|
||||
|
||||
case WorkerProto::Op::VerifyStore: {
|
||||
bool checkContents, repair;
|
||||
from >> checkContents >> repair;
|
||||
bool checkContents = readBool(from);
|
||||
bool repair = readBool(from);
|
||||
logger->startWork();
|
||||
if (repair && !trusted)
|
||||
throw Error("you are not privileged to repair paths");
|
||||
@@ -760,10 +763,13 @@ static void performOp(AsyncIoRoot & aio, TunnelLogger * logger, ref<Store> store
|
||||
if (deriver != "")
|
||||
info.deriver = store->parseStorePath(deriver);
|
||||
info.references = WorkerProto::Serialise<StorePathSet>::read(rconn);
|
||||
from >> info.registrationTime >> info.narSize >> info.ultimate;
|
||||
info.registrationTime = readNum<time_t>(from);
|
||||
info.narSize = readNum<uint64_t>(from);
|
||||
info.ultimate = readBool(from);
|
||||
info.sigs = readStrings<StringSet>(from);
|
||||
info.ca = ContentAddress::parseOpt(readString(from));
|
||||
from >> repair >> dontCheckSigs;
|
||||
repair = readBool(from);
|
||||
dontCheckSigs = readBool(from);
|
||||
if (!trusted && dontCheckSigs)
|
||||
dontCheckSigs = false;
|
||||
if (!trusted)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "lix/libstore/globals.hh"
|
||||
#include "lix/libutil/json.hh"
|
||||
#include "lix/libutil/result.hh"
|
||||
#include "lix/libutil/serialise.hh"
|
||||
#include "lix/libutil/types.hh"
|
||||
#include "lix/libstore/common-protocol.hh"
|
||||
#include "lix/libstore/common-protocol-impl.hh"
|
||||
@@ -678,7 +679,8 @@ Source & readDerivation(Source & in, const Store & store, BasicDerivation & drv,
|
||||
|
||||
drv.inputSrcs = CommonProto::Serialise<StorePathSet>::read(
|
||||
CommonProto::ReadConn { .from = in, .store = store });
|
||||
in >> drv.platform >> drv.builder;
|
||||
drv.platform = readString(in);
|
||||
drv.builder = readString(in);
|
||||
drv.args = readStrings<Strings>(in);
|
||||
|
||||
nr = readNum<size_t>(in);
|
||||
|
||||
@@ -65,7 +65,7 @@ BuildPathsResult ServeProto::Serialise<BuildPathsResult>::read(ServeProto::ReadC
|
||||
result.status = (BuildResult::Status) readInt(conn.from);
|
||||
|
||||
if (!result.success()) {
|
||||
conn.from >> result.errorMsg;
|
||||
result.errorMsg = readString(conn.from);
|
||||
return {result, Error(result.status, result.errorMsg)};
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ try {
|
||||
if (magic != WORKER_MAGIC_2)
|
||||
throw Error("protocol mismatch");
|
||||
|
||||
from >> conn.daemonVersion;
|
||||
conn.daemonVersion = readNum<unsigned>(from);
|
||||
if (GET_PROTOCOL_MAJOR(conn.daemonVersion) != GET_PROTOCOL_MAJOR(PROTOCOL_VERSION))
|
||||
throw Error("Nix daemon protocol version not supported");
|
||||
if (GET_PROTOCOL_MINOR(conn.daemonVersion) < MIN_SUPPORTED_MINOR_WORKER_PROTO_VERSION)
|
||||
|
||||
@@ -14,14 +14,14 @@ BuildResult ServeProto::Serialise<BuildResult>::read(ServeProto::ReadConn conn)
|
||||
{
|
||||
BuildResult status;
|
||||
status.status = (BuildResult::Status) readInt(conn.from);
|
||||
conn.from >> status.errorMsg;
|
||||
status.errorMsg = readString(conn.from);
|
||||
|
||||
if (GET_PROTOCOL_MINOR(conn.version) >= 3)
|
||||
conn.from
|
||||
>> status.timesBuilt
|
||||
>> status.isNonDeterministic
|
||||
>> status.startTime
|
||||
>> status.stopTime;
|
||||
if (GET_PROTOCOL_MINOR(conn.version) >= 3) {
|
||||
status.timesBuilt = readNum<unsigned>(conn.from);
|
||||
status.isNonDeterministic = readBool(conn.from);
|
||||
status.startTime = readNum<time_t>(conn.from);
|
||||
status.stopTime = readNum<time_t>(conn.from);
|
||||
}
|
||||
if (GET_PROTOCOL_MINOR(conn.version) >= 6) {
|
||||
auto builtOutputs = ServeProto::Serialise<DrvOutputs>::read(conn);
|
||||
for (auto && [output, realisation] : builtOutputs)
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "lix/libstore/worker-protocol-impl.hh"
|
||||
#include "lix/libutil/archive.hh"
|
||||
#include "lix/libstore/path-info.hh"
|
||||
#include <cstdint>
|
||||
#include <ctime>
|
||||
#include <optional>
|
||||
|
||||
namespace nix {
|
||||
@@ -79,12 +81,11 @@ BuildResult WorkerProto::Serialise<BuildResult>::read(WorkerProto::ReadConn conn
|
||||
{
|
||||
BuildResult res;
|
||||
res.status = (BuildResult::Status) readInt(conn.from);
|
||||
conn.from >> res.errorMsg;
|
||||
conn.from
|
||||
>> res.timesBuilt
|
||||
>> res.isNonDeterministic
|
||||
>> res.startTime
|
||||
>> res.stopTime;
|
||||
res.errorMsg = readString(conn.from);
|
||||
res.timesBuilt = readNum<unsigned>(conn.from);
|
||||
res.isNonDeterministic = readBool(conn.from);
|
||||
res.startTime = readNum<time_t>(conn.from);
|
||||
res.stopTime = readNum<time_t>(conn.from);
|
||||
auto builtOutputs = WorkerProto::Serialise<DrvOutputs>::read(conn);
|
||||
for (auto && [output, realisation] : builtOutputs)
|
||||
res.builtOutputs.insert_or_assign(
|
||||
@@ -131,9 +132,10 @@ UnkeyedValidPathInfo WorkerProto::Serialise<UnkeyedValidPathInfo>::read(ReadConn
|
||||
UnkeyedValidPathInfo info(narHash);
|
||||
if (deriver != "") info.deriver = conn.store.parseStorePath(deriver);
|
||||
info.references = WorkerProto::Serialise<StorePathSet>::read(conn);
|
||||
conn.from >> info.registrationTime >> info.narSize;
|
||||
info.registrationTime = readNum<time_t>(conn.from);
|
||||
info.narSize = readNum<uint64_t>(conn.from);
|
||||
|
||||
conn.from >> info.ultimate;
|
||||
info.ultimate = readBool(conn.from);
|
||||
info.sigs = readStrings<StringSet>(conn.from);
|
||||
info.ca = ContentAddress::parseOpt(readString(conn.from));
|
||||
|
||||
@@ -156,8 +158,7 @@ WireFormatGenerator WorkerProto::Serialise<UnkeyedValidPathInfo>::write(WriteCon
|
||||
std::optional<UnkeyedValidPathInfo>
|
||||
WorkerProto::Serialise<std::optional<UnkeyedValidPathInfo>>::read(ReadConn conn)
|
||||
{
|
||||
bool valid;
|
||||
conn.from >> valid;
|
||||
bool valid = readBool(conn.from);
|
||||
if (valid) {
|
||||
return WorkerProto::Serialise<UnkeyedValidPathInfo>::read(conn);
|
||||
} else {
|
||||
|
||||
@@ -254,13 +254,6 @@ std::string readString(Source & source, size_t max)
|
||||
return res;
|
||||
}
|
||||
|
||||
Source & operator >> (Source & in, std::string & s)
|
||||
{
|
||||
s = readString(in);
|
||||
return in;
|
||||
}
|
||||
|
||||
|
||||
template<class T> T readStrings(Source & source)
|
||||
{
|
||||
auto count = readNum<size_t>(source);
|
||||
|
||||
@@ -395,20 +395,9 @@ void readPadding(size_t len, Source & source);
|
||||
std::string readString(Source & source, size_t max = std::numeric_limits<size_t>::max());
|
||||
template<class T> T readStrings(Source & source);
|
||||
|
||||
Source & operator >> (Source & in, std::string & s);
|
||||
|
||||
template<typename T>
|
||||
Source & operator >> (Source & in, T & n)
|
||||
inline bool readBool(Source & in)
|
||||
{
|
||||
n = readNum<T>(in);
|
||||
return in;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Source & operator >> (Source & in, bool & b)
|
||||
{
|
||||
b = readNum<uint64_t>(in);
|
||||
return in;
|
||||
return readNum<uint64_t>(in);
|
||||
}
|
||||
|
||||
Error readError(Source & source);
|
||||
|
||||
Reference in New Issue
Block a user