Fence Windows sync until the helper confirms the signed decision
Rust development slice / linux (push) Failing after 7s

This commit is contained in:
2026-11-15 22:28:49 +01:00
parent 17c53c1602
commit 148969f0c6
5 changed files with 155 additions and 11 deletions
+43 -10
View File
@@ -5,7 +5,7 @@ use anyhow::{Context, Result, ensure};
use rmm_agent_core::{
auth::{Binding, Outcome, Request},
helper_reconcile::{NoStartAnchor, Snapshot},
reconcile::HelperSnapshot,
reconcile::{HelperSnapshot, SyncClock},
};
use rmm_domain::jobs::{Action, JobPayload};
use rmm_protocol::{SyncAttempt, SyncResponse};
@@ -473,16 +473,49 @@ impl Client {
response: &SyncResponse,
request_bytes: Vec<u8>,
boot: uuid::Uuid,
valid_until: chrono::DateTime<chrono::Utc>,
clock: &impl SyncClock,
) -> Result<ControlSnapshot> {
let reply = self
.call(ipc::Operation::Apply {
response: rmm_agent_core::helper_reconcile::SignedResponse {
decision_bytes: response.decision_bytes.clone(),
signature: response.signature.clone(),
},
request_bytes,
})
.await?;
let operation = ipc::Operation::Apply {
response: rmm_agent_core::helper_reconcile::SignedResponse {
decision_bytes: response.decision_bytes.clone(),
signature: response.signature.clone(),
},
request_bytes,
};
let started = std::time::Instant::now();
let reply = loop {
ensure!(
started.elapsed() < Duration::from_secs(60),
"HELPER_APPLY_EXPIRED"
);
let Ok(reading) = clock.reading() else {
tokio::time::sleep(Duration::from_millis(250)).await;
continue;
};
ensure!(
reading.upper < valid_until && reading.own_wall < valid_until,
"HELPER_APPLY_EXPIRED"
);
match self.call(operation.clone()).await {
Ok(reply) => break reply,
Err(error) => {
// Retry only contention before dispatch. An authenticated
// denial or an unknown reply keeps this round closed.
let diagnostic = ipc::diagnostic(&error);
let pipe_busy = diagnostic.stage == "client_open_pipe"
&& diagnostic.win32
== Some(windows_sys::Win32::Foundation::ERROR_PIPE_BUSY);
if error.to_string() != "HELPER_CONTROL_BUSY" && !pipe_busy {
return Err(error);
}
tokio::time::sleep(Duration::from_millis(250)).await;
}
}
};
if let ipc::ReplyBody::Denied { code } = &reply.body {
return Err(ipc::remote_denial(ipc::Stage::ClientReplyBinding, code));
}
let ipc::ReplyBody::Applied {
snapshot,
no_start_anchor,