File tree Expand file tree Collapse file tree 4 files changed +35
-0
lines changed
Expand file tree Collapse file tree 4 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,9 @@ ref<LegacySSHStore::Connection> LegacySSHStore::openConnection()
7070 command.push_back (remoteStore.get ());
7171 }
7272 conn->sshConn = master.startCommand (std::move (command), std::list{extraSshArgs});
73+ if (connPipeSize) {
74+ conn->sshConn ->trySetBufferSize (*connPipeSize);
75+ }
7376 conn->to = FdSink (conn->sshConn ->in .get ());
7477 conn->from = FdSource (conn->sshConn ->out .get ());
7578
Original file line number Diff line number Diff line change @@ -30,6 +30,11 @@ struct LegacySSHStoreConfig : virtual CommonSSHStoreConfig
3030 */
3131 Strings extraSshArgs = {};
3232
33+ /* *
34+ * Exposed for hydra
35+ */
36+ std::optional<size_t > connPipeSize;
37+
3338 const std::string name () override { return " SSH Store" ; }
3439
3540 static std::set<std::string> uriSchemes () { return {" ssh" }; }
Original file line number Diff line number Diff line change @@ -240,4 +240,19 @@ Path SSHMaster::startMaster()
240240
241241#endif
242242
243+ void SSHMaster::Connection::trySetBufferSize (size_t size)
244+ {
245+ #ifdef F_SETPIPE_SZ
246+ /* This `fcntl` method of doing this takes a positive `int`. Check
247+ and convert accordingly.
248+
249+ The function overall still takes `size_t` because this is more
250+ portable for a platform-agnostic interface. */
251+ assert (size <= INT_MAX);
252+ int pipesize = size;
253+ fcntl (in.get (), F_SETPIPE_SZ, pipesize);
254+ fcntl (out.get (), F_SETPIPE_SZ, pipesize);
255+ #endif
256+ }
257+
243258}
Original file line number Diff line number Diff line change @@ -54,6 +54,18 @@ public:
5454 Pid sshPid;
5555#endif
5656 AutoCloseFD out, in;
57+
58+ /* *
59+ * Try to set the buffer size in both directions to the
60+ * designated amount, if possible. If not possible, does
61+ * nothing.
62+ *
63+ * Current implementation is to use `fcntl` with `F_SETPIPE_SZ`,
64+ * which is Linux-only. For this implementation, `size` must
65+ * convertable to an `int`. In other words, it must be within
66+ * `[0, INT_MAX]`.
67+ */
68+ void trySetBufferSize (size_t size);
5769 };
5870
5971 /* *
You can’t perform that action at this time.
0 commit comments