Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/client/device_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -988,12 +988,18 @@ impl Client {
devices
}

/// Background loop placeholder for device registry cleanup.
/// Note: Cleanup functionality was removed as part of trait simplification.
/// Device registry entries are managed through normal update/get operations.
pub(super) async fn device_registry_cleanup_loop(&self) {
// Simply wait for shutdown signal
self.shutdown_notifier.listen().await;
/// Background task placeholder: waits for the shutdown signal, then exits.
/// (Cleanup was removed with trait simplification; entries are managed via
/// normal update/get.) Holds the client Weak, not strong, so it never keeps
/// the client - and its store's file handle - alive past teardown, exactly
/// like the event-delivery drainer's `Arc::downgrade`.
pub(super) async fn device_registry_cleanup_loop(client: std::sync::Weak<Self>) {
// Grab the 'static shutdown future without holding the client across the
// wait; if the client is already gone there is nothing to wait for.
let Some(shutdown) = client.upgrade().map(|c| c.shutdown_notifier.listen()) else {
return;
};
shutdown.await;
debug!(
target: "Client/DeviceRegistry",
"Shutdown signaled, exiting cleanup loop"
Expand Down
9 changes: 4 additions & 5 deletions src/client/lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,11 @@ impl Client {
}))
.detach();

// Start background task to clean up stale device registry entries
let cleanup_arc = arc.clone();
// Background shutdown-awaiter; Weak so it never pins the client (and its
// store handle) past teardown, like the event drainer's downgrade.
let cleanup_weak = Arc::downgrade(&arc);
arc.runtime
.spawn(Box::pin(async move {
cleanup_arc.device_registry_cleanup_loop().await;
}))
.spawn(Box::pin(Self::device_registry_cleanup_loop(cleanup_weak)))
.detach();

(arc, rx)
Expand Down