diff options
author | eldritch horrors <pennae@lix.systems> | 2024-05-18 02:35:34 +0200 |
---|---|---|
committer | eldritch horrors <pennae@lix.systems> | 2024-07-16 00:57:42 +0000 |
commit | a5d1f698417dff4e470eb94c38ad6c4e5ebf38ff (patch) | |
tree | 116b887a80fd96f9008bc55c872a24ef1955ca2f /src/libstore/daemon.cc | |
parent | 5271424d14241ec5cbe7ab3bda85ddeb486cff76 (diff) |
libstore: generatorize protocol serializers
this is cursed. deeply and profoundly cursed. under NO CIRCUMSTANCES
must protocol serializer helpers be applied to temporaries! doing so
will inevitably cause dangling references and cause the entire thing
to crash. we need to do this even so to get rid of boost coroutines,
and likewise to encapsulate the serializers we suffer today at least
a little bit to allow a gradual migration to an actual IPC protocol.
(this isn't a problem that's unique to generators. c++ coroutines in
general cannot safely take references to arbitrary temporaries since
c++ does not have a lifetime system that can make this safe. -sigh-)
Change-Id: I2921ba451e04d86798752d140885d3c5cc08e146
Diffstat (limited to 'src/libstore/daemon.cc')
-rw-r--r-- | src/libstore/daemon.cc | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/libstore/daemon.cc b/src/libstore/daemon.cc index cae5b54fd..46500e7d3 100644 --- a/src/libstore/daemon.cc +++ b/src/libstore/daemon.cc @@ -291,7 +291,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store, } auto res = store->queryValidPaths(paths, substitute); logger->stopWork(); - WorkerProto::write(*store, wconn, res); + wconn.to << WorkerProto::write(*store, wconn, res); break; } @@ -300,7 +300,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store, logger->startWork(); auto res = store->querySubstitutablePaths(paths); logger->stopWork(); - WorkerProto::write(*store, wconn, res); + wconn.to << WorkerProto::write(*store, wconn, res); break; } @@ -365,7 +365,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store, #pragma GCC diagnostic pop logger->stopWork(); - WorkerProto::write(*store, wconn, paths); + wconn.to << WorkerProto::write(*store, wconn, paths); break; } @@ -385,7 +385,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store, logger->startWork(); auto outputs = store->queryPartialDerivationOutputMap(path); logger->stopWork(); - WorkerProto::write(*store, wconn, outputs); + wconn.to << WorkerProto::write(*store, wconn, outputs); break; } @@ -432,7 +432,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store, }(); logger->stopWork(); - WorkerProto::Serialise<ValidPathInfo>::write(*store, wconn, *pathInfo); + wconn.to << WorkerProto::Serialise<ValidPathInfo>::write(*store, wconn, *pathInfo); } else { HashType hashAlgo; std::string baseName; @@ -565,7 +565,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store, auto results = store->buildPathsWithResults(drvs, mode); logger->stopWork(); - WorkerProto::write(*store, wconn, results); + wconn.to << WorkerProto::write(*store, wconn, results); break; } @@ -643,7 +643,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store, auto res = store->buildDerivation(drvPath, drv, buildMode); logger->stopWork(); - WorkerProto::write(*store, wconn, res); + wconn.to << WorkerProto::write(*store, wconn, res); break; } @@ -777,7 +777,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store, else { to << 1 << (i->second.deriver ? store->printStorePath(*i->second.deriver) : ""); - WorkerProto::write(*store, wconn, i->second.references); + wconn.to << WorkerProto::write(*store, wconn, i->second.references); to << i->second.downloadSize << i->second.narSize; } @@ -800,7 +800,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store, for (auto & i : infos) { to << store->printStorePath(i.first) << (i.second.deriver ? store->printStorePath(*i.second.deriver) : ""); - WorkerProto::write(*store, wconn, i.second.references); + wconn.to << WorkerProto::write(*store, wconn, i.second.references); to << i.second.downloadSize << i.second.narSize; } break; @@ -810,7 +810,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store, logger->startWork(); auto paths = store->queryAllValidPaths(); logger->stopWork(); - WorkerProto::write(*store, wconn, paths); + wconn.to << WorkerProto::write(*store, wconn, paths); break; } @@ -827,7 +827,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store, logger->stopWork(); if (info) { to << 1; - WorkerProto::write(*store, wconn, static_cast<const UnkeyedValidPathInfo &>(*info)); + wconn.to << WorkerProto::write(*store, wconn, static_cast<const UnkeyedValidPathInfo &>(*info)); } else { to << 0; } @@ -922,9 +922,9 @@ static void performOp(TunnelLogger * logger, ref<Store> store, uint64_t downloadSize, narSize; store->queryMissing(targets, willBuild, willSubstitute, unknown, downloadSize, narSize); logger->stopWork(); - WorkerProto::write(*store, wconn, willBuild); - WorkerProto::write(*store, wconn, willSubstitute); - WorkerProto::write(*store, wconn, unknown); + wconn.to << WorkerProto::write(*store, wconn, willBuild); + wconn.to << WorkerProto::write(*store, wconn, willSubstitute); + wconn.to << WorkerProto::write(*store, wconn, unknown); to << downloadSize << narSize; break; } @@ -952,11 +952,11 @@ static void performOp(TunnelLogger * logger, ref<Store> store, if (GET_PROTOCOL_MINOR(clientVersion) < 31) { std::set<StorePath> outPaths; if (info) outPaths.insert(info->outPath); - WorkerProto::write(*store, wconn, outPaths); + wconn.to << WorkerProto::write(*store, wconn, outPaths); } else { std::set<Realisation> realisations; if (info) realisations.insert(*info); - WorkerProto::write(*store, wconn, realisations); + wconn.to << WorkerProto::write(*store, wconn, realisations); } break; } @@ -1037,7 +1037,7 @@ void processConnection( ? store->isTrustedClient() : std::optional { NotTrusted }; WorkerProto::WriteConn wconn {to, clientVersion}; - WorkerProto::write(*store, wconn, temp); + wconn.to << WorkerProto::write(*store, wconn, temp); } /* Send startup error messages to the client. */ |