mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +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 mut iter_counter = 0usize;
|
||||
let mut now = Instant::now();
|
||||
let mut last_cleaning = Instant::now();
|
||||
|
||||
loop {
|
||||
poll.poll(&mut events, Some(timeout))
|
||||
|
|
@ -86,10 +86,12 @@ pub fn run_socket_worker(
|
|||
);
|
||||
|
||||
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();
|
||||
|
||||
now = Instant::now();
|
||||
last_cleaning = now;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue