mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
Move machineName from DerivationBuildingGoal to HookInstance
Exactly why is is correct is a little subtle, because sometimes the
worker is owned by the worker. But the commit message in
e437b08250 explained the situation well
enough: I made that commit message part of the ABI docs, and now it
should be understandable to the next person.
This commit is contained in:
parent
eb56b181ae
commit
450633aa8c
3 changed files with 20 additions and 8 deletions
|
|
@ -450,7 +450,7 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
|
||||||
fmt("building '%s'", worker.store.printStorePath(drvPath));
|
fmt("building '%s'", worker.store.printStorePath(drvPath));
|
||||||
#ifndef _WIN32 // TODO enable build hook on Windows
|
#ifndef _WIN32 // TODO enable build hook on Windows
|
||||||
if (hook)
|
if (hook)
|
||||||
msg += fmt(" on '%s'", machineName);
|
msg += fmt(" on '%s'", hook->machineName);
|
||||||
#endif
|
#endif
|
||||||
act = std::make_unique<Activity>(
|
act = std::make_unique<Activity>(
|
||||||
*logger,
|
*logger,
|
||||||
|
|
@ -460,7 +460,7 @@ Goal::Co DerivationBuildingGoal::tryToBuild()
|
||||||
Logger::Fields{
|
Logger::Fields{
|
||||||
worker.store.printStorePath(drvPath),
|
worker.store.printStorePath(drvPath),
|
||||||
#ifndef _WIN32 // TODO enable build hook on Windows
|
#ifndef _WIN32 // TODO enable build hook on Windows
|
||||||
hook ? machineName :
|
hook ? hook->machineName :
|
||||||
#endif
|
#endif
|
||||||
"",
|
"",
|
||||||
1,
|
1,
|
||||||
|
|
@ -1027,7 +1027,7 @@ HookReply DerivationBuildingGoal::tryBuildHook()
|
||||||
hook = std::move(worker.hook);
|
hook = std::move(worker.hook);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
machineName = readLine(hook->fromHook.readSide.get());
|
hook->machineName = readLine(hook->fromHook.readSide.get());
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
e.addTrace({}, "while reading the machine name from the build hook");
|
e.addTrace({}, "while reading the machine name from the build hook");
|
||||||
throw;
|
throw;
|
||||||
|
|
|
||||||
|
|
@ -95,11 +95,6 @@ private:
|
||||||
|
|
||||||
std::map<ActivityId, Activity> builderActivities;
|
std::map<ActivityId, Activity> builderActivities;
|
||||||
|
|
||||||
/**
|
|
||||||
* The remote machine on which we're building.
|
|
||||||
*/
|
|
||||||
std::string machineName;
|
|
||||||
|
|
||||||
void timedOut(Error && ex) override;
|
void timedOut(Error && ex) override;
|
||||||
|
|
||||||
std::string key() override;
|
std::string key() override;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,14 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @note Sometimes this is owned by the `Worker`, and sometimes it is
|
||||||
|
* owned by a `Goal`. This is for efficiency: rather than starting the
|
||||||
|
* hook every time we want to ask whether we can run a remote build
|
||||||
|
* (which can be very often), we reuse a hook process for answering
|
||||||
|
* those queries until it accepts a build. So if there are N
|
||||||
|
* derivations to be built, at most N hooks will be started.
|
||||||
|
*/
|
||||||
struct HookInstance
|
struct HookInstance
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|
@ -29,6 +37,15 @@ struct HookInstance
|
||||||
*/
|
*/
|
||||||
Pid pid;
|
Pid pid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The remote machine on which we're building.
|
||||||
|
*
|
||||||
|
* @Invariant When the hook instance is owned by the `Worker`, this
|
||||||
|
* is the empty string. When it is owned by a `Goal`, this should be
|
||||||
|
* set.
|
||||||
|
*/
|
||||||
|
std::string machineName;
|
||||||
|
|
||||||
FdSink sink;
|
FdSink sink;
|
||||||
|
|
||||||
std::map<ActivityId, Activity> activities;
|
std::map<ActivityId, Activity> activities;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue