Skip to main content

ensure_singleton

Function ensure_singleton 

Source
pub async fn ensure_singleton(
    connection_file_path: impl AsRef<Path>,
    port: u16,
) -> Result<Outcome, BootstrapError>
Expand description

Find an existing daemon or atomically bind loopback TCP for this daemon.

The algorithm is intentionally connect-first: an endpoint from the connection file is treated as live only after the TCP+key server-proof authenticates for that file’s key and daemon_id. Stale or foreign connection files are reclaimed only while holding the per-user start lock; the TCP port is never the singleton primitive.