mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 20:16:03 +01:00
Write a destructor for DerivationBuilderImpl
This allows `DerivationBuildingGoal` to know less.
This commit is contained in:
parent
557bbe969e
commit
49da508f46
3 changed files with 33 additions and 31 deletions
|
|
@ -59,18 +59,8 @@ DerivationBuildingGoal::~DerivationBuildingGoal()
|
|||
ignoreExceptionInDestructor();
|
||||
}
|
||||
#ifndef _WIN32 // TODO enable `DerivationBuilder` on Windows
|
||||
if (builder) {
|
||||
try {
|
||||
builder->stopDaemon();
|
||||
} catch (...) {
|
||||
ignoreExceptionInDestructor();
|
||||
}
|
||||
try {
|
||||
builder->cleanupBuild(false);
|
||||
} catch (...) {
|
||||
ignoreExceptionInDestructor();
|
||||
}
|
||||
}
|
||||
if (builder)
|
||||
builder.reset();
|
||||
#endif
|
||||
try {
|
||||
closeLogFile();
|
||||
|
|
|
|||
|
|
@ -192,20 +192,6 @@ struct DerivationBuilder : RestrictionContext
|
|||
*/
|
||||
virtual SingleDrvOutputs unprepareBuild() = 0;
|
||||
|
||||
/**
|
||||
* Stop the in-process nix daemon thread.
|
||||
* @see startDaemon
|
||||
*/
|
||||
virtual void stopDaemon() = 0;
|
||||
|
||||
/**
|
||||
* Delete the temporary directory, if we have one.
|
||||
*
|
||||
* @param force We know the build suceeded, so don't attempt to
|
||||
* preseve anything for debugging.
|
||||
*/
|
||||
virtual void cleanupBuild(bool force) = 0;
|
||||
|
||||
/**
|
||||
* Kill any processes running under the build user UID or in the
|
||||
* cgroup of the build.
|
||||
|
|
|
|||
|
|
@ -85,6 +85,22 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
~DerivationBuilderImpl()
|
||||
{
|
||||
/* Careful: we should never ever throw an exception from a
|
||||
destructor. */
|
||||
try {
|
||||
stopDaemon();
|
||||
} catch (...) {
|
||||
ignoreExceptionInDestructor();
|
||||
}
|
||||
try {
|
||||
cleanupBuild(false);
|
||||
} catch (...) {
|
||||
ignoreExceptionInDestructor();
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
|
@ -285,9 +301,11 @@ private:
|
|||
*/
|
||||
void startDaemon();
|
||||
|
||||
public:
|
||||
|
||||
void stopDaemon() override;
|
||||
/**
|
||||
* Stop the in-process nix daemon thread.
|
||||
* @see startDaemon
|
||||
*/
|
||||
void stopDaemon();
|
||||
|
||||
protected:
|
||||
|
||||
|
|
@ -342,9 +360,17 @@ private:
|
|||
*/
|
||||
SingleDrvOutputs registerOutputs();
|
||||
|
||||
public:
|
||||
protected:
|
||||
|
||||
void cleanupBuild(bool force) override;
|
||||
/**
|
||||
* Delete the temporary directory, if we have one.
|
||||
*
|
||||
* @param force We know the build suceeded, so don't attempt to
|
||||
* preseve anything for debugging.
|
||||
*/
|
||||
virtual void cleanupBuild(bool force);
|
||||
|
||||
public:
|
||||
|
||||
void killSandbox(bool getStats) override;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue