mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
aquatic_http: glommio: remove closed connections in own fn
This commit is contained in:
parent
f767e8a6fa
commit
a9b8b0224d
1 changed files with 26 additions and 16 deletions
|
|
@ -89,22 +89,11 @@ pub async fn run_socket_worker(
|
|||
// Periodically remove closed connections
|
||||
TimerActionRepeat::repeat(
|
||||
enclose!((config, connection_slab, connections_to_remove) move || {
|
||||
enclose!((config, connection_slab, connections_to_remove) move || async move {
|
||||
let connections_to_remove = connections_to_remove.replace(Vec::new());
|
||||
|
||||
for connection_id in connections_to_remove {
|
||||
if let Some(_) = connection_slab.borrow_mut().try_remove(connection_id) {
|
||||
::log::debug!("removed connection with id {}", connection_id);
|
||||
} else {
|
||||
::log::error!(
|
||||
"couldn't remove connection with id {}, it is not in connection slab",
|
||||
connection_id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Some(Duration::from_secs(config.cleaning.interval))
|
||||
})()
|
||||
remove_closed_connections(
|
||||
config.clone(),
|
||||
connection_slab.clone(),
|
||||
connections_to_remove.clone(),
|
||||
)
|
||||
}),
|
||||
);
|
||||
|
||||
|
|
@ -151,6 +140,27 @@ pub async fn run_socket_worker(
|
|||
}
|
||||
}
|
||||
|
||||
async fn remove_closed_connections(
|
||||
config: Rc<Config>,
|
||||
connection_slab: Rc<RefCell<Slab<ConnectionReference>>>,
|
||||
connections_to_remove: Rc<RefCell<Vec<usize>>>,
|
||||
) -> Option<Duration> {
|
||||
let connections_to_remove = connections_to_remove.replace(Vec::new());
|
||||
|
||||
for connection_id in connections_to_remove {
|
||||
if let Some(_) = connection_slab.borrow_mut().try_remove(connection_id) {
|
||||
::log::debug!("removed connection with id {}", connection_id);
|
||||
} else {
|
||||
::log::error!(
|
||||
"couldn't remove connection with id {}, it is not in connection slab",
|
||||
connection_id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Some(Duration::from_secs(config.cleaning.interval))
|
||||
}
|
||||
|
||||
async fn receive_responses(
|
||||
mut response_receiver: ConnectedReceiver<ChannelResponse>,
|
||||
connection_references: Rc<RefCell<Slab<ConnectionReference>>>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue