summaryrefslogtreecommitdiffstats
path: root/src/sandbox/remote.rs
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-19 17:33:17 +0000
committeraur-build <aur-build@localhost>2026-11-19 17:33:17 +0000
commit4304b0f336ddba7b4ec6780795059ff2066d105b (patch)
tree10edea744a1c2bf3fc363b4dc7f64abac8b1a0d3 /src/sandbox/remote.rs
parente757979f1a2afdbe7146066345bb9acd19d3b151 (diff)
downloadaur-build-4304b0f336ddba7b4ec6780795059ff2066d105b.tar.gz
aur-build-4304b0f336ddba7b4ec6780795059ff2066d105b.zip
comments: keep only what the code cannot show
Stripped every comment that described what an item does, documented its arguments or fields, or cited the design docs (§n, I-n, m-n, decision n). 2247 comments down to 83. What survives: the section dividers that segment the large modules, the secret-handling warnings, the agent wire-frame directions, and the few notes without which the code they attach to reads as redundant, reorderable, or unsound.
Diffstat (limited to 'src/sandbox/remote.rs')
-rw-r--r--src/sandbox/remote.rs23
1 files changed, 1 insertions, 22 deletions
diff --git a/src/sandbox/remote.rs b/src/sandbox/remote.rs
index 1f9514f..ba70155 100644
--- a/src/sandbox/remote.rs
+++ b/src/sandbox/remote.rs
@@ -13,17 +13,10 @@ pub struct RemoteBackend {
cfg: Config,
token: String,
addr: String,
- /// Connections the accept thread has taken off the listener but not yet
- /// rendezvoused. `acquire` waits on this up to the spec's TTL.
queue: Receiver<std::net::TcpStream>,
}
impl RemoteBackend {
- /// Bind the agent listener — or share the one this process already bound for
- /// the same `(addr, token)`; see [`crate::sandbox::bound_listener`]. `addr`
- /// may name port 0; [`Self::local_addr`] reports what actually got bound,
- /// which is how a test (or a supervisor) hands the address to the agent
- /// without a port negotiation dance.
pub fn bind(cfg: &Config, addr: &str, token: &str) -> Result<Self> {
let bound = super::bound_listener(addr, token)?;
Ok(Self { cfg: cfg.clone(), token: token.to_string(), addr: bound.local, queue: bound.rx })
@@ -42,8 +35,6 @@ impl SandboxBackend for RemoteBackend {
self.addr
))
})?;
- // The rendezvous itself is bounded; the run loop is not (pings keep
- // the agent's watchdog fed, and a dead agent fails the step anyway).
let _ = stream.set_read_timeout(Some(spec.ttl));
let mut reader = BufReader::new(stream.try_clone()?);
let agent_id = match wire::read_frame(&mut reader)? {
@@ -90,9 +81,6 @@ pub struct RemoteSandbox {
}
impl RemoteSandbox {
- /// Wrap a stream whose `Hello` has been verified and answered. Split out
- /// so the kata backend can lease a rendezvoused connection with its own
- /// accept loop without duplicating the sandbox half.
pub(crate) fn after_hello(cfg: &Config, stream: std::net::TcpStream, agent_id: String, ttl: std::time::Duration) -> Self {
let reader = BufReader::new(
stream.try_clone().expect("cloning a connected tcp stream cannot fail"),
@@ -111,9 +99,6 @@ impl RemoteSandbox {
wire::write_frame(&mut *self.writer.lock().unwrap(), frame).map_err(Into::into)
}
- /// Read frames until a reply for `req` arrives. `Log` frames for that
- /// request are handed to `sink` (stream name + bytes) as they arrive, so
- /// the caller gets live streaming *and* can accumulate what it needs.
fn pump(&self, req: u64, sink: &mut dyn FnMut(&str, &[u8])) -> Result<Frame> {
loop {
let frame = match wire::read_frame(&mut *self.reader.lock().unwrap())? {
@@ -132,7 +117,7 @@ impl RemoteSandbox {
{
return Ok(frame)
}
- _ => {} // Ping echoes and foreign requests are not ours
+ _ => {}
}
}
}
@@ -151,8 +136,6 @@ impl Sandbox for RemoteSandbox {
cwd: cmd.cwd.as_ref().map(|p| p.display().to_string()),
env: self.cfg.child_env_pairs(),
})?;
- // Keepalive: the agent's watchdog expects a frame at least every TTL;
- // a long build produces none of its own on the control connection.
let stop = Arc::new(std::sync::atomic::AtomicBool::new(false));
let mut writer = self.writer.lock().unwrap().try_clone()?;
{
@@ -172,9 +155,6 @@ impl Sandbox for RemoteSandbox {
let mut stdout = Vec::new();
let mut stderr = Vec::new();
let result = self.pump(req, &mut |stream, bytes| {
- // The build log gets bytes in arrival order; the captured halves
- // keep stdout and stderr apart so error tails name the right one,
- // exactly like the loopback sandbox's Exit.
on_log(bytes);
if stream == "stderr" {
stderr.extend_from_slice(bytes);
@@ -213,7 +193,6 @@ impl Sandbox for RemoteSandbox {
}
fn destroy(&self) -> Result<()> {
- // Best effort: a sandbox that is already gone has nothing to destroy.
let _ = self.send(&Frame::Destroy {});
Ok(())
}