diff --git a/crates/ledger-host/src/bridge.rs b/crates/ledger-host/src/bridge.rs index ae9486f9..3d23a9f2 100644 --- a/crates/ledger-host/src/bridge.rs +++ b/crates/ledger-host/src/bridge.rs @@ -1005,6 +1005,17 @@ impl Bridge { return; } }; + // The host this bridge held went, and the app started in its + // place: its lease is on a server with no host, which never + // ends, so it would never see the app go. The bridge becomes + // the line to whatever runs, as a fresh one is, and says the + // same words when the app closes (INVARIANT 12). + if lease.is_hostless() { + drop(lease); + self.app.store(true, std::sync::atomic::Ordering::SeqCst); + self.link.send_replace(Link::Opening); + return self.keep_in_app(run_dir).await; + } // Until this lease ends: whenever the server is ready and no // session is up, open one. The lease is always heard, even // while a session is being opened or a try waits (INVARIANT 1). diff --git a/crates/ledger-host/src/opener.rs b/crates/ledger-host/src/opener.rs index ed019d33..8e50099d 100644 --- a/crates/ledger-host/src/opener.rs +++ b/crates/ledger-host/src/opener.rs @@ -166,6 +166,13 @@ struct HostLink { } impl Lease { + /// Whether this lease is on the app's server with no host behind it + /// (INVARIANT 6): it never ends, so a holder that has one follows + /// what runs by looking, as a bridge with no host does. + pub fn is_hostless(&self) -> bool { + self.link.is_none() + } + /// The host's next word: `Ready`, or `Ending` with why; `None` when /// the host is gone without a word. pub async fn next(&mut self) -> Option {