fix(asusd): improve async task supervision, eliminate unwrap panics, and deduplicate ZBus registration - #239
Conversation
|
Warning Review limit reached
Next review available in: 42 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@asusd/src/ctrl_backlight.rs`:
- Around line 160-164: Update the startup guard around screenpad sync to treat
both None and Some(false) as disabled, and ensure the worker loop rechecks the
current setting and sleeps before continuing when sync is unset or disabled at
runtime. Use the existing screenpad sync configuration access and 300 ms delay
so disabled paths do not spin or spawn unnecessarily.
- Around line 166-170: Update the spawned watcher task created in the primary
backlight branch to handle errors from watch.into_event_stream(...) explicitly:
log the initialization failure with the existing logging mechanism or propagate
it so the task handle reports an error. Apply the same behavior to the
corresponding watcher setup at the additional location, ensuring synchronization
failures are observable instead of silently returning Ok(()).
In `@asusd/src/ctrl_platform.rs`:
- Around line 929-1090: Handle errors from monitor_platform_profile in the
create_tasks flow without propagating them after the listener tasks have been
added to the JoinSet. Log the failure and continue to
Self::spawn_task_supervisor so existing sleep, shutdown, lid, power, and
charge-control tasks remain owned and running; only spawn the platform-profile
watcher when monitoring succeeds.
In `@asusd/src/lib.rs`:
- Around line 241-266: Document the ownership/lifetime contract on
create_sys_event_tasks: once it returns a JoinSet, callers must supervise or
explicitly handle it before performing any fallible work, because dropping it
aborts all spawned listeners. Place the guidance in the function’s documentation
and cover all returned-task paths without changing the task behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 6e60e05c-99b8-4b0a-917d-1d5b10a1b177
📒 Files selected for processing (7)
asusd/src/aura_anime/trait_impls.rsasusd/src/aura_laptop/trait_impls.rsasusd/src/aura_manager.rsasusd/src/ctrl_backlight.rsasusd/src/ctrl_platform.rsasusd/src/daemon.rsasusd/src/lib.rs
📜 Review details
🔇 Additional comments (9)
asusd/src/ctrl_backlight.rs (1)
153-159: LGTM!Also applies to: 211-213
asusd/src/daemon.rs (2)
37-37: LGTM!
120-126: LGTM!asusd/src/lib.rs (2)
65-109: Return-type change looks correct.
watch_*now surfaces the spawnedJoinHandle(orNoneon a benign unsupported-feature inotify failure) instead of discarding it, enabling callers to supervise the task. Logic is consistent between both macros.Also applies to: 112-146
208-217: Supervisor helper looks correct.Drains the
JoinSetand logsJoinErrors viawarn!; matches the stated goal of centralizing task supervision.asusd/src/aura_anime/trait_impls.rs (1)
319-449: LGTM — no fallible calls between task creation and supervision.
tasksis obtained viacreate_sys_event_tasks(...).await?and passed straight toSelf::spawn_task_supervisor("AniMeZbus", tasks)with no intervening fallible operation, so this call site doesn't hit the JoinSet-drop hazard flagged inctrl_platform.rs.asusd/src/aura_laptop/trait_impls.rs (1)
242-295: Panics removed, supervision wired correctly.
unwrap()-based "bomb out" error handling is replaced withif let Err(e) = ... { error!(...) }, andtasksis passed tospawn_task_supervisorimmediately afterawait?with no intervening fallible step.asusd/src/aura_manager.rs (2)
30-48: Clean consolidation of the duplicated register-on-success pattern.
register_device_zbuscorrectly gatesAsusDeviceregistration onstart_taskssucceeding and logs failures viaerror!, matching the three inline blocks it replaces.
407-410: LGTM — registration now consistently gated onstart_taskssuccess.Slash, AniMe Matrix, and TUF Aura registration all correctly capture the
start_tasks(...)result and defer toregister_device_zbusfor the conditional push, matching the "Gate device registration on task startup" objective.Also applies to: 419-424, 445-448
…to return JoinSet and JoinHandle
…ght watcher, and charge threshold logging
…imary backlight supervisor
f2f0229 to
a103b3b
Compare
Description
This PR enhances
asusddaemon stability and safety by centralizing Tokio async task supervision, eliminating.unwrap()panics in system event handlers, and deduplicating D-Bus registration boilerplate across controller modules.Key Changes
Async Task Supervision & Lifetime Management:
CtrlTask::spawn_task_supervisor(name, join_set)helper inasusd/src/lib.rs.create_sys_event_tasksand task watch macros (task_watch_item!) to returnJoinSet<()>andJoinHandle<()>, ensuring background task errors (suspend/resume, power plug, lid events) are logged instead of swallowed or lost.Panic Elimination (
.unwrap()Removal):.unwrap()calls inCtrlKbdLedTaskand system event callbacks with non-blocking error propagation and log warnings (if let Err(e) = ...).create_sys_event_tasksto returnResult<(), RogError>rather than panicking on event watcher initialization failure.ZBus Device Registration Boilerplate:
Self::add_to_server_helperacrossaura_anime,aura_laptop,ctrl_platform, andctrl_backlight.Daemon & Environment Fixes:
IS_SERVICEenvironment check for reliable systemd service detection.