aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/build/derivation-goal.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/build/derivation-goal.hh')
-rw-r--r--src/libstore/build/derivation-goal.hh59
1 files changed, 34 insertions, 25 deletions
diff --git a/src/libstore/build/derivation-goal.hh b/src/libstore/build/derivation-goal.hh
index 020388d5a..7505409c0 100644
--- a/src/libstore/build/derivation-goal.hh
+++ b/src/libstore/build/derivation-goal.hh
@@ -8,6 +8,7 @@
#include "store-api.hh"
#include "pathlocks.hh"
#include "goal.hh"
+#include <kj/time.h>
namespace nix {
@@ -17,7 +18,7 @@ struct HookInstance;
struct HookReplyBase {
struct [[nodiscard]] Accept {
- std::set<int> fds;
+ kj::Promise<Outcome<void, Goal::Finished>> promise;
};
struct [[nodiscard]] Decline {};
struct [[nodiscard]] Postpone {};
@@ -70,6 +71,8 @@ struct InitialOutput {
*/
struct DerivationGoal : public Goal
{
+ struct InputStream;
+
/**
* Whether to use an on-disk .drv file.
*/
@@ -213,9 +216,6 @@ struct DerivationGoal : public Goal
*/
std::optional<DerivationType> derivationType;
- typedef kj::Promise<Result<WorkResult>> (DerivationGoal::*GoalState)(bool inBuildSlot) noexcept;
- GoalState state;
-
BuildMode buildMode;
NotifyingCounter<uint64_t>::Bump mcExpectedBuilds, mcRunningBuilds;
@@ -242,11 +242,9 @@ struct DerivationGoal : public Goal
BuildMode buildMode = bmNormal);
virtual ~DerivationGoal() noexcept(false);
- Finished timedOut(Error && ex) override;
+ Finished timedOut(Error && ex);
- std::string key() override;
-
- kj::Promise<Result<WorkResult>> work(bool inBuildSlot) noexcept override;
+ kj::Promise<Result<WorkResult>> work() noexcept override;
/**
* Add wanted outputs to an already existing derivation goal.
@@ -256,23 +254,23 @@ struct DerivationGoal : public Goal
/**
* The states.
*/
- kj::Promise<Result<WorkResult>> getDerivation(bool inBuildSlot) noexcept;
- kj::Promise<Result<WorkResult>> loadDerivation(bool inBuildSlot) noexcept;
- kj::Promise<Result<WorkResult>> haveDerivation(bool inBuildSlot) noexcept;
- kj::Promise<Result<WorkResult>> outputsSubstitutionTried(bool inBuildSlot) noexcept;
- kj::Promise<Result<WorkResult>> gaveUpOnSubstitution(bool inBuildSlot) noexcept;
- kj::Promise<Result<WorkResult>> closureRepaired(bool inBuildSlot) noexcept;
- kj::Promise<Result<WorkResult>> inputsRealised(bool inBuildSlot) noexcept;
- kj::Promise<Result<WorkResult>> tryToBuild(bool inBuildSlot) noexcept;
- virtual kj::Promise<Result<WorkResult>> tryLocalBuild(bool inBuildSlot) noexcept;
- kj::Promise<Result<WorkResult>> buildDone(bool inBuildSlot) noexcept;
+ kj::Promise<Result<WorkResult>> getDerivation() noexcept;
+ kj::Promise<Result<WorkResult>> loadDerivation() noexcept;
+ kj::Promise<Result<WorkResult>> haveDerivation() noexcept;
+ kj::Promise<Result<WorkResult>> outputsSubstitutionTried() noexcept;
+ kj::Promise<Result<WorkResult>> gaveUpOnSubstitution() noexcept;
+ kj::Promise<Result<WorkResult>> closureRepaired() noexcept;
+ kj::Promise<Result<WorkResult>> inputsRealised() noexcept;
+ kj::Promise<Result<WorkResult>> tryToBuild() noexcept;
+ virtual kj::Promise<Result<WorkResult>> tryLocalBuild() noexcept;
+ kj::Promise<Result<WorkResult>> buildDone() noexcept;
- kj::Promise<Result<WorkResult>> resolvedFinished(bool inBuildSlot) noexcept;
+ kj::Promise<Result<WorkResult>> resolvedFinished() noexcept;
/**
* Is the build hook willing to perform the build?
*/
- HookReply tryBuildHook(bool inBuildSlot);
+ HookReply tryBuildHook();
virtual int getChildStatus();
@@ -312,13 +310,19 @@ struct DerivationGoal : public Goal
virtual void cleanupPostOutputsRegisteredModeCheck();
virtual void cleanupPostOutputsRegisteredModeNonCheck();
- /**
- * Callback used by the worker to write to the log.
- */
- WorkResult handleChildOutput(int fd, std::string_view data) override;
- void handleEOF(int fd) override;
+protected:
+ kj::TimePoint lastChildActivity = kj::minValue;
+
+ kj::Promise<Outcome<void, Finished>> handleChildOutput() noexcept;
+ kj::Promise<Outcome<void, Finished>>
+ handleChildStreams(InputStream & builderIn, InputStream * hookIn) noexcept;
+ kj::Promise<Outcome<void, Finished>> handleBuilderOutput(InputStream & in) noexcept;
+ kj::Promise<Outcome<void, Finished>> handleHookOutput(InputStream & in) noexcept;
+ kj::Promise<Outcome<void, Finished>> monitorForSilence() noexcept;
+ Finished tooMuchLogs();
void flushLine();
+public:
/**
* Wrappers around the corresponding Store methods that first consult the
* derivation. This is currently needed because when there is no drv file
@@ -357,6 +361,11 @@ struct DerivationGoal : public Goal
void waiteeDone(GoalPtr waitee) override;
+ virtual bool respectsTimeouts()
+ {
+ return false;
+ }
+
StorePathSet exportReferences(const StorePathSet & storePaths);
JobCategory jobCategory() const override {