Add SSHMaster::Connection::trySetBufferSize

It is unused in Nix currently, but will be used in Hydra. This reflects
what Hydra does in https://github.com/NixOS/hydra/pull/1387.

We may probalby to use it more widely for better SSH store performance,
but this needs to be subject to more testing before we do that.
This commit is contained in:
John Ericson 2024-05-23 11:53:17 -04:00
parent 7de033d63f
commit 05be135783
2 changed files with 20 additions and 0 deletions

View File

@ -194,4 +194,14 @@ Path SSHMaster::startMaster()
#endif
void SSHMaster::Connection::trySetBufferSize(size_t size)
{
#ifdef F_SETPIPE_SZ
// convert type
int pipesize = size;
fcntl(in.get(), F_SETPIPE_SZ, pipesize);
fcntl(out.get(), F_SETPIPE_SZ, pipesize);
#endif
}
}

View File

@ -51,6 +51,16 @@ public:
Pid sshPid;
#endif
AutoCloseFD out, in;
/**
* Try to set the buffer size in both directions to the
* designated amount, if possible. If not possible, does
* nothing.
*
* Current implementation is to use `fcntl` with `F_SETPIPE_SZ`,
* which is Linux-only.
*/
void trySetBufferSize(size_t size);
};
/**