Skip to content

Commit

Permalink
remove the last use of the shutdown channel from the codebase, the si…
Browse files Browse the repository at this point in the history
…gint watcher now only cancels that token
  • Loading branch information
albertotirla committed Mar 9, 2024
1 parent 9687a0d commit eb00bf1
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions odilia/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use odilia_notify::listen_to_dbus_notifications;
use ssip_client_async::Priority;
use tokio::{
signal::unix::{signal, SignalKind},
sync::broadcast::{self, error::SendError},
sync::mpsc,
};
use tokio_util::sync::CancellationToken;
Expand All @@ -51,15 +50,11 @@ async fn notifications_monitor(
}
Ok(())
}
async fn sigterm_signal_watcher(
token: CancellationToken,
shutdown_tx: broadcast::Sender<i32>,
) -> eyre::Result<()> {
async fn sigterm_signal_watcher(token: CancellationToken) -> eyre::Result<()> {

Check warning on line 53 in odilia/src/main.rs

View check run for this annotation

Codecov / codecov/patch

odilia/src/main.rs#L53

Added line #L53 was not covered by tests
let mut c = signal(SignalKind::interrupt())?;
tracing::debug!("Watching for Ctrl+C");
c.recv().await;
tracing::debug!("Asking all processes to stop.");
let _: Result<usize, SendError<i32>> = shutdown_tx.send(0);
tracing::debug!("cancelling all tokens");
token.cancel();

Check warning on line 59 in odilia/src/main.rs

View check run for this annotation

Codecov / codecov/patch

odilia/src/main.rs#L58-L59

Added lines #L58 - L59 were not covered by tests
Ok(())
Expand All @@ -77,7 +72,6 @@ async fn main() -> eyre::Result<()> {
if let Err(e) = atspi_connection::set_session_accessibility(true).await {
tracing::debug!("Could not set AT-SPI2 IsEnabled property because: {}", e);
}
let (shutdown_tx, _) = broadcast::channel(1);
let (sr_event_tx, mut sr_event_rx) = mpsc::channel(128);
// this channel must NEVER fill up; it will cause the thread receiving events to deadlock due to a zbus design choice.
// If you need to make it bigger, then make it bigger, but do NOT let it ever fill up.
Expand Down Expand Up @@ -124,7 +118,7 @@ async fn main() -> eyre::Result<()> {
.map(|r| r.wrap_err("Could not process Odilia event"));
let notification_task = notifications_monitor(Arc::clone(&state), token.clone())

Check warning on line 119 in odilia/src/main.rs

View check run for this annotation

Codecov / codecov/patch

odilia/src/main.rs#L116-L119

Added lines #L116 - L119 were not covered by tests
.map(|r| r.wrap_err("Could not process signal shutdown."));
let signal_receiver = sigterm_signal_watcher(token, shutdown_tx)
let signal_receiver = sigterm_signal_watcher(token)

Check warning on line 121 in odilia/src/main.rs

View check run for this annotation

Codecov / codecov/patch

odilia/src/main.rs#L121

Added line #L121 was not covered by tests
.map(|r| r.wrap_err("Could not process signal shutdown."));

tokio::try_join!(
Expand Down

0 comments on commit eb00bf1

Please sign in to comment.