From 733503cd8df43b74bebff62a3258f66372395a74 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Mon, 29 Jun 2026 20:30:59 +0200 Subject: [PATCH 1/2] fix: Stop breakwater when sink crashes --- CHANGELOG.md | 5 +++++ breakwater/src/sinks/mod.rs | 44 +++++++++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7d7ea2..8a08963 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,12 @@ All notable changes to this project will be documented in this file. As this feature is mutually exclusive with `alpha` and `binary-pixel-sync`, `--all-features` will now fail to compile. Please choose the required features explicitly instead. +### Fixed + +- Let breakwater exit as soon as a sink reports an error ([#XX]). + [#84]: https://github.com/sbernauer/breakwater/pull/84 +[#XX]: https://github.com/sbernauer/breakwater/pull/XX ## [0.22.0] - 2026-06-20 diff --git a/breakwater/src/sinks/mod.rs b/breakwater/src/sinks/mod.rs index a371a24..d88bb48 100644 --- a/breakwater/src/sinks/mod.rs +++ b/breakwater/src/sinks/mod.rs @@ -128,9 +128,14 @@ pub async fn start_sinks) -> eyre::Result<()> { - tokio::signal::ctrl_c() - .await - .context("failed to wait for ctrl + c")?; +/// Blocks until either the user requests a shutdown via Ctrl+C, or one of the sinks signals +/// termination (e.g. because it crashed). Afterwards all remaining sinks are told to terminate. +async fn wait_for_shutdown( + terminate_signal_tx: broadcast::Sender<()>, + mut terminate_signal_rx: broadcast::Receiver<()>, +) -> eyre::Result<()> { + tokio::select! { + result = tokio::signal::ctrl_c() => { + result.context("failed to wait for ctrl + c")?; + } + // A sink signalled termination, e.g. because it crashed. + _ = terminate_signal_rx.recv() => {} + } - terminate_signal_tx - .send(()) - .context("failed to signal termination")?; + // Tell all remaining sinks to terminate. Best-effort: this fails if all other receivers are + // already gone (e.g. the only sink crashed and dropped its receiver), which is fine here. + let _ = terminate_signal_tx.send(()); Ok(()) } From 4669c8bff628407963cbf5cea8502490f3ab9ee5 Mon Sep 17 00:00:00 2001 From: Sebastian Bernauer Date: Mon, 29 Jun 2026 20:31:53 +0200 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a08963..0af0492 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,10 +12,10 @@ All notable changes to this project will be documented in this file. ### Fixed -- Let breakwater exit as soon as a sink reports an error ([#XX]). +- Let breakwater exit as soon as a sink reports an error ([#95]). [#84]: https://github.com/sbernauer/breakwater/pull/84 -[#XX]: https://github.com/sbernauer/breakwater/pull/XX +[#95]: https://github.com/sbernauer/breakwater/pull/95 ## [0.22.0] - 2026-06-20