mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
http: rewrite retain function
This commit is contained in:
parent
9b85fa31d1
commit
a348fcfd2d
1 changed files with 5 additions and 6 deletions
|
|
@ -73,7 +73,6 @@ pub async fn run_socket_worker(
|
|||
|
||||
let connection_slab = Rc::new(RefCell::new(Slab::new()));
|
||||
|
||||
// Periodically remove closed connections
|
||||
TimerActionRepeat::repeat(enclose!((config, connection_slab) move || {
|
||||
clean_connections(
|
||||
config.clone(),
|
||||
|
|
@ -139,15 +138,15 @@ async fn clean_connections(
|
|||
let now = Instant::now();
|
||||
|
||||
connection_slab.borrow_mut().retain(|_, reference| {
|
||||
let keep = reference.valid_until.0 > now;
|
||||
|
||||
if !keep {
|
||||
if reference.valid_until.0 > now {
|
||||
true
|
||||
} else {
|
||||
if let Some(ref handle) = reference.task_handle {
|
||||
handle.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
keep
|
||||
false
|
||||
}
|
||||
});
|
||||
|
||||
connection_slab.borrow_mut().shrink_to_fit();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue