fix(ssh): extraneous master processes

This commit is contained in:
ThinkChaos 2023-11-04 12:08:00 -04:00
parent 28dddde0ac
commit 6472c3bf0d
No known key found for this signature in database

View file

@ -132,7 +132,6 @@ Path SSHMaster::startMaster()
if (state->sshMaster != -1) return state->socketPath; if (state->sshMaster != -1) return state->socketPath;
state->socketPath = (Path) *state->tmpDir + "/ssh.sock"; state->socketPath = (Path) *state->tmpDir + "/ssh.sock";
Pipe out; Pipe out;
@ -144,7 +143,8 @@ Path SSHMaster::startMaster()
logger->pause(); logger->pause();
Finally cleanup = [&]() { logger->resume(); }; Finally cleanup = [&]() { logger->resume(); };
bool wasMasterRunning = isMasterRunning(); if (isMasterRunning())
return state->socketPath;
state->sshMaster = startProcess([&]() { state->sshMaster = startProcess([&]() {
restoreProcessContext(); restoreProcessContext();
@ -165,13 +165,12 @@ Path SSHMaster::startMaster()
out.writeSide = -1; out.writeSide = -1;
if (!wasMasterRunning) {
std::string reply; std::string reply;
try { try {
reply = readLine(out.readSide.get()); reply = readLine(out.readSide.get());
} catch (EndOfFile & e) { } } catch (EndOfFile & e) { }
if (reply != "started") if (reply != "started") {
throw Error("failed to start SSH master connection to '%s'", host); throw Error("failed to start SSH master connection to '%s'", host);
} }