fix(service): repair initial owner identity and extend readiness wait

This commit is contained in:
wonfen
2026-09-21 17:32:48 +08:00
parent b469bee352
commit 81ce247ecc
3 changed files with 10 additions and 10 deletions
+3 -6
View File
@@ -392,13 +392,10 @@ mod windows_owner {
}
pub(super) fn repair_root_owner(root: &Path) -> Result<()> {
// Elevated Windows processes can create directories owned by Administrators.
std::fs::create_dir_all(root).context("failed to create the application data root before owner repair")?;
// The Service canonicalizes before checking, so resolve junctions to the same object.
let root = match std::fs::canonicalize(root) {
Ok(path) => path,
// Nothing to repair: this process creates the root and owns it by construction.
Err(error) if error.kind() == std::io::ErrorKind::NotFound => return Ok(()),
Err(error) => return Err(error).context("failed to canonicalize the application data root"),
};
let root = std::fs::canonicalize(root).context("failed to canonicalize the application data root")?;
let root = root.as_path();
let sid = current_sid()?;
+5 -4
View File
@@ -1963,12 +1963,13 @@ async fn recover_after_owner_loss_while_locked(reason: OwnerRecoveryReason) {
#[tracing::instrument(skip_all, level = "info", fields(attempts = tracing::field::Empty, interval_ms = tracing::field::Empty, outcome = tracing::field::Empty))]
async fn wait_for_service_ipc() -> Result<()> {
const CONTEXT: &str = "service IPC did not become available";
let config = ServiceManager::config();
const READY_ATTEMPTS: usize = 61;
const READY_INTERVAL: Duration = Duration::from_millis(500);
let span = tracing::Span::current();
span.record("attempts", config.max_retries);
span.record("interval_ms", config.retry_delay.as_millis() as u64);
span.record("attempts", READY_ATTEMPTS);
span.record("interval_ms", READY_INTERVAL.as_millis() as u64);
match RUN_STATE.await_ready(config.max_retries, config.retry_delay).await {
match RUN_STATE.await_ready(READY_ATTEMPTS, READY_INTERVAL).await {
Ok(_) => {
tracing::Span::current().record("outcome", "ready");
Ok(())