From 9f3f292bf50fd284385b156789f1b23dd639e0c1 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Sat, 21 Nov 2026 09:21:20 -0700 Subject: [PATCH] fix(gui): a failed start can be tried again, and a close that was not whole stays on screen The window retries a failed server start when the next tab opens or when the person asks, says a server still starting is starting, tells the person which wanted companies did not open, and when the close reports an incomplete last backup or a bad exit it stays up with a Close anyway button. ViewerOwner only forwards to AppHost now, and the format upgrade goes to the window's own server. Co-Authored-By: Claude Fable 5.2 --- crates/ledger-cli/src/main.rs | 57 +++------ crates/ledger-gui/src/app.rs | 65 +++++++++- crates/ledger-gui/src/owner.rs | 14 ++- crates/ledger-gui/src/serving.rs | 167 ++++++++++++++++++++----- crates/ledger-gui/tests/serving.rs | 194 ++++++++++++++++++++++++++++- 5 files changed, 417 insertions(+), 80 deletions(-) diff --git a/crates/ledger-cli/src/main.rs b/crates/ledger-cli/src/main.rs index 3bc716a3..ddf6173b 100644 --- a/crates/ledger-cli/src/main.rs +++ b/crates/ledger-cli/src/main.rs @@ -73,26 +73,16 @@ fn gui_args(args: Vec) -> Vec { struct ViewerOwner { common: ledger_host::commands::Common, /// The books server this window runs, a child process of it (plan P15 - /// 3.1): started with the window, closed with it. - server: std::sync::Mutex>>, + /// 3.1): started with the window, closed with it. All of what is done + /// with it is `AppHost`'s, which the tests drive. + server: ledger_host::app_server::AppHost, } #[cfg(feature = "gui")] impl ViewerOwner { fn new(common: ledger_host::commands::Common) -> Self { - Self { - common, - server: std::sync::Mutex::new(None), - } - } - - /// The running server, or why there is none. - fn running(&self) -> Result, String> { - self.server - .lock() - .unwrap_or_else(|e| e.into_inner()) - .clone() - .ok_or_else(|| "the books server isn't running".to_string()) + let server = ledger_host::app_server::AppHost::new(common.root.clone()); + Self { common, server } } } @@ -103,41 +93,27 @@ impl ledger_gui::owner::Owner for ViewerOwner { } fn serve_start(&self, open: &[String]) -> Result<(), String> { - use ledger_host::app_server::{AppServer, READY_WAIT}; - // Started before it is waited for, and kept at once: a window - // closed meanwhile closes this one too. - let server = std::sync::Arc::new(AppServer::start(self.common.root.as_deref(), open)?); - *self.server.lock().unwrap_or_else(|e| e.into_inner()) = Some(server.clone()); - server.wait_ready(READY_WAIT) + self.server.start(open) } fn serve_open(&self, book: &str) -> Result, String> { - self.running()?.open_book(book) + self.server.open_book(book) } fn serve_close(&self, book: &str) -> Result, String> { - self.running()?.close_book(book) + self.server.close_book(book) + } + + fn serve_not_open(&self, wanted: &[String]) -> Vec<(String, String)> { + self.server.not_open(wanted) } fn serve_stop(&self) -> Result, String> { - use ledger_host::app_server::{STOP_WAIT, Stopped}; - let Some(server) = self.server.lock().unwrap_or_else(|e| e.into_inner()).take() else { - return Ok(None); - }; - Ok(match server.stop(STOP_WAIT) { - Stopped::Closed => None, - Stopped::StillClosing => Some( - "The books are still closing in the background (most likely a last backup): Wanderbooks finishes it on its own. Start it again once it has.".into(), - ), - }) + self.server.stop(ledger_host::app_server::STOP_WAIT) } fn serve_exited(&self) -> Option { - self.server - .lock() - .unwrap_or_else(|e| e.into_inner()) - .as_ref()? - .exited() + self.server.exited() } fn close_books(&self) -> Result { @@ -243,8 +219,11 @@ impl ledger_gui::owner::Owner for ViewerOwner { }) } + /// Handed to the window's own server as an admin request: there is + /// no host here, and so no lease socket to ask (app_server.rs + /// INVARIANT 10). fn upgrade_format(&self, book: &str, passphrase: &str) -> Result, String> { - ledger_host::commands::upgrade_format(&self.common, book, passphrase) + self.server.upgrade_format(book, passphrase) } fn update_waiting(&self) -> Option { diff --git a/crates/ledger-gui/src/app.rs b/crates/ledger-gui/src/app.rs index 368cff8b..51b3acf3 100644 --- a/crates/ledger-gui/src/app.rs +++ b/crates/ledger-gui/src/app.rs @@ -65,6 +65,11 @@ //! closing the books, until the server has exited or its bounded //! close has run out (and then says what is left); a close is never //! begun while a job that changes the books runs (7) (WB-app-4). +//! When the close says something was not whole (a company's last +//! backup, a server that exited badly), the window stays up showing +//! it, with a "Close anyway" button; closing again is not that. +//! A server still starting is said under the tab bar, and one whose +//! start failed has a "Try again" button there (WB-app-2). //! ``` use crate::company::CompanyView; @@ -429,7 +434,10 @@ impl App { return; } let asked = ctx.input(|i| i.viewport().close_requested()); - if asked && !self.serving.is_closed() { + // What the close said was not whole is read before the window goes + // (INVARIANT 9): asking again is not reading it. + let report = self.serving.close_report(); + if asked && (!self.serving.is_closed() || !report.is_empty()) { ctx.send_viewport_cmd(egui::ViewportCommand::CancelClose); self.serving.begin_stop(); self.closing_window = true; @@ -438,8 +446,30 @@ impl App { return; } if self.serving.is_closed() { - self.closing_window = false; - ctx.send_viewport_cmd(egui::ViewportCommand::Close); + if report.is_empty() { + self.closing_window = false; + ctx.send_viewport_cmd(egui::ViewportCommand::Close); + return; + } + let mut close_anyway = false; + egui::Modal::new(egui::Id::new("wanderbooks-closed-with-problems")).show(ctx, |ui| { + ui.set_max_width(520.0); + ui.heading("Your books did not close cleanly"); + ui.add_space(4.0); + for line in &report { + ui.label(line); + ui.add_space(2.0); + } + ui.add_space(6.0); + if ui.button("Close anyway").clicked() { + close_anyway = true; + } + }); + if close_anyway { + self.serving.acknowledge_close(); + self.closing_window = false; + ctx.send_viewport_cmd(egui::ViewportCommand::Close); + } return; } egui::Modal::new(egui::Id::new("wanderbooks-closing-books")).show(ctx, |ui| { @@ -460,11 +490,14 @@ impl App { /// dismissed (INVARIANT 8). fn show_notices(&mut self, ui: &mut Ui) { self.notices.extend(self.serving.take_notices()); - if self.notices.is_empty() { + let starting = self.serving.is_starting(); + let down = self.serving.is_down(); + if self.notices.is_empty() && !starting && !down { return; } let p = pal(ui.ctx()); let mut dismiss = None; + let mut retry = false; egui::Panel::top("server_notices") .resizable(false) .frame( @@ -473,18 +506,42 @@ impl App { .inner_margin(egui::Margin::symmetric(12, 6)), ) .show(ui, |ui| { + if starting { + ui.horizontal_wrapped(|ui| { + ui.spinner(); + ui.label( + RichText::new( + "Starting the books server for your assistants: another program may still be finishing with the books.", + ) + .color(p.text), + ); + }); + } for (i, words) in self.notices.iter().enumerate() { ui.horizontal_wrapped(|ui| { ui.label(RichText::new(words).color(p.text)); + if down && ui.button("Try again").clicked() { + retry = true; + } if ui.button("Dismiss").clicked() { dismiss = Some(i); } }); } + if down && self.notices.is_empty() && ui.button("Try again").clicked() { + retry = true; + } }); + if retry { + self.serving.retry(); + } if let Some(i) = dismiss { self.notices.remove(i); } + if starting { + ui.ctx() + .request_repaint_after(std::time::Duration::from_millis(500)); + } } /// What the server work has said that has not been dismissed (tests). diff --git a/crates/ledger-gui/src/owner.rs b/crates/ledger-gui/src/owner.rs index 638dd572..5b124fa7 100644 --- a/crates/ledger-gui/src/owner.rs +++ b/crates/ledger-gui/src/owner.rs @@ -180,9 +180,17 @@ pub trait Owner: Send + Sync { fn serve_close(&self, _book: &str) -> Result, String> { Ok(None) } - /// Close the server (the window closed): its input is closed and the - /// exit waited for, for a bounded time. `Ok(Some(words))` when it is - /// still finishing by itself after that. Blocks. + /// Of the companies `wanted` (asked to be open at the start), those + /// the server does not have open now, each with why in words: asked + /// once the server is ready. Blocks. + fn serve_not_open(&self, _wanted: &[String]) -> Vec<(String, String)> { + Vec::new() + } + /// Close the server (the window closed): each open company is closed + /// first, then the server's input, and the exit is waited for, for a + /// bounded time. `Ok(Some(words))` says what was not whole, a line + /// each: a company whose last backup was incomplete, a server that + /// exited badly, one still finishing by itself after the wait. Blocks. fn serve_stop(&self) -> Result, String> { Ok(None) } diff --git a/crates/ledger-gui/src/serving.rs b/crates/ledger-gui/src/serving.rs index 24cb619f..c3ae7350 100644 --- a/crates/ledger-gui/src/serving.rs +++ b/crates/ledger-gui/src/serving.rs @@ -19,17 +19,25 @@ //! company's request waits for another company's, so closing one //! company's tab, which makes its last backup, delays no other. //! 3. No request is made before the server has started, and none after -//! a start that failed (the person was told why, once). +//! a start that failed (the person was told why, once). A start that +//! failed is tried again, with the companies wanted then, when the +//! next tab opens or the person asks (`retry`); the owner has +//! stopped the server that failed, so no second one runs beside it. +//! A server still starting is waited for, in view (`is_starting`). //! 4. A company the window opened at the start is not opened again; a -//! company whose open failed is asked for again the next time its -//! tab opens. +//! company whose open failed, at the start (the server's list says +//! it isn't open: `serve_not_open`) or later, is a notice, and is +//! asked for again the next time its tab opens. //! 5. A failed request, a close whose last backup wasn't whole, and a //! server that has exited on its own are each a notice, in words, //! once; the window shows them until they are dismissed. //! 6. The server is closed once: by `begin_stop` (the window asked to //! close, with the wait in view), else when this is dropped. Neither //! returns before the owner's bounded close has, and neither kills -//! anything. +//! anything. What the close says was not whole (a company's last +//! backup, a server that exited badly) is the close's report: the +//! window stays up showing it until the person closes anyway +//! (`close_report`, `acknowledge_close`). //! 7. Without an owner that hosts a server (the viewer on its own, the //! demo, tests) it does nothing at all. //! ``` @@ -70,6 +78,10 @@ struct State { lanes: HashMap>, /// The server's exit has been said. exit_said: bool, + /// What the server's close said was not whole, a line each. + report: Vec, + /// The person has seen the report and chose to close anyway. + report_seen: bool, } struct Inner { @@ -117,17 +129,18 @@ impl Inner { } *closing = Closing::Running; } - match self.owner.serve_stop() { - Ok(None) => {} - Ok(Some(words)) => { - // The window may be gone before anyone reads a notice. - eprintln!("wanderbooks: {words}"); - self.note(words); - } - Err(why) => self.note(format!( + let said: Vec = match self.owner.serve_stop() { + Ok(None) => Vec::new(), + Ok(Some(words)) => words.lines().map(str::to_string).collect(), + Err(why) => vec![format!( "The books server could not be closed cleanly: {why}" - )), + )], + }; + for line in &said { + // The window may be gone before anyone reads the report. + eprintln!("wanderbooks: {line}"); } + lock(&self.state).report = said; *lock(&self.closing) = Closing::Done; self.closing_changed.notify_all(); } @@ -161,21 +174,7 @@ impl Serving { ..State::default() }), }); - let starting = inner.clone(); - let spawned = std::thread::Builder::new() - .name("serving-start".into()) - .spawn(move || { - let came = match starting.owner.serve_start(&open) { - Ok(()) => Gate::Up, - Err(why) => { - starting.note(format!("Assistants can't reach your companies: {why}")); - Gate::Down - } - }; - *lock(&starting.gate) = came; - starting.gate_changed.notify_all(); - }); - if spawned.is_err() { + if !Self::spawn_start(&inner) { inner.note( "Assistants can't reach your companies: the books server could not be started." .into(), @@ -185,6 +184,86 @@ impl Serving { Self { inner: Some(inner) } } + /// Start the server, on a thread of its own, with the companies + /// wanted now (INVARIANTS 1, 3, 4): false when no thread could be made. + fn spawn_start(inner: &Arc) -> bool { + let open: Vec = lock(&inner.state).wanted.iter().cloned().collect(); + let starting = inner.clone(); + std::thread::Builder::new() + .name("serving-start".into()) + .spawn(move || { + let came = match starting.owner.serve_start(&open) { + Ok(()) => { + // The server says ready once each company was + // tried: the ones that did not open are said, and + // asked for again with their tab (INVARIANT 4). + for (id, words) in starting.owner.serve_not_open(&open) { + lock(&starting.state).wanted.remove(&id); + starting.note(words); + } + Gate::Up + } + Err(why) => { + // A window asked to close meanwhile has no use for + // the word. + if *lock(&starting.closing) == Closing::Not { + starting.note(format!("Assistants can't reach your companies: {why}")); + } + Gate::Down + } + }; + *lock(&starting.gate) = came; + starting.gate_changed.notify_all(); + }) + .is_ok() + } + + /// Try a start that failed again, with the companies wanted now + /// (INVARIANT 3): true when one has begun. + pub fn retry(&self) -> bool { + let Some(inner) = &self.inner else { + return false; + }; + Self::restart(inner) + } + + fn restart(inner: &Arc) -> bool { + if *lock(&inner.closing) != Closing::Not { + return false; + } + { + let mut gate = lock(&inner.gate); + if *gate != Gate::Down { + return false; + } + *gate = Gate::Starting; + } + if Self::spawn_start(inner) { + return true; + } + inner.note( + "Assistants can't reach your companies: the books server could not be started.".into(), + ); + *lock(&inner.gate) = Gate::Down; + false + } + + /// Whether the server is still starting (INVARIANT 3): its tabs wait + /// for it, and the window says so. + pub fn is_starting(&self) -> bool { + self.inner + .as_ref() + .is_some_and(|i| *lock(&i.gate) == Gate::Starting) + } + + /// Whether the start failed and a `retry` would try again. + pub fn is_down(&self) -> bool { + self.inner + .as_ref() + .is_some_and(|i| *lock(&i.gate) == Gate::Down) + && !self.is_closing() + } + /// Whether a server is being hosted for this window. pub fn is_on(&self) -> bool { self.inner.is_some() @@ -195,7 +274,14 @@ impl Serving { pub fn open(&self, id: &str) { let Some(inner) = &self.inner else { return }; let fresh = lock(&inner.state).wanted.insert(id.to_string()); + // After a failed start the next tab is the next try (INVARIANT 3): + // the start opens every company wanted, this one included. + // A company already wanted is the window's own start-up opening + // the tabs it restored, which the start has in its list. if fresh { + if Self::restart(inner) { + return; + } Self::send(inner, id, Cmd::Open); } } @@ -293,6 +379,31 @@ impl Serving { std::mem::take(&mut state.notices) } + /// What the server's close said was not whole, a line each, until the + /// person has closed anyway (INVARIANT 6); nothing before the close + /// is done, or when it was whole. + pub fn close_report(&self) -> Vec { + let Some(inner) = &self.inner else { + return Vec::new(); + }; + if *lock(&inner.closing) != Closing::Done { + return Vec::new(); + } + let state = lock(&inner.state); + if state.report_seen { + Vec::new() + } else { + state.report.clone() + } + } + + /// The person has read the close's report and closes anyway. + pub fn acknowledge_close(&self) { + if let Some(inner) = &self.inner { + lock(&inner.state).report_seen = true; + } + } + /// The window was asked to close: close the server on a thread of its /// own, so the window can say so while it does (INVARIANT 6). pub fn begin_stop(&self) { diff --git a/crates/ledger-gui/tests/serving.rs b/crates/ledger-gui/tests/serving.rs index 6f3507c7..6c5b7da5 100644 --- a/crates/ledger-gui/tests/serving.rs +++ b/crates/ledger-gui/tests/serving.rs @@ -23,6 +23,12 @@ //! until the owner's close has returned; the owner is asked to close //! once, however many times it is asked. //! 6. A window with no owner that hosts a server asks nothing of any. +//! 7. A start that failed is tried again by the next tab that opens, or +//! by the person (`retry`); one still going is said to be starting. +//! 8. A company wanted at the start that the server did not open is a +//! notice, and its tab asks again when it opens. +//! 9. A close that says something was not whole keeps the window up, +//! showing it, until the person closes anyway. //! ``` use egui_kittest::Harness; @@ -109,6 +115,10 @@ struct Fake { stop_says: Mutex>, /// Why the server is gone, once it is. exited: Mutex>, + /// How long starting takes. + start_takes: Mutex, + /// The wanted companies the server did not open, and why. + not_open_says: Mutex>, } impl Fake { @@ -131,11 +141,15 @@ impl Owner for Fake { } fn serve_start(&self, open: &[String]) -> Result<(), String> { self.note(format!("start {}", open.join(","))); + std::thread::sleep(*self.start_takes.lock().unwrap()); match self.start_says.lock().unwrap().clone() { Some(why) => Err(why), None => Ok(()), } } + fn serve_not_open(&self, _wanted: &[String]) -> Vec<(String, String)> { + std::mem::take(&mut *self.not_open_says.lock().unwrap()) + } fn serve_open(&self, book: &str) -> Result, String> { self.note(format!("open {book}")); match self.open_says.lock().unwrap().remove(book) { @@ -329,7 +343,13 @@ fn a_refused_start_is_said_and_nothing_is_asked_of_the_server() { app.open(&ctx, w.source("gamma")); app.close(tab_of(&app, "alpha")); a_while(); - assert_eq!(owner.said(), vec!["start alpha".to_string()]); + // The next tab is a new try at the start (INVARIANT 7), which fails + // the same way; no company is asked to open or close in a server that + // isn't there. + assert_eq!( + owner.said(), + vec!["start alpha".to_string(), "start alpha,gamma".to_string()] + ); drop(app); } @@ -423,12 +443,12 @@ fn a_server_that_will_not_exit_is_left_closing_and_the_window_closes() { until("started", || !owner.said().is_empty()); serving.begin_stop(); until("the close returned", || serving.is_closed()); - // The wait ended with the owner's word; the window can close, and the - // person is told what is left. - let notices = serving.take_notices(); + // The wait ended with the owner's word; the person is told what is + // left (the close's report, which the window shows, `close_report`). + let report = serving.close_report(); assert!( - notices.iter().any(|n| n.contains("still closing")), - "{notices:?}" + report.iter().any(|n| n.contains("still closing")), + "{report:?}" ); drop(serving); drop(w); @@ -490,3 +510,165 @@ fn a_window_with_no_server_asks_nothing_of_any() { ); assert!(!app.serving().is_on()); } + +#[test] +fn a_failed_start_is_tried_again_when_the_next_tab_opens() { + let w = World::new(&["alpha", "gamma"]); + let owner = Fake::new(); + *owner.start_says.lock().unwrap() = Some("Another program has these books open".into()); + let ctx = egui::Context::default(); + let mut app = w.start(&["alpha"], &owner); + until("the refusal is said", || { + app.notices() + .iter() + .any(|n| n.contains("Another program has these books open")) + }); + until("the start is over", || !app.serving().is_starting()); + assert!(app.serving().is_down(), "the window offers to try again"); + // Whatever held the books has let go: the next tab is the next try. + *owner.start_says.lock().unwrap() = None; + app.open(&ctx, w.source("gamma")); + until("started again", || owner.said().len() == 2); + until("up", || !app.serving().is_starting()); + a_while(); + // The new start has every company wanted, so none is asked for twice. + assert_eq!( + owner.said(), + vec!["start alpha".to_string(), "start alpha,gamma".to_string()] + ); + assert!(!app.serving().is_down()); + // And it is up: a tab closing is asked of the server now. + app.close(tab_of(&app, "gamma")); + until("gamma closed", || { + owner.said().contains(&"close gamma".to_string()) + }); + drop(app); +} + +#[test] +fn the_person_can_try_a_failed_start_again() { + let owner = Fake::new(); + *owner.start_says.lock().unwrap() = Some("the books server stopped (exit status: 1)".into()); + let serving = Serving::start(Some(owner.clone() as Arc), vec!["alpha".into()]); + until("down", || serving.is_down()); + assert!(serving.retry(), "asked again, it starts again"); + until("settled", || !serving.is_starting()); + assert!(serving.is_down(), "failed again: it can be tried again"); + *owner.start_says.lock().unwrap() = None; + assert!(serving.retry()); + until("up", || !serving.is_starting() && !serving.is_down()); + assert!(!serving.retry(), "a server that is up is not started again"); + assert_eq!( + owner + .said() + .iter() + .filter(|s| s.starts_with("start")) + .count(), + 3 + ); + let notices = serving.take_notices(); + assert_eq!(notices.len(), 2, "each failure said once: {notices:?}"); +} + +#[test] +fn a_server_still_starting_is_said_to_be_starting() { + let owner = Fake::new(); + *owner.start_takes.lock().unwrap() = Duration::from_millis(600); + let serving = Serving::start(Some(owner.clone() as Arc), vec!["alpha".into()]); + assert!(serving.is_starting()); + assert!(!serving.is_down(), "waited for, not given up on"); + until("up", || !serving.is_starting()); + assert!(!serving.is_down()); + assert!(serving.take_notices().is_empty()); +} + +#[test] +fn a_company_that_did_not_open_at_the_start_is_said_and_asked_for_again() { + let w = World::new(&["alpha", "beta"]); + let owner = Fake::new(); + *owner.not_open_says.lock().unwrap() = vec![( + "beta".into(), + "beta couldn't be opened for your assistants: a damaged line.".into(), + )]; + // The tabs are opened (and wanted) before the server says ready. + *owner.start_takes.lock().unwrap() = Duration::from_millis(300); + let ctx = egui::Context::default(); + let mut app = w.start(&["alpha", "beta"], &owner); + until("the failed open is said", || { + app.notices().iter().any(|n| n.contains("a damaged line")) + }); + assert!(!app.serving().wants("beta"), "not open in the server"); + assert!(app.serving().wants("alpha")); + // Its tab closed and opened again asks the server again. + app.close(tab_of(&app, "beta")); + a_while(); + assert!( + !owner.said().contains(&"close beta".to_string()), + "nothing to close: it was never open: {:?}", + owner.said() + ); + app.open(&ctx, w.source("beta")); + until("beta asked for", || { + owner.said().contains(&"open beta".to_string()) + }); + drop(app); +} + +#[test] +fn a_close_that_was_not_whole_keeps_the_window_up_until_the_person_closes_anyway() { + let w = World::new(&["alpha"]); + let owner = Fake::new(); + *owner.stop_says.lock().unwrap() = Some( + "alpha is closed to your assistants, but its last backup wasn't whole: the folder is gone\nThe books server ended badly (exit status: 1)." + .into(), + ); + let kept = w.kept(&["alpha"]); + let (root, fallback) = (w.root.clone(), w.source("alpha")); + let for_app: Arc = owner.clone(); + let mut h = Harness::builder() + .with_size(egui::vec2(1000.0, 700.0)) + .build_eframe(move |cc| { + App::start_with_owner( + &cc.egui_ctx, + &|k| kept.get(k).cloned(), + Start::Restore { root, fallback }, + Some(for_app), + ) + }); + h.run_steps(3); + let ask_to_close = |h: &mut Harness<'_, App>| { + h.input_mut() + .viewports + .entry(egui::ViewportId::ROOT) + .or_default() + .events + .push(egui::ViewportEvent::Close); + h.run_steps(2); + }; + ask_to_close(&mut h); + until("the close is done", || h.state().serving().is_closed()); + h.run_steps(3); + // The close is over, and the window says what was not whole. + assert!(h.query_by_label_contains("did not close cleanly").is_some()); + assert!( + h.query_by_label_contains("last backup wasn't whole") + .is_some() + ); + assert!(h.query_by_label_contains("ended badly").is_some()); + assert_eq!(h.state().serving().close_report().len(), 2); + // Asked to close again, it is not "close anyway": still up, still said. + ask_to_close(&mut h); + h.run_steps(2); + assert!(h.query_by_label_contains("did not close cleanly").is_some()); + assert_eq!(h.state().serving().close_report().len(), 2); + // The button is. + h.get_by_label("Close anyway").click(); + h.run_steps(3); + assert!(h.state().serving().close_report().is_empty()); + assert_eq!( + owner.said().iter().filter(|s| *s == "stop").count(), + 1, + "the owner closed the server once: {:?}", + owner.said() + ); +}