Make Env::AppBundle constructor exception safe

When the Env::AppBundle constructor throws an exception
it still needs to run ~AppBundle(), otherwise the JobQueue
isn't properly shut down.  Specifically the  JobQueue
can destruct without waiting on outstanding jobs in the
queue.

This change ensures that if Env::AppBundle constructor
throws, Env::AppBundle::~AppBundle() runs.

This fixes the unit test crash exposed by PR #3047.
This commit is contained in:
Howard Hinnant
2019-10-17 20:21:24 -04:00
committed by Manoj doshi
parent 41b2c80dde
commit 726dd69ab9
3 changed files with 28 additions and 5 deletions

View File

@@ -749,6 +749,22 @@ public:
}
}
void testExceptionalShutdown()
{
except(
[this]
{
jtx::Env env {*this,
jtx::envconfig([](std::unique_ptr<Config> cfg)
{
(*cfg).deprecatedClearSection("port_rpc");
return cfg;
})};
}
);
pass();
}
void
run() override
{
@@ -771,6 +787,7 @@ public:
testResignSigned();
testSignAndSubmit();
testFeatures();
testExceptionalShutdown();
}
};