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 0dd1d8ca1c, 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
This commit is contained in:
Alois Wohlschlager 2024-08-02 18:32:24 +02:00
parent 61a93d5308
commit a93dade821
No known key found for this signature in database
GPG key ID: E0F59EA5E5216914

View file

@ -65,10 +65,11 @@ std::unique_ptr<SSHMaster::Connection> SSHMaster::startCommand(const std::string
ProcessOptions options; ProcessOptions options;
options.dieWithParent = false; options.dieWithParent = false;
std::optional<Finally<std::function<void()>>> resumeLoggerDefer;
if (!fakeSSH && !useMaster) { if (!fakeSSH && !useMaster) {
logger->pause(); logger->pause();
resumeLoggerDefer.emplace([&]() { logger->resume(); });
} }
Finally cleanup = [&]() { logger->resume(); };
conn->sshPid = startProcess([&]() { conn->sshPid = startProcess([&]() {
restoreProcessContext(); restoreProcessContext();