aquatic_udp: glommio: use signals for access list update

This commit is contained in:
Joakim Frostegård 2021-11-02 22:23:47 +01:00
parent a4d131359c
commit fdaafae4b7
7 changed files with 97 additions and 105 deletions

View file

@ -4,7 +4,7 @@ use std::path::PathBuf;
use std::sync::Arc;
use anyhow::Context;
use arc_swap::ArcSwap;
use arc_swap::{ArcSwap, Cache};
use hashbrown::HashSet;
use serde::{Deserialize, Serialize};
@ -85,6 +85,7 @@ pub trait AccessListQuery {
}
pub type AccessListArcSwap = ArcSwap<AccessList>;
pub type AccessListCache = Cache<Arc<AccessListArcSwap>, Arc<AccessList>>;
impl AccessListQuery for AccessListArcSwap {
fn update(&self, config: &AccessListConfig) -> anyhow::Result<()> {
@ -102,6 +103,10 @@ impl AccessListQuery for AccessListArcSwap {
}
}
pub fn create_access_list_cache(arc_swap: &Arc<AccessListArcSwap>) -> AccessListCache {
Cache::from(Arc::clone(arc_swap))
}
fn parse_info_hash(line: &str) -> anyhow::Result<[u8; 20]> {
let mut bytes = [0u8; 20];