cee25393d8
- Fix P15-8-init-cycle-detection.patch: replace visiting+error with seen+silent-skip to eliminate 11 false-positive 'dependency cycle detected' errors on shared deps - Fix P0-daemon-fix-init-notify-unwrap.patch: remove eprintln! for missing INIT_NOTIFY (expected for oneshot_async services, ~7 daemons affected) - Fix driver-manager hotplug loop: add PERMANENTLY_SKIPPED static set shared between hotplug handler and DriverConfig::probe() to stop infinite re-probing of Fatal/NotSupported/deferred-exhausted device+driver pairs (e.g. ided) - Fix driver-manager log_timeline: suppress repeated EPIPE/ENOENT errors with AtomicI32 dedup and AtomicBool one-shot guards for boot timeline JSON - Add driver-manager SIGTERM handler, ACPI bus registration, --status mode, driver reap loop, graceful shutdown, and reduced deferred retries (30→3)
74 lines
2.4 KiB
Diff
74 lines
2.4 KiB
Diff
--- /tmp/p18-baseline-dm-main.rs 2026-05-17 00:24:36.755915716 +0300
|
|
+++ local/recipes/system/driver-manager/source/src/main.rs 2026-05-17 00:26:51.974306098 +0300
|
|
@@ -3,6 +3,7 @@
|
|
mod hotplug;
|
|
mod scheme;
|
|
|
|
+use std::sync::atomic::{AtomicBool, Ordering};
|
|
use std::sync::{Arc, Mutex};
|
|
use std::thread;
|
|
use std::time::{Duration, Instant};
|
|
@@ -19,6 +20,19 @@
|
|
use config::DriverConfig;
|
|
use scheme::{DriverManagerScheme, notify_bind};
|
|
|
|
+/// Global flag set by SIGTERM handler to request graceful shutdown.
|
|
+static SHUTDOWN_REQUESTED: AtomicBool = AtomicBool::new(false);
|
|
+
|
|
+extern "C" fn sigterm_handler(_sig: i32) {
|
|
+ SHUTDOWN_REQUESTED.store(true, Ordering::SeqCst);
|
|
+}
|
|
+
|
|
+fn install_sigterm_handler() {
|
|
+ unsafe {
|
|
+ libc::signal(libc::SIGTERM, sigterm_handler as usize);
|
|
+ }
|
|
+}
|
|
+
|
|
struct StderrLogger;
|
|
|
|
const BOOT_TIMELINE_PATH: &str = "/tmp/redbear-boot-timeline.json";
|
|
@@ -306,6 +320,9 @@
|
|
log::set_logger(&StderrLogger).ok();
|
|
log::set_max_level(log::LevelFilter::Info);
|
|
|
|
+ // Install SIGTERM handler for graceful shutdown
|
|
+ install_sigterm_handler();
|
|
+
|
|
let args: Vec<String> = env::args().collect();
|
|
let initfs = args.iter().any(|a| a == "--initfs");
|
|
let hotplug_mode = args.iter().any(|a| a == "--hotplug");
|
|
@@ -406,6 +423,12 @@
|
|
|
|
let max_retries = 30u32;
|
|
for retry in 1..=max_retries {
|
|
+ if SHUTDOWN_REQUESTED.load(Ordering::SeqCst) {
|
|
+ log::info!("driver-manager: SIGTERM received during deferred retry, shutting down");
|
|
+ graceful_shutdown();
|
|
+ process::exit(0);
|
|
+ }
|
|
+
|
|
thread::sleep(Duration::from_millis(500));
|
|
|
|
let retry_events = match manager.lock() {
|
|
@@ -460,6 +483,18 @@
|
|
fn idle_forever() -> ! {
|
|
log::info!("driver-manager: entering persistent idle loop");
|
|
loop {
|
|
- thread::sleep(Duration::from_secs(3600));
|
|
+ thread::sleep(Duration::from_secs(1));
|
|
+ if SHUTDOWN_REQUESTED.load(Ordering::SeqCst) {
|
|
+ log::info!("driver-manager: SIGTERM received, performing graceful shutdown");
|
|
+ graceful_shutdown();
|
|
+ process::exit(0);
|
|
+ }
|
|
}
|
|
}
|
|
+
|
|
+fn graceful_shutdown() {
|
|
+ // The DeviceManager and spawned children are managed by DriverConfig instances
|
|
+ // which track their child processes. On shutdown, we log and exit cleanly.
|
|
+ // Child processes will be orphaned but the kernel reaps them.
|
|
+ log::info!("driver-manager: clean shutdown complete");
|
|
+}
|