Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make dnf5 compatible with sdbus-cpp version 2 #1888

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

m-blaha
Copy link
Member

@m-blaha m-blaha commented Nov 22, 2024

The new and incompatible version of sdbus-cpp library has been released upstream.
I'd like to upgrade also version in Fedora rawhide, but to not break dnf5
building we fist need to adjust it.
This patch makes dnf5 buildable with both sdbus-cpp versions.

Copy link
Member

@Conan-Kudo Conan-Kudo left a comment

Choose a reason for hiding this comment

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

This fixed compiling against sdbus-cpp v2 in openSUSE Tumblweed.

@kontura kontura self-assigned this Dec 16, 2024
Copy link
Contributor

@kontura kontura left a comment

Choose a reason for hiding this comment

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

This looks reasonable to me but the dnf5daemon CI tests fail, I have verified that also locally.
I didn't investigate it further but the error is: [System.Error.ENXIO] Failed to enter a variant (No such device or address) when sdbus-cpp < 2.

With sdbus-cpp >= 2 (I used your build from https://copr.fedorainfracloud.org/coprs/mblaha/dnf5-sdbus-cpp-2/) I am getting some [org.rpm.dnf.v0.rpm.Rpm.TransactionError] rpm transaction failed with code 6.

@@ -0,0 +1,11 @@

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could drop this new line.

Comment on lines -76 to +105
"org.freedesktop.DBus", "NameOwnerChanged", [this](sdbus::Signal signal) -> void {
SDBUS_INTERFACE_NAME_TYPE{"org.freedesktop.DBus"},
SDBUS_SIGNAL_NAME_TYPE{"NameOwnerChanged"},
[this](sdbus::Signal signal) -> void {
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this is in the wrong commit, but it doesn't matter all that much.

Also set SDBUS_CPP_VERSION_2 macro in case sdbus-c++ was found in
version 2. This enables conditional compilation according the version of
the library found.
- Use InterfaceName type instead of char * for interface names
- Use SignalName type instead of char * for signal names
- Use ServiceName instead of char * for bus names
- Use Error::Name type instead of char * for errors
In version 2 the sdbus::Variant constuctor was made explicit.
In version 2, conversion of sdbus::Variant to the underlying type is
explicit.
sdbus-cpp version 2 requires signal handler to have signature
(sdbus::Signal signal) -> void, which is also acceptable for version 1.
sdbus-cpp-2 uses different approach to registering methods and signals
on the interface.
@m-blaha
Copy link
Member Author

m-blaha commented Dec 20, 2024

This looks reasonable to me but the dnf5daemon CI tests fail, I have verified that also locally. I didn't investigate it further but the error is: [System.Error.ENXIO] Failed to enter a variant (No such device or address) when sdbus-cpp < 2.

With sdbus-cpp >= 2 (I used your build from https://copr.fedorainfracloud.org/coprs/mblaha/dnf5-sdbus-cpp-2/) I am getting some [org.rpm.dnf.v0.rpm.Rpm.TransactionError] rpm transaction failed with code 6.

Thanks, the [System.Error.ENXIO] Failed to enter a variant (No such device or address) when sdbus-cpp < 2 issue should be resolved.

Still working on coredumps with sdbus-cpp version 2. Let me convert this back to draft until the issues are investigated and resolved.

@m-blaha m-blaha marked this pull request as draft December 20, 2024 10:28
Exit the event loop and properly join the serving thread.
To address race conditions between the lifetime of the context and
callbacks, it is safer to manage them separately.

With sdbus-cpp version 2, I observed various failures in
dnf5daemon-client, typically following this pattern:

- The main thread has already completed its work and is in the process
  of destructing the Context class.

- Meanwhile, the D-Bus event loop thread is still handling messages, and
  the handler attempts to access the context instance that is currently
  being destroyed.
@m-blaha m-blaha force-pushed the mblaha/sdbus-cpp-2 branch from 45934c7 to 80c6e46 Compare January 7, 2025 09:13
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.

3 participants