Skip to content

Commit 148e745

Browse files
committed
fix: fix pending restart implementation
1 parent f50694a commit 148e745

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src-tauri/src/manager.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,14 @@ impl ManagerState {
8282
self.modules_running.insert(name.to_string(), true);
8383
self.modules_pid.insert(name.to_string(), pid);
8484
self.modules_args.insert(name.to_string(), args);
85+
self.modules_pending_shutdown.remove(name);
8586
debug!("Running modules: {:?}", self.modules_running);
8687
self.update_tray_menu();
8788
}
8889
fn stopped_module(&mut self, name: &str) {
8990
info!("Stopped module: {name}");
9091
self.modules_running.insert(name.to_string(), false);
9192
self.modules_pid.remove(name);
92-
self.modules_pending_shutdown.remove(name);
9393
self.update_tray_menu();
9494
}
9595
fn update_tray_menu(&mut self) {
@@ -281,20 +281,23 @@ fn handle(rx: Receiver<ModuleMessage>, state: Arc<Mutex<ManagerState>>) {
281281
error!("Module {name} exited with error status");
282282
thread::spawn(move || {
283283
thread::sleep(Duration::from_secs(1));
284-
let state = &state_clone.lock().unwrap();
284+
let state = &mut state_clone.lock().unwrap();
285285
let restart_count =
286286
state.modules_restart_count.get(&name_clone).unwrap_or(&0);
287287

288288
let pending_shutdown = state
289289
.modules_pending_shutdown
290290
.get(&name_clone)
291291
.unwrap_or(&false);
292-
let _ = state;
293-
if *restart_count < 3 && !*pending_shutdown {
294-
let mut state = state_clone.lock().unwrap();
292+
293+
if *pending_shutdown {
294+
return;
295+
}
296+
if *restart_count < 3 {
297+
let new_count = *restart_count + 1;
295298
state
296299
.modules_restart_count
297-
.insert(name_clone.clone(), *restart_count + 1);
300+
.insert(name_clone.clone(), new_count);
298301
// Get the stored arguments for this module
299302
let stored_args =
300303
state.modules_args.get(&name_clone).cloned().flatten();

0 commit comments

Comments
 (0)