Skip to content

Fixed LICENSE install and self-deadlock in callbacks#41

Merged
AndreaRicchi merged 2 commits into
mainfrom
fixes
Jul 2, 2026
Merged

Fixed LICENSE install and self-deadlock in callbacks#41
AndreaRicchi merged 2 commits into
mainfrom
fixes

Conversation

@AndreaRicchi

@AndreaRicchi AndreaRicchi commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes
    • Improved service and technology update handling by dispatching change callbacks outside internal locks and using snapshots, improving responsiveness and reducing the likelihood of deadlocks.
  • Build & Packaging
    • Updated installation packaging so the LICENSE file is taken from the correct source location during install.

Replaced CMAKE_SOURCE_DIR with CMAKE_CURRENT_SOURCE_DIR when specifying
the path to the LICENSE file for installation.

Using CMAKE_SOURCE_DIR breaks the installation if this project is included
as a subproject (e.g., via add_subdirectory) in a larger CMake build,
because it would resolve to the top-level parent project's root directory.
CMAKE_CURRENT_SOURCE_DIR ensures the LICENSE file is correctly resolved
relative to this specific CMakeLists.txt file.

Gh-Issue: #40
Signed-off-by: Andrea Ricchi <andrea.ricchi@amarulasolutions.com>
@AndreaRicchi AndreaRicchi requested a review from EddyTheCo July 1, 2026 14:23
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c3b65b27-52e0-43aa-9ee7-e911a920be1c

📥 Commits

Reviewing files that changed from the base of the PR and between 06bbe40 and a32c5e7.

📒 Files selected for processing (1)
  • src/dbus/gconnman_manager.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/dbus/gconnman_manager.cpp

📝 Walkthrough

Walkthrough

Refactors Manager callback dispatch so shared state updates happen under mtx_ and callbacks run after unlocking with snapshots, and updates the LICENSE install path in CMakeLists.txt.

Changes

Manager Callback Locking Refactor

Layer / File(s) Summary
Decouple state update from callback invocation
src/dbus/gconnman_manager.cpp
process_services_changed now only updates services_ without invoking services_changed_cb_; the caller handles the callback.
Proxy callback dispatch under lock
src/dbus/gconnman_manager.cpp
get_proxies_cb updates services_ or technologies_ under mtx_, conditionally selects the changed callback, and invokes it outside the mutex.
Technology change snapshot invocation
src/dbus/gconnman_manager.cpp
on_technology_added_removed_cb computes updated_technologies under mtx_ and invokes technologies_changed_cb_ outside the lock with the snapshot.
Services change snapshot invocation
src/dbus/gconnman_manager.cpp
on_services_changed_cb calls process_services_changed, snapshots services_ and the callback under mtx_, then invokes the callback outside the lock.

CMake Install Path Fix

Layer / File(s) Summary
LICENSE install source path
CMakeLists.txt
The install(FILES ...) entry for LICENSE now references CMAKE_CURRENT_SOURCE_DIR instead of CMAKE_SOURCE_DIR.

Estimated code review effort: 3 (Moderate) | ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main changes: LICENSE install path fix and callback deadlock avoidance.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fixes

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

🧩 Build Artifacts

✅ The following build artifacts were produced:

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Clang-Tidy found issue(s) with the introduced code (1/1)

Comment thread src/dbus/gconnman_manager.cpp Outdated
Comment thread src/dbus/gconnman_manager.cpp Outdated
Comment thread src/dbus/gconnman_manager.cpp Outdated
Comment thread src/dbus/gconnman_manager.cpp Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@src/dbus/gconnman_manager.cpp`:
- Around line 333-340: The TechnologyRemoved branch in connectSignal() is
reading the signal tuple directly instead of its first child, so removals are
not processed correctly. Update the TechnologyRemoved handling in
gconnman_manager.cpp to extract child 0 from parameters before passing it to
g_variant_get_string, while keeping the existing g-signal::TechnologyAdded and
g-signal::TechnologyRemoved comparisons unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a059462a-5649-4272-8e45-17f764fa7048

📥 Commits

Reviewing files that changed from the base of the PR and between 499e497 and 9093d73.

📒 Files selected for processing (2)
  • CMakeLists.txt
  • src/dbus/gconnman_manager.cpp

Comment thread src/dbus/gconnman_manager.cpp
@EddyTheCo

Copy link
Copy Markdown
Contributor

LGTM.
Just fix the clang comments!
I have to run the tests, but it should be ok. Thanks!

on_services_changed_cb, get_proxies_cb and on_technology_added_removed_cb
all invoke the user-registered services_changed_cb_/technologies_changed_cb_
while still holding mtx_. If the callback calls back into
Manager::services()/technologies() (both of which lock the same
non-recursive mtx_), the callback dispatch thread deadlocks on itself.

This is easy to hit in practice: a consumer's services-changed handler
typically wants to read the current service list, which is the obvious
thing to call from inside the callback.

Copy the updated list and the callback out under the lock, release the
lock, then invoke the callback with the copies. This also means any
work the callback does (which we don't control) no longer serializes
against unrelated Manager accessors while it runs.

Signed-off-by: Andrea Ricchi <andrea.ricchi@amarulasolutions.com>
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

🧩 Build Artifacts

✅ The following build artifacts were produced:

@AndreaRicchi AndreaRicchi merged commit caed122 into main Jul 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants