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

src/message_iter: Maintain reference to underlying DBusMessage #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ziyao233
Copy link

@ziyao233 ziyao233 commented Feb 1, 2025

Weirdly, an DBusMessageIter doesn't increase the refcount of the referred DBusMessage, thus we need to maintain the reference manually to prevent underlying DBusMessage from garbage collection before the DBusMessageIter is collected, which results in a dangling reference.

Let's introduce a new type, lDBusMessageIter, which contains both the iterator and the underlying DBusMessage, and refer/unref the message during creation, initialization and garbage collection of the iterator.

Closes: #20

Weirdly, an DBusMessageIter doesn't increase the refcount of the
referred DBusMessage, thus we need to maintain the reference manually to
prevent underlying DBusMessage from garbage collection before the
DBusMessageIter is collected, which results in a dangling reference.

Let's introduce a new type, lDBusMessageIter, which contains both the
iterator and the underlying DBusMessage, and refer/unref the message
during creation, initialization and garbage collection of the iterator.

Closes: daurnimator#20
Signed-off-by: Yao Zi <[email protected]>
@ziyao233
Copy link
Author

ziyao233 commented Feb 1, 2025

@daurnimator Thanks for your review (and the suggestion for the solution)!

btw, is it possible to add some testing infra for ldbus to make it more robust?

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.

Wrapper for DBusMessageIter doesn't reference the DBusMessage used to initialize it
1 participant