mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
Don't unwrap() - use a result for proper error handling and not terminating the queue tracking when monitor mode or something unexpected happens.
This commit is contained in:
parent
c2ae327c48
commit
66356d66d2
@ -11,6 +11,7 @@ use tokio::{join, task, time};
|
|||||||
mod queue_reader;
|
mod queue_reader;
|
||||||
use lazy_static::*;
|
use lazy_static::*;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
const NUM_QUEUE_HISTORY: usize = 600;
|
const NUM_QUEUE_HISTORY: usize = 600;
|
||||||
|
|
||||||
@ -59,19 +60,18 @@ lazy_static! {
|
|||||||
RwLock::new(HashMap::new());
|
RwLock::new(HashMap::new());
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn track_queues() {
|
async fn track_queues() -> Result<()> {
|
||||||
let config = LibreQoSConfig::load().unwrap();
|
let config = LibreQoSConfig::load()?;
|
||||||
let queues = if config.on_a_stick_mode {
|
let queues = if config.on_a_stick_mode {
|
||||||
let queues = queue_reader::read_tc_queues(&config.internet_interface)
|
let queues = queue_reader::read_tc_queues(&config.internet_interface)
|
||||||
.await
|
.await?;
|
||||||
.unwrap();
|
|
||||||
vec![queues]
|
vec![queues]
|
||||||
} else {
|
} else {
|
||||||
let (isp, internet) = join! {
|
let (isp, internet) = join! {
|
||||||
queue_reader::read_tc_queues(&config.isp_interface),
|
queue_reader::read_tc_queues(&config.isp_interface),
|
||||||
queue_reader::read_tc_queues(&config.internet_interface),
|
queue_reader::read_tc_queues(&config.internet_interface),
|
||||||
};
|
};
|
||||||
vec![isp.unwrap(), internet.unwrap()]
|
vec![isp?, internet?]
|
||||||
};
|
};
|
||||||
|
|
||||||
// Time to associate queues with circuits
|
// Time to associate queues with circuits
|
||||||
@ -152,6 +152,8 @@ async fn track_queues() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
Loading…
Reference in New Issue
Block a user