Skip to content

Commit 5a882da

Browse files
authored
Fix(cbf): stop kyoto during backoff wait (#16)
Previously if we try to stop kyoto during the backoff wait it would restart despite the user's command to stop.
1 parent 67af5c8 commit 5a882da

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

src/chain/cbf.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,20 @@ impl CbfChainSource {
374374
event_rx: new_event_rx,
375375
} = new_client;
376376

377-
// Swap the requester so callers pick up the new handle.
378-
*restart_status.lock().expect("lock") =
379-
CbfRuntimeStatus::Started { requester: new_requester };
377+
// Publish the new requester only if stop() did not fire during the
378+
// backoff sleep. Otherwise the rebuilt node would outlive stop().
379+
{
380+
let mut status = restart_status.lock().expect("lock");
381+
if matches!(*status, CbfRuntimeStatus::Stopped) {
382+
let _ = new_requester.shutdown();
383+
log_info!(
384+
restart_logger,
385+
"CBF restart aborted: stop() called during backoff."
386+
);
387+
break;
388+
}
389+
*status = CbfRuntimeStatus::Started { requester: new_requester };
390+
}
380391

381392
current_node = new_node;
382393
current_info_rx = new_info_rx;

0 commit comments

Comments
 (0)