Skip to content

Commit e091a3b

Browse files
committed
signal shutdown on tpu_to_pack channel drop
1 parent 1912839 commit e091a3b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

core/src/banking_stage.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@ mod external {
783783
// Spawn tpu to pack.
784784
threads.push(tpu_to_pack::spawn(
785785
self.worker_exit_signal.clone(),
786+
self.banking_shutdown_signal.clone(),
786787
tpu_to_pack_receivers,
787788
tpu_to_pack,
788789
));

core/src/banking_stage/tpu_to_pack.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use {
1818
thread::JoinHandle,
1919
time::Duration,
2020
},
21+
tokio_util::sync::CancellationToken,
2122
};
2223

2324
pub struct BankingPacketReceivers {
@@ -29,6 +30,7 @@ pub struct BankingPacketReceivers {
2930
/// Spawns a thread to receive packets from TPU and send them to the external scheduler.
3031
pub fn spawn(
3132
exit: Arc<AtomicBool>,
33+
shutdown_signal: CancellationToken,
3234
receivers: BankingPacketReceivers,
3335
AgaveTpuToPackSession {
3436
allocator,
@@ -38,13 +40,14 @@ pub fn spawn(
3840
std::thread::Builder::new()
3941
.name("solTpu2Pack".to_string())
4042
.spawn(move || {
41-
tpu_to_pack(exit, receivers, allocator, producer);
43+
tpu_to_pack(exit, shutdown_signal, receivers, allocator, producer);
4244
})
4345
.unwrap()
4446
}
4547

4648
fn tpu_to_pack(
4749
exit: Arc<AtomicBool>,
50+
shutdown_signal: CancellationToken,
4851
receivers: BankingPacketReceivers,
4952
allocator: Allocator,
5053
mut producer: shaq::Producer<TpuToPackMessage>,
@@ -68,7 +71,9 @@ fn tpu_to_pack(
6871
} {
6972
Ok(packet_batches) => packet_batches,
7073
Err(crossbeam_channel::RecvError) => {
71-
// Senders have been dropped, exit the loop.
74+
// Senders have been dropped, signal shutdown and exit.
75+
shutdown_signal.cancel();
76+
7277
break;
7378
}
7479
};

0 commit comments

Comments
 (0)