From ea21c7a43e59b293d1d6488406460719ec1721a3 Mon Sep 17 00:00:00 2001 From: Stephen Akridge Date: Fri, 20 Jul 2018 07:05:15 -0700 Subject: [PATCH] Limit bench-tps last_id poll to prevent infinite loop --- src/bin/bench-tps.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/bin/bench-tps.rs b/src/bin/bench-tps.rs index 60a4af10ba..e2bb726cfb 100644 --- a/src/bin/bench-tps.rs +++ b/src/bin/bench-tps.rs @@ -151,13 +151,24 @@ fn generate_and_send_txs( txs as f32 / (duration_as_s(&transfer_start.elapsed())) ); - loop { + let mut found_new_last_id = false; + // try for ~5s to get a new last_id + for i in 0..32 { let new_id = client.get_last_id(); if *last_id != new_id { *last_id = new_id; + found_new_last_id = true; break; } - sleep(Duration::from_millis(100)); + if i != 0 && (i % 8) == 0 { + println!("polling for new last_id try: {}", i); + } + sleep(Duration::from_millis(200)); + } + + if !found_new_last_id { + println!("Error: Couldn't get new last id!"); + exit(1); } }