From 828611c0e4942d134c764e525a3c1b2f21e2c2ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20K=C3=B6sters?= Date: Tue, 31 Aug 2021 22:04:47 +0200 Subject: [PATCH] improvement: stop prev event fetching if too many events fail --- src/server_server.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/server_server.rs b/src/server_server.rs index dee92e86..e2b13441 100644 --- a/src/server_server.rs +++ b/src/server_server.rs @@ -1084,7 +1084,11 @@ pub(crate) async fn handle_incoming_pdu<'a>( }) .map_err(|_| "Error sorting prev events".to_owned())?; + let mut errors = 0; for prev_id in dbg!(sorted) { + if errors >= 5 { + break; + } if let Some((pdu, json)) = eventid_info.remove(&prev_id) { let start_time = Instant::now(); let event_id = pdu.event_id.clone(); @@ -1099,6 +1103,7 @@ pub(crate) async fn handle_incoming_pdu<'a>( ) .await { + errors += 1; warn!("Prev event {} failed: {}", event_id, e); } let elapsed = start_time.elapsed();