Set settings twice when dirty, to be extra sure settings are set when set and not unset when set set set set
This commit is contained in:
parent
f4e94d9e7d
commit
11c1fc0ddc
2 changed files with 9 additions and 5 deletions
|
@ -218,12 +218,14 @@ pub struct ApiMessageHandler {
|
||||||
|
|
||||||
impl ApiMessageHandler {
|
impl ApiMessageHandler {
|
||||||
pub fn process_forever(&mut self, settings: &mut Settings) {
|
pub fn process_forever(&mut self, settings: &mut Settings) {
|
||||||
|
let mut dirty_echo = true; // set everything twice, to make sure PowerTools wins on race conditions
|
||||||
while let Ok(msg) = self.intake.recv() {
|
while let Ok(msg) = self.intake.recv() {
|
||||||
let mut dirty = self.process(settings, msg);
|
let mut dirty = self.process(settings, msg);
|
||||||
while let Ok(msg) = self.intake.try_recv() {
|
while let Ok(msg) = self.intake.try_recv() {
|
||||||
dirty |= self.process(settings, msg);
|
dirty |= self.process(settings, msg);
|
||||||
}
|
}
|
||||||
if dirty {
|
if dirty || dirty_echo {
|
||||||
|
dirty_echo = dirty; // echo only once
|
||||||
// run on_set
|
// run on_set
|
||||||
if let Err(e) = settings.on_set() {
|
if let Err(e) = settings.on_set() {
|
||||||
log::error!("Settings on_set() err: {}", e);
|
log::error!("Settings on_set() err: {}", e);
|
||||||
|
|
|
@ -69,10 +69,6 @@ fn main() -> Result<(), ()> {
|
||||||
//let (_save_handle, save_sender) = save_worker::spawn(loaded_settings.clone());
|
//let (_save_handle, save_sender) = save_worker::spawn(loaded_settings.clone());
|
||||||
let _resume_handle = resume_worker::spawn(api_sender.clone());
|
let _resume_handle = resume_worker::spawn(api_sender.clone());
|
||||||
|
|
||||||
if let Err(e) = loaded_settings.on_set() {
|
|
||||||
log::error!("Startup Settings.on_set() error: {}", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
let instance = Instance::new(PORT)
|
let instance = Instance::new(PORT)
|
||||||
.register("V_INFO", |_: Vec<Primitive>| {
|
.register("V_INFO", |_: Vec<Primitive>| {
|
||||||
vec![format!("{} v{}", PACKAGE_NAME, PACKAGE_VERSION).into()]
|
vec![format!("{} v{}", PACKAGE_NAME, PACKAGE_VERSION).into()]
|
||||||
|
@ -225,6 +221,12 @@ fn main() -> Result<(), ()> {
|
||||||
)
|
)
|
||||||
.register("GENERAL_idk", api::general::gunter);
|
.register("GENERAL_idk", api::general::gunter);
|
||||||
|
|
||||||
|
if let Err(e) = loaded_settings.on_set() {
|
||||||
|
log::error!("Startup Settings.on_set() error: {}", e);
|
||||||
|
} else {
|
||||||
|
log::info!("Startup Settings.on_set() success");
|
||||||
|
}
|
||||||
|
|
||||||
api_worker::spawn(loaded_settings, api_handler);
|
api_worker::spawn(loaded_settings, api_handler);
|
||||||
|
|
||||||
instance
|
instance
|
||||||
|
|
Loading…
Reference in a new issue