todo socket: pause after a failed accept instead of spinning
This commit is contained in:
parent
0a1e4db0f4
commit
6bcffb0ebb
1 changed files with 10 additions and 1 deletions
|
|
@ -43,6 +43,10 @@ use crate::todos::{Todo, Todos};
|
||||||
/// dashboard's `ctx·Nk` badge before hitting the `/compact` button.
|
/// dashboard's `ctx·Nk` badge before hitting the `/compact` button.
|
||||||
const COMPACT_MIN_USAGE_FRACTION: f64 = 0.66;
|
const COMPACT_MIN_USAGE_FRACTION: f64 = 0.66;
|
||||||
|
|
||||||
|
/// Pause after a failed `accept`, so a failure that persists (fd exhaustion)
|
||||||
|
/// does not turn the accept loop into a busy spin.
|
||||||
|
const ACCEPT_RETRY_DELAY: std::time::Duration = std::time::Duration::from_secs(1);
|
||||||
|
|
||||||
/// Resolve the in-agent socket path from `HIVE_AGENT_SOCKET`. `None` when
|
/// Resolve the in-agent socket path from `HIVE_AGENT_SOCKET`. `None` when
|
||||||
/// unset/empty (e.g. a standalone dev run) — the server then stays off.
|
/// unset/empty (e.g. a standalone dev run) — the server then stays off.
|
||||||
fn socket_path() -> Option<PathBuf> {
|
fn socket_path() -> Option<PathBuf> {
|
||||||
|
|
@ -107,7 +111,12 @@ pub async fn run(
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Err(e) => tracing::warn!(error = ?e, "in-agent todo accept failed"),
|
Err(e) => {
|
||||||
|
tracing::warn!(error = ?e, "in-agent todo accept failed");
|
||||||
|
// A persistent failure (fd exhaustion) fails again at once;
|
||||||
|
// without a pause this loop spins and floods the log.
|
||||||
|
tokio::time::sleep(ACCEPT_RETRY_DELAY).await;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue