aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/build/derivation-goal.cc
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-08-11 21:53:29 +0200
committereldritch horrors <pennae@lix.systems>2024-08-18 22:04:06 +0000
commite2d330aeed19a1bfed56ea55277ac9400fbc7fed (patch)
tree8089cbe286d252bfc441695655bd8f21a206aceb /src/libstore/build/derivation-goal.cc
parent007211e7a27a512cb343060e8b363c9f66ef67af (diff)
libstore: remove DerivationGoal::isReadDesc
all derivation goals need a log fd of some description. let's save this single fd in a dedicated pointer field for all subclasses so that later we have just the one spot to change if we turn this into async promises Change-Id: If223adf90909247363fb823d751cae34d25d0c0b
Diffstat (limited to 'src/libstore/build/derivation-goal.cc')
-rw-r--r--src/libstore/build/derivation-goal.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc
index 17b6afbb2..f43a2a5b6 100644
--- a/src/libstore/build/derivation-goal.cc
+++ b/src/libstore/build/derivation-goal.cc
@@ -119,6 +119,7 @@ std::string DerivationGoal::key()
void DerivationGoal::killChild()
{
hook.reset();
+ builderOutFD = nullptr;
}
@@ -814,6 +815,7 @@ void replaceValidPath(const Path & storePath, const Path & tmpPath)
int DerivationGoal::getChildStatus()
{
+ builderOutFD = nullptr;
return hook->pid.kill();
}
@@ -822,6 +824,7 @@ void DerivationGoal::closeReadPipes()
{
hook->builderOut.readSide.reset();
hook->fromHook.readSide.reset();
+ builderOutFD = nullptr;
}
@@ -1209,6 +1212,7 @@ HookReply DerivationGoal::tryBuildHook(bool inBuildSlot)
std::set<int> fds;
fds.insert(hook->fromHook.readSide.get());
fds.insert(hook->builderOut.readSide.get());
+ builderOutFD = &hook->builderOut.readSide;
worker.childStarted(shared_from_this(), fds, false, false);
return rpAccept;
@@ -1271,13 +1275,10 @@ void DerivationGoal::closeLogFile()
}
-bool DerivationGoal::isReadDesc(int fd)
-{
- return fd == hook->builderOut.readSide.get();
-}
-
Goal::WorkResult DerivationGoal::handleChildOutput(int fd, std::string_view data)
{
+ assert(builderOutFD);
+
auto tooMuchLogs = [&] {
killChild();
return done(
@@ -1287,7 +1288,7 @@ Goal::WorkResult DerivationGoal::handleChildOutput(int fd, std::string_view data
};
// local & `ssh://`-builds are dealt with here.
- auto isWrittenToLog = isReadDesc(fd);
+ auto isWrittenToLog = fd == builderOutFD->get();
if (isWrittenToLog)
{
logSize += data.size();