diff --git a/tower-batch/src/worker.rs b/tower-batch/src/worker.rs index 4137dfed..6fc58e3c 100644 --- a/tower-batch/src/worker.rs +++ b/tower-batch/src/worker.rs @@ -143,6 +143,7 @@ where }, Some(mut sleep) => { // Wait on either a new message or the batch timer. + // If both are ready, select! chooses one of them at random. tokio::select! { maybe_msg = self.rx.recv() => match maybe_msg { Some(msg) => { diff --git a/zebrad/src/components/inbound/downloads.rs b/zebrad/src/components/inbound/downloads.rs index 8492ae90..54e2bc90 100644 --- a/zebrad/src/components/inbound/downloads.rs +++ b/zebrad/src/components/inbound/downloads.rs @@ -223,6 +223,8 @@ where .in_current_span(); let task = tokio::spawn(async move { + // TODO: if the verifier and cancel are both ready, which should we + // prefer? (Currently, select! chooses one at random.) tokio::select! { _ = &mut cancel_rx => { tracing::trace!("task cancelled prior to completion"); diff --git a/zebrad/src/components/sync/downloads.rs b/zebrad/src/components/sync/downloads.rs index 0751f42a..01f81817 100644 --- a/zebrad/src/components/sync/downloads.rs +++ b/zebrad/src/components/sync/downloads.rs @@ -149,6 +149,8 @@ where let mut verifier = self.verifier.clone(); let task = tokio::spawn( async move { + // TODO: if the verifier and cancel are both ready, which should + // we prefer? (Currently, select! chooses one at random.) let rsp = tokio::select! { _ = &mut cancel_rx => { tracing::trace!("task cancelled prior to download completion"); @@ -169,6 +171,8 @@ where metrics::counter!("sync.downloaded.block.count", 1); let rsp = verifier.ready_and().await?.call(block); + // TODO: if the verifier and cancel are both ready, which should + // we prefer? (Currently, select! chooses one at random.) let verification = tokio::select! { _ = &mut cancel_rx => { tracing::trace!("task cancelled prior to verification"); diff --git a/zebrad/src/components/tokio.rs b/zebrad/src/components/tokio.rs index 1f39d5ca..49c13c56 100644 --- a/zebrad/src/components/tokio.rs +++ b/zebrad/src/components/tokio.rs @@ -46,6 +46,8 @@ pub(crate) trait RuntimeRun { impl RuntimeRun for Runtime { fn run(&mut self, fut: impl Future>) { let result = self.block_on(async move { + // If the run task and shutdown are both ready, select! chooses + // one of them at random. tokio::select! { result = fut => result, _ = shutdown() => Ok(()), @@ -68,6 +70,7 @@ mod imp { use tracing::info; pub(super) async fn shutdown() { + // If both signals are received, select! chooses one of them at random. tokio::select! { // SIGINT - Terminal interrupt signal. Typically generated by shells in response to Ctrl-C. () = sig(SignalKind::interrupt(), "SIGINT") => {}