updated main loop timeout
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Paul 2023-05-13 10:40:46 +02:00
parent ea0c561102
commit 40811d9754

View File

@ -2,7 +2,7 @@ use crate::config::{Context, GIT_VERSION};
use crate::fw::{fwblock, fwinit};
use crate::ip::{filter, IpData, IpEvent};
use crate::monitoring::apiserver;
use crate::utils::{gethostname, read_lines, sleep_ms};
use crate::utils::{gethostname, read_lines, sleep_s};
use crate::webservice::send_to_ipbl_api;
use crate::websocket::{send_to_ipbl_websocket, websocketpubsub, websocketreqrep};
@ -18,7 +18,7 @@ use tokio::sync::RwLock;
pub const PKG_NAME: &str = env!("CARGO_PKG_NAME");
const BL_CHAN_SIZE: usize = 32;
const WS_CHAN_SIZE: usize = 64;
const LOOPSLEEP: u64 = 500;
const LOOP_MAX_WAIT: u64 = 5;
pub async fn run() {
let globalctx = Context::new().await;
@ -113,7 +113,7 @@ pub async fn run() {
}
}
}
_val = sleep_ms(LOOPSLEEP) => {}
_val = sleep_s(LOOP_MAX_WAIT) => {}
};
let ctxclone = Arc::clone(&ctxarc);
@ -131,7 +131,7 @@ pub async fn run() {
async fn handle_cfg_reload(ctxclone: &Arc<RwLock<Context>>, last_cfg_reload: &mut DateTime<Local>) {
let now_cfg_reload = Local::now().trunc_subsecs(0);
if (now_cfg_reload - *last_cfg_reload) > Duration::seconds(5) {
if (now_cfg_reload - *last_cfg_reload) > Duration::seconds(LOOP_MAX_WAIT as i64) {
let mut ctx = ctxclone.write().await;
match ctx.load().await {
Ok(_) => {