From bfb2dba0c2ef96a12f8630b863cf25c2dc4f8eb3 Mon Sep 17 00:00:00 2001 From: Daniel Karzel Date: Mon, 15 Nov 2021 12:19:15 +1100 Subject: [PATCH] Make sure not to fail in for loop sending to takers --- daemon/src/maker_inc_connections.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/daemon/src/maker_inc_connections.rs b/daemon/src/maker_inc_connections.rs index 5081576..a504db7 100644 --- a/daemon/src/maker_inc_connections.rs +++ b/daemon/src/maker_inc_connections.rs @@ -157,9 +157,16 @@ impl Actor { async fn handle_broadcast_order(&mut self, msg: BroadcastOrder) -> Result<()> { let order = msg.0; for (taker_id, conn) in self.write_connections.clone() { - tracing::trace!(%taker_id, "sending new order for broadcast to connection: {:?}", order); - conn.do_send_async(wire::MakerToTaker::CurrentOrder(order.clone())) - .await?; + if conn + .do_send_async(wire::MakerToTaker::CurrentOrder(order.clone())) + .await + .is_err() + { + tracing::trace!(%taker_id, "removing outdated connection to taker because unable to send order: {:?}", order); + self.write_connections.remove(&taker_id); + } else { + tracing::trace!(%taker_id, "sent new order: {:?}", order); + } } Ok(()) }