From 9dc615a8f923ea92ef5f7e0f277122d340b1f1da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Tue, 19 Oct 2021 02:11:27 +0200 Subject: [PATCH] aquatic_udp: glommio: add yield_if_needed(), add comment --- aquatic_udp/src/lib/glommio/handlers.rs | 3 +++ aquatic_udp/src/lib/glommio/network.rs | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/aquatic_udp/src/lib/glommio/handlers.rs b/aquatic_udp/src/lib/glommio/handlers.rs index 3d52f93..d7b5220 100644 --- a/aquatic_udp/src/lib/glommio/handlers.rs +++ b/aquatic_udp/src/lib/glommio/handlers.rs @@ -3,6 +3,7 @@ use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}; use futures_lite::stream::empty; use futures_lite::StreamExt; use glommio::channels::channel_mesh::{MeshBuilder, Partial, Role}; +use glommio::prelude::*; use rand::prelude::SmallRng; use rand::SeedableRng; @@ -56,5 +57,7 @@ pub async fn run_request_worker( if let Err(err) = response_senders.try_send_to(producer_index, (response, addr)) { ::log::warn!("response_sender.try_send: {:?}", err); } + + yield_if_needed().await; } } diff --git a/aquatic_udp/src/lib/glommio/network.rs b/aquatic_udp/src/lib/glommio/network.rs index daa9a2d..834d07a 100644 --- a/aquatic_udp/src/lib/glommio/network.rs +++ b/aquatic_udp/src/lib/glommio/network.rs @@ -65,9 +65,10 @@ async fn read_requests( ) { let mut rng = StdRng::from_entropy(); - let valid_until = ValidUntil::new(config.cleaning.max_connection_age); let access_list_mode = config.access_list.mode; + // Needs to be updated periodically: use timer? + let valid_until = ValidUntil::new(config.cleaning.max_connection_age); // Needs to be updated periodically: use timer? let access_list = AccessList::default(); // Needs to be cleaned periodically: use timer?