mirror of
https://github.com/NixOS/nix.git
synced 2025-11-13 22:12:43 +01:00
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 probably to use it more widely for better SSH store performance,
but this needs to be subject to more testing before we do that.
(cherry picked from commit 0d25cc6541)
This commit is contained in:
parent
674a87462c
commit
7112f8294c
2 changed files with 27 additions and 0 deletions
|
|
@ -240,4 +240,19 @@ Path SSHMaster::startMaster()
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void SSHMaster::Connection::trySetBufferSize(size_t size)
|
||||||
|
{
|
||||||
|
#ifdef F_SETPIPE_SZ
|
||||||
|
/* This `fcntl` method of doing this takes a positive `int`. Check
|
||||||
|
and convert accordingly.
|
||||||
|
|
||||||
|
The function overall still takes `size_t` because this is more
|
||||||
|
portable for a platform-agnostic interface. */
|
||||||
|
assert(size <= INT_MAX);
|
||||||
|
int pipesize = size;
|
||||||
|
fcntl(in.get(), F_SETPIPE_SZ, pipesize);
|
||||||
|
fcntl(out.get(), F_SETPIPE_SZ, pipesize);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,18 @@ public:
|
||||||
Pid sshPid;
|
Pid sshPid;
|
||||||
#endif
|
#endif
|
||||||
AutoCloseFD out, in;
|
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. For this implementation, `size` must
|
||||||
|
* convertable to an `int`. In other words, it must be within
|
||||||
|
* `[0, INT_MAX]`.
|
||||||
|
*/
|
||||||
|
void trySetBufferSize(size_t size);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue