mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-02 10:45: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},
|
atomic::{AtomicUsize, Ordering},
|
||||||
Arc,
|
Arc,
|
||||||
};
|
};
|
||||||
use std::time::Duration;
|
use std::time::{Duration, Instant};
|
||||||
use std::vec::Drain;
|
use std::vec::Drain;
|
||||||
|
|
||||||
use aquatic_common::access_list::AccessListQuery;
|
use aquatic_common::access_list::AccessListQuery;
|
||||||
|
|
@ -53,6 +53,7 @@ pub fn run_socket_worker(
|
||||||
let timeout = Duration::from_millis(50);
|
let timeout = Duration::from_millis(50);
|
||||||
|
|
||||||
let mut iter_counter = 0usize;
|
let mut iter_counter = 0usize;
|
||||||
|
let mut now = Instant::now();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
poll.poll(&mut events, Some(timeout))
|
poll.poll(&mut events, Some(timeout))
|
||||||
|
|
@ -84,14 +85,16 @@ pub fn run_socket_worker(
|
||||||
local_responses.drain(..),
|
local_responses.drain(..),
|
||||||
);
|
);
|
||||||
|
|
||||||
iter_counter += 1;
|
if iter_counter % 32 == 0 {
|
||||||
|
if now.elapsed().as_secs() >= config.cleaning.interval {
|
||||||
if iter_counter == 1000 {
|
|
||||||
connections.clean();
|
connections.clean();
|
||||||
|
|
||||||
iter_counter = 0;
|
now = Instant::now();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iter_counter = iter_counter.wrapping_add(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_socket(config: &Config) -> ::std::net::UdpSocket {
|
fn create_socket(config: &Config) -> ::std::net::UdpSocket {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue