From a93dade82118c68b3656ffb40d6a48ab66f2aa1a Mon Sep 17 00:00:00 2001 From: Alois Wohlschlager Date: Fri, 2 Aug 2024 18:32:24 +0200 Subject: [PATCH] libstore/ssh: only resume the logger when we paused it In the SSH code, the logger was conditionally paused, but unconditionally resumed. This was fine as long as resuming the logger was idempotent. Starting with 0dd1d8ca1cdccfc620644a7f690ed35bcd2d1e74, it isn't any more, and the behaviour of the code in question was missed. Consequently, an assertion failure is triggered for example when performing builds against an "SSH" store on localhost. Fix the issue by only resuming the logger when it has actually been paused. Fixes: https://git.lix.systems/lix-project/lix/issues/458 Change-Id: Ib1e4d047744a129f15730b7216f9c9368c2f4211 --- src/libstore/ssh.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libstore/ssh.cc b/src/libstore/ssh.cc index 0d7bfa01d..8386b0e0a 100644 --- a/src/libstore/ssh.cc +++ b/src/libstore/ssh.cc @@ -65,10 +65,11 @@ std::unique_ptr SSHMaster::startCommand(const std::string ProcessOptions options; options.dieWithParent = false; + std::optional>> resumeLoggerDefer; if (!fakeSSH && !useMaster) { logger->pause(); + resumeLoggerDefer.emplace([&]() { logger->resume(); }); } - Finally cleanup = [&]() { logger->resume(); }; conn->sshPid = startProcess([&]() { restoreProcessContext();