mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 02:05:30 +00:00
aquatic_udp: mio: actually clean connections according to config
This commit is contained in:
parent
b2347ef3b0
commit
143585792c
1 changed files with 9 additions and 6 deletions
|
|
@ -4,7 +4,7 @@ use std::sync::{
|
|||
atomic::{AtomicUsize, Ordering},
|
||||
Arc,
|
||||
};
|
||||
use std::time::Duration;
|
||||
use std::time::{Duration, Instant};
|
||||
use std::vec::Drain;
|
||||
|
||||
use aquatic_common::access_list::AccessListQuery;
|
||||
|
|
@ -53,6 +53,7 @@ pub fn run_socket_worker(
|
|||
let timeout = Duration::from_millis(50);
|
||||
|
||||
let mut iter_counter = 0usize;
|
||||
let mut now = Instant::now();
|
||||
|
||||
loop {
|
||||
poll.poll(&mut events, Some(timeout))
|
||||
|
|
@ -84,13 +85,15 @@ pub fn run_socket_worker(
|
|||
local_responses.drain(..),
|
||||
);
|
||||
|
||||
iter_counter += 1;
|
||||
if iter_counter % 32 == 0 {
|
||||
if now.elapsed().as_secs() >= config.cleaning.interval {
|
||||
connections.clean();
|
||||
|
||||
if iter_counter == 1000 {
|
||||
connections.clean();
|
||||
|
||||
iter_counter = 0;
|
||||
now = Instant::now();
|
||||
}
|
||||
}
|
||||
|
||||
iter_counter = iter_counter.wrapping_add(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue