Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@arkq
Copy link
Contributor

@arkq arkq commented Apr 9, 2025

This PR fixes the issue reported in #94 (comment)

@arkq
Copy link
Contributor Author

arkq commented Apr 9, 2025

As stated in the comment #94 (comment) there is another bug in the implementation. In case where interfaces are added to the same path with the handle = object_manager.export_with_manager() method, the InterfacesAdded signal contains all interfaces available on the path - not only the once which were added in the last export. The same case is with handle.stop() - the InterfacesRemoved signal contains the list of all interfaces available on the path prior to the stop() call (including standard org.freedesktop.DBus.Peer, org.freedesktop.DBus.Introspectable and org.freedesktop.DBus.Properties). Unfortunately, my understanding of the internals of this library is not good enough to propose a fix for that....

@igo95862 igo95862 merged commit aa58a8c into python-sdbus:master Apr 9, 2025
4 checks passed
@igo95862
Copy link
Collaborator

igo95862 commented Apr 9, 2025

As stated in the comment #94 (comment) there is another bug in the implementation. In case where interfaces are added to the same path with the handle = object_manager.export_with_manager() method, the InterfacesAdded signal contains all interfaces available on the path - not only the once which were added in the last export. The same case is with handle.stop() - the InterfacesRemoved signal contains the list of all interfaces available on the path prior to the stop() call (including standard org.freedesktop.DBus.Peer, org.freedesktop.DBus.Introspectable and org.freedesktop.DBus.Properties). Unfortunately, my understanding of the internals of this library is not good enough to propose a fix for that....

I need to add a way to call the sd_bus_emit_interfaces_added_strv and sd_bus_emit_interfaces_removed_strv from Python. This will include a calloc to allocate an array of char * from the passed strings.

@igo95862
Copy link
Collaborator

@arkq I experimented with sd_bus_emit_interfaces_{added,remove}_strv in 10340bf. Could you give it a test?

@arkq
Copy link
Contributor Author

arkq commented Apr 14, 2025

I've compiled package with python wheel-build/run_podman_full_build.py (from emit-interfaces-added-removed branch) and when running my test script I have:

ImportError: /.../python3.12/site-packages/sdbus/sd_bus_internals.abi3.so: undefined symbol: SD_BUS_PY_UNICODE_AS_CHAR_PTR

@igo95862
Copy link
Collaborator

igo95862 commented Apr 14, 2025

python wheel-build/run_podman_full_build.py will build using the limited API that I did not yet implement for the changes I created. Can you build it locally with python setup.py build? After it is built you can use the PYTHONPATH environment variable to load sdbus Python module from build directory.

@arkq
Copy link
Contributor Author

arkq commented Apr 14, 2025

I've just built package on the host and I can import sdbus now.

As for the test. InterfacesAdded and InterfacesRemoved are generated only for the interfaces added and removed explicitly by the user. But there are also org.freedesktop.DBus.Peer, ...Introspectable and ...Properties. So, when the path is created, the InterfacesAdded should contain those interfaces as well. The same for InterfacesRemoved when the path is removed (all user interfaces are gone).

@igo95862
Copy link
Collaborator

igo95862 commented Apr 14, 2025

But there are also org.freedesktop.DBus.Peer, ...Introspectable and ...Properties. So, when the path is created, the InterfacesAdded should contain those interfaces as well.

There is actually some kind of bug regarding those interfaces and emit InterfacesAdded call. I had to add if meta.serving_enabled or libsystemd would corrupt the memory and exit with SIGSEGV.

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