mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 10:15:31 +00:00
aquatic_udp: mio: rewrite connection cleaning interval logic
This commit is contained in:
parent
03a344eb8e
commit
1949ed2e9c
1 changed files with 5 additions and 3 deletions
|
|
@ -53,7 +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();
|
let mut last_cleaning = Instant::now();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
poll.poll(&mut events, Some(timeout))
|
poll.poll(&mut events, Some(timeout))
|
||||||
|
|
@ -86,10 +86,12 @@ pub fn run_socket_worker(
|
||||||
);
|
);
|
||||||
|
|
||||||
if iter_counter % 32 == 0 {
|
if iter_counter % 32 == 0 {
|
||||||
if now.elapsed().as_secs() >= config.cleaning.interval {
|
let now = Instant::now();
|
||||||
|
|
||||||
|
if last_cleaning + Duration::from_secs(config.cleaning.interval) > now {
|
||||||
connections.clean();
|
connections.clean();
|
||||||
|
|
||||||
now = Instant::now();
|
last_cleaning = now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue