Skip to content

fix(#634): drop network event streams for removed access points and devices - #635

Merged
cachebag merged 2 commits into
freedesktop-rs:masterfrom
velo:fix/634-drop-removed-object-streams
Nov 28, 2026
Merged

cachebag merged 2 commits into
freedesktop-rs:masterfrom
velo:fix/634-drop-removed-object-streams

Conversation

@velo

@velo velo commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #634.

run_network_events pushed a per-object stream into the select_all for every AccessPointAdded / DeviceAdded, but the removal signals discarded the path, so nothing ever ended those streams. A zbus signal/property stream for an object that no longer exists never yields None, so each one kept its proxy, property cache and match rule for the life of the event task. In a long-running consumer (cosmic-applet-network) this reached 2.5 GiB after 18 days, with ~99.5 % of every AccessPoint path NetworkManager had ever created still referenced; numbers are in #634.

Change

  • AccessPointRemoved and DeviceRemoved now carry the object path.
  • Each per-object stream is wrapped with futures::stream::abortable and its AbortHandle is kept in an ObjectStreams map keyed by the owning object path:
    • AP strength streams under the AP path,
    • device state streams and a wireless device's AccessPointAdded / AccessPointRemoved streams under the device path.
  • On removal the handles for that path are aborted; the aborted streams return None and SelectAll drops them.
  • A repeated AccessPointAdded / DeviceAdded for an already-tracked path releases the old streams first, so duplicates no longer accumulate either.

Public API and emitted NetworkEvents are unchanged.

Tests

  • released_object_streams_leave_the_merged_stream: a tracked stream that would never end leaves the merged stream once its object is released.
  • releasing_one_object_keeps_the_others: release is scoped to the path.
  • Classifier test updated for the path-carrying removal events.

cargo fmt --check, cargo clippy --all-targets --all-features -D warnings, cargo test --lib --all-features (768 passed) and cargo doc with -D warnings pass locally. I did not run the Docker NetworkManager integration harnesses.

AI disclosure

The leak was diagnosed and this patch written with Claude Code (Anthropic), working from a core dump of the leaking process: glibc arena walk, live-chunk histogram and object-path counts. Verified by the unit tests above and the local CI checks.

…s points and devices

Signed-off-by: Marvin Froeder <velo.br@gmail.com>
@agustux

This comment was marked as resolved.

@cachebag cachebag added bug Something isn't working monitoring Connection monitoring and info wifi WiFi connection management labels Nov 27, 2026

@cachebag cachebag left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! A couple notes

Comment thread src/monitoring/events.rs Resolved
Comment thread CHANGELOG.md Resolved
@velo
velo deployed to self-hosted-pr-integration November 27, 2026 15:40 — with GitHub Actions Active
…heir device

Signed-off-by: Marvin Froeder <velo.br@gmail.com>
@velo

velo commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

No worries, thanks for taking a look! Happy Thanksgiving to you too.

@cachebag cachebag left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@velo
velo deployed to self-hosted-pr-integration November 27, 2026 23:42 — with GitHub Actions Active
@cachebag
cachebag merged commit 2e4e532 into freedesktop-rs:master Nov 28, 2026
7 checks passed

This branch was successfully deployed

1 active deployment
self-hosted-pr-integration — 48519a19 Deployed Nov 27, 2026 by velo via NetworkManager Integration #1350
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working monitoring Connection monitoring and info wifi WiFi connection management

Projects

None yet

Development

Successfully merging this pull request may close these issues.

network_events() never drops monitor streams for removed access points and devices, so memory grows with every AP/device NetworkManager has ever created

3 participants