mirror of
https://github.com/NixOS/nix.git
synced 2025-12-22 08:51:08 +01:00
Make worker timeouts a bit more strongly typed
This tidies things up in general, but also prepares the way for the next commit in particular.
This commit is contained in:
parent
b398c14045
commit
906334686c
10 changed files with 24 additions and 12 deletions
|
|
@ -71,12 +71,12 @@ void DerivationBuildingGoal::killChild()
|
|||
#endif
|
||||
}
|
||||
|
||||
void DerivationBuildingGoal::timedOut(Error && ex)
|
||||
void DerivationBuildingGoal::timedOut(TimedOut && ex)
|
||||
{
|
||||
killChild();
|
||||
// We're not inside a coroutine, hence we can't use co_return here.
|
||||
// Thus we ignore the return value.
|
||||
[[maybe_unused]] Done _ = doneFailure({BuildResult::Failure::TimedOut, std::move(ex)});
|
||||
[[maybe_unused]] Done _ = doneFailure(std::move(ex));
|
||||
}
|
||||
|
||||
std::string showKnownOutputs(const StoreDirConfig & store, const Derivation & drv)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,12 @@
|
|||
|
||||
namespace nix {
|
||||
|
||||
TimedOut::TimedOut(time_t maxDuration)
|
||||
: BuildError(BuildResult::Failure::TimedOut, "timed out after %1% seconds", maxDuration)
|
||||
, maxDuration(maxDuration)
|
||||
{
|
||||
}
|
||||
|
||||
using Co = nix::Goal::Co;
|
||||
using promise_type = nix::Goal::promise_type;
|
||||
using handle_type = nix::Goal::handle_type;
|
||||
|
|
|
|||
|
|
@ -479,14 +479,13 @@ void Worker::waitForInput()
|
|||
|
||||
if (goal->exitCode == Goal::ecBusy && 0 != settings.maxSilentTime && j->respectTimeouts
|
||||
&& after - j->lastOutput >= std::chrono::seconds(settings.maxSilentTime)) {
|
||||
goal->timedOut(
|
||||
Error("%1% timed out after %2% seconds of silence", goal->getName(), settings.maxSilentTime));
|
||||
goal->timedOut(TimedOut(settings.maxSilentTime));
|
||||
}
|
||||
|
||||
else if (
|
||||
goal->exitCode == Goal::ecBusy && 0 != settings.buildTimeout && j->respectTimeouts
|
||||
&& after - j->timeStarted >= std::chrono::seconds(settings.buildTimeout)) {
|
||||
goal->timedOut(Error("%1% timed out after %2% seconds", goal->getName(), settings.buildTimeout));
|
||||
goal->timedOut(TimedOut(settings.buildTimeout));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ private:
|
|||
|
||||
std::map<ActivityId, Activity> builderActivities;
|
||||
|
||||
void timedOut(Error && ex) override;
|
||||
void timedOut(TimedOut && ex) override;
|
||||
|
||||
std::string key() override;
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ struct DerivationGoal : public Goal
|
|||
bool storeDerivation);
|
||||
~DerivationGoal() = default;
|
||||
|
||||
void timedOut(Error && ex) override
|
||||
void timedOut(TimedOut && ex) override
|
||||
{
|
||||
unreachable();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ struct DerivationResolutionGoal : public Goal
|
|||
*/
|
||||
std::unique_ptr<std::pair<StorePath, BasicDerivation>> resolvedDrv;
|
||||
|
||||
void timedOut(Error && ex) override {}
|
||||
void timedOut(TimedOut && ex) override {}
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ struct DerivationTrampolineGoal : public Goal
|
|||
|
||||
virtual ~DerivationTrampolineGoal();
|
||||
|
||||
void timedOut(Error && ex) override {}
|
||||
void timedOut(TimedOut && ex) override {}
|
||||
|
||||
std::string key() override;
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public:
|
|||
|
||||
Co init();
|
||||
|
||||
void timedOut(Error && ex) override
|
||||
void timedOut(TimedOut && ex) override
|
||||
{
|
||||
unreachable();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,6 +8,13 @@
|
|||
|
||||
namespace nix {
|
||||
|
||||
struct TimedOut : BuildError
|
||||
{
|
||||
time_t maxDuration;
|
||||
|
||||
TimedOut(time_t maxDuration);
|
||||
};
|
||||
|
||||
/**
|
||||
* Forward definition.
|
||||
*/
|
||||
|
|
@ -454,7 +461,7 @@ public:
|
|||
* get rid of any running child processes that are being monitored
|
||||
* by the worker (important!), etc.
|
||||
*/
|
||||
virtual void timedOut(Error && ex) = 0;
|
||||
virtual void timedOut(TimedOut && ex) = 0;
|
||||
|
||||
/**
|
||||
* Used for comparisons. The order matters a bit for scheduling. We
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public:
|
|||
std::optional<ContentAddress> ca = std::nullopt);
|
||||
~PathSubstitutionGoal();
|
||||
|
||||
void timedOut(Error && ex) override
|
||||
void timedOut(TimedOut && ex) override
|
||||
{
|
||||
unreachable();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue