mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
aquatic_udp: glommio: fix access list update bug
This commit is contained in:
parent
af5816e2ab
commit
ead7650d41
1 changed files with 9 additions and 5 deletions
|
|
@ -1,3 +1,4 @@
|
|||
use std::borrow::Borrow;
|
||||
use std::cell::RefCell;
|
||||
use std::rc::Rc;
|
||||
|
||||
|
|
@ -8,18 +9,19 @@ use glommio::prelude::*;
|
|||
use crate::common::*;
|
||||
use crate::config::Config;
|
||||
|
||||
pub async fn update_access_list(config: Config, access_list: Rc<RefCell<AccessList>>) {
|
||||
if config.access_list.mode.is_on() {
|
||||
match BufferedFile::open(config.access_list.path).await {
|
||||
pub async fn update_access_list<C: Borrow<Config>>(config: C, access_list: Rc<RefCell<AccessList>>) {
|
||||
if config.borrow().access_list.mode.is_on() {
|
||||
match BufferedFile::open(&config.borrow().access_list.path).await {
|
||||
Ok(file) => {
|
||||
let mut reader = StreamReaderBuilder::new(file).build();
|
||||
let mut new_access_list = AccessList::default();
|
||||
|
||||
loop {
|
||||
let mut buf = String::with_capacity(42);
|
||||
|
||||
match reader.read_line(&mut buf).await {
|
||||
Ok(_) => {
|
||||
if let Err(err) = access_list.borrow_mut().insert_from_line(&buf) {
|
||||
if let Err(err) = new_access_list.insert_from_line(&buf) {
|
||||
::log::error!(
|
||||
"Couln't parse access list line '{}': {:?}",
|
||||
buf,
|
||||
|
|
@ -36,10 +38,12 @@ pub async fn update_access_list(config: Config, access_list: Rc<RefCell<AccessLi
|
|||
|
||||
yield_if_needed().await;
|
||||
}
|
||||
|
||||
*access_list.borrow_mut() = new_access_list;
|
||||
}
|
||||
Err(err) => {
|
||||
::log::error!("Couldn't open access list file: {:?}", err)
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue