Skip to content

Commit cfb11ef

Browse files
committed
Enable exiting while loading alarms
1 parent 91b8398 commit cfb11ef

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/sites.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use shvclient::clientapi::{CallRpcMethodErrorKind, RpcCall, RpcCallDirExists, Rp
1010
use shvclient::clientnode::{METH_DIR, SIG_CHNG};
1111
use shvclient::{ClientCommandSender, ClientEvent, ClientEventsReceiver};
1212
use shvproto::{DateTime, RpcValue};
13-
use shvrpc::rpcmessage::RpcError;
13+
use shvrpc::rpcmessage::{RpcError, RpcErrorCode};
1414
use shvrpc::typeinfo::TypeInfo;
1515
use shvrpc::util::find_longest_path_prefix;
1616
use shvrpc::{join_path, RpcMessageMetaTags};
@@ -552,6 +552,11 @@ async fn reload_sites(
552552
.acquire()
553553
.await
554554
.unwrap_or_else(|e| panic!("Cannot acquire semaphore: {e}"));
555+
556+
if app_state.app_closing.load(std::sync::atomic::Ordering::Relaxed) {
557+
return (site_path, type_info, Err(RpcError::new(RpcErrorCode::InternalError, "App is closing")));
558+
}
559+
555560
let log = getlog_handler(&site_path, &params, app_state).await;
556561
(site_path, type_info, log)
557562
}
@@ -561,7 +566,9 @@ async fn reload_sites(
561566
match result {
562567
Ok(log) => Some((site_path, type_info, log)),
563568
Err(err) => {
564-
log::error!("couldn't init alarms: getlog failed: {err}");
569+
if !app_state.app_closing.load(std::sync::atomic::Ordering::Relaxed) {
570+
log::error!("couldn't init alarms: getlog failed: {err}");
571+
}
565572
None
566573
}
567574
}

0 commit comments

Comments
 (0)