Skip to content

Commit 82a2f8c

Browse files
committed
Address comments
1 parent 4209de5 commit 82a2f8c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

apps/quorum/src/server.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ lazy_static! {
8080
/// happened after the subscribe, so it means all listeners should always be notified
8181
/// correctly.
8282
83-
// Make sure at least one receiver is created
84-
static ref EXIT_CHANNEL: (watch::Sender<bool>, watch::Receiver<bool>) = watch::channel(false);
85-
pub static ref EXIT: watch::Sender<bool> = EXIT_CHANNEL.0.clone();
83+
static ref EXIT: watch::Sender<bool> = watch::channel(false).0;
8684
}
8785

8886
pub async fn wait_for_exit() {
8987
let mut rx = EXIT.subscribe();
90-
if !*rx.borrow() {
88+
// Check if the exit flag is already set, if so, we don't need to wait.
89+
if !(*rx.borrow()) {
90+
// Wait until the exit flag is set.
9191
let _ = rx.changed().await;
9292
}
9393
}
@@ -136,7 +136,7 @@ where
136136
},
137137
Err(err) => {
138138
tracing::error!("{} is panicked or canceled: {:?}", name, err);
139-
let _ = EXIT.send(true);
139+
EXIT.send_modify(|exit| *exit = true);
140140
break;
141141
}
142142
}
@@ -149,7 +149,7 @@ pub async fn run(run_options: RunOptions) -> anyhow::Result<()> {
149149
tracing::info!("Registered shutdown signal handler...");
150150
tokio::signal::ctrl_c().await.unwrap();
151151
tracing::info!("Shut down signal received, waiting for tasks...");
152-
let _ = EXIT.send(true);
152+
EXIT.send_modify(|exit| *exit = true);
153153
});
154154

155155
let guardian_set = fetch_guardian_set(

0 commit comments

Comments
 (0)