Skip to content

Commit

Permalink
break thread loop if receiver happens to be dropped
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillLykov committed Mar 22, 2024
1 parent 35aa38b commit 5f83197
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions bench-tps/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ fn do_tx_transfers<T: BenchTpsClient + ?Sized>(
signatures_sender: Option<SignatureBatchSender>,
) {
let mut last_sent_time = timestamp();
loop {
'thread_loop: loop {
if thread_batch_sleep_ms > 0 {
sleep(Duration::from_millis(thread_batch_sleep_ms as u64));
}
Expand Down Expand Up @@ -995,16 +995,13 @@ fn do_tx_transfers<T: BenchTpsClient + ?Sized>(
}

if let Some(signatures_sender) = &signatures_sender {
if signatures_sender
.send(TransactionInfoBatch {
signatures,
sent_at: Utc::now(),
compute_unit_prices,
})
.is_err()
{
error!("Receiver has been dropped, stop sending transactions.");
break;
if let Err(error) = signatures_sender.send(TransactionInfoBatch {
signatures,
sent_at: Utc::now(),
compute_unit_prices,
}) {
error!("Receiver has been dropped with error `{error}`, stop sending transactions.");
break 'thread_loop;
}
}

Expand Down

0 comments on commit 5f83197

Please sign in to comment.