mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 18:25:30 +00:00
aquatic_udp: glommio: setup timer to update peer_valid_until
This commit is contained in:
parent
184a2c291b
commit
1dcc48ee67
2 changed files with 13 additions and 4 deletions
|
|
@ -68,8 +68,16 @@ async fn handle_request_stream<S>(
|
|||
{
|
||||
let mut rng = SmallRng::from_entropy();
|
||||
|
||||
// Needs to be updated periodically: use timer?
|
||||
let peer_valid_until = ValidUntil::new(config.cleaning.max_peer_age);
|
||||
let max_peer_age = config.cleaning.max_peer_age;
|
||||
let peer_valid_until = Rc::new(RefCell::new(ValidUntil::new(max_peer_age)));
|
||||
|
||||
TimerActionRepeat::repeat(enclose!((peer_valid_until) move || {
|
||||
enclose!((peer_valid_until) move || async move {
|
||||
*peer_valid_until.borrow_mut() = ValidUntil::new(max_peer_age);
|
||||
|
||||
Some(Duration::from_secs(1))
|
||||
})()
|
||||
}));
|
||||
|
||||
while let Some((producer_index, request, addr)) = stream.next().await {
|
||||
let response = match addr.ip() {
|
||||
|
|
@ -79,7 +87,7 @@ async fn handle_request_stream<S>(
|
|||
&mut torrents.borrow_mut().ipv4,
|
||||
request,
|
||||
ip,
|
||||
peer_valid_until,
|
||||
peer_valid_until.borrow().to_owned(),
|
||||
),
|
||||
IpAddr::V6(ip) => handle_announce_request(
|
||||
&config,
|
||||
|
|
@ -87,7 +95,7 @@ async fn handle_request_stream<S>(
|
|||
&mut torrents.borrow_mut().ipv6,
|
||||
request,
|
||||
ip,
|
||||
peer_valid_until,
|
||||
peer_valid_until.borrow().to_owned(),
|
||||
),
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue