-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bt2: make _ListenerHandle not hold a strong reference on the target o…
…bject The bt2._ListenerHandle object currently holds a strong reference to the Python object on which the listener was added. This allows validating that a handle passed to the remove_destruction_listener method of an object mathces that object. However, keeping that strong reference also prevents the destruction of that target object. So, adding a destruction listener and keeping the handle around actually prevents the destruction from happening, making that destruction listener useless. Change it so the _ListenerHandle only keeps the address of the target object. This is enough to do the check described above. We must however invalidate the _ListenerHandle when the target object is destroyed, because another object could be later created at the same address. To achieve this, the handle object is bound to the destruction callback, so that we can invalidate it in _trace_destruction_listener_from_native / _trace_class_destruction_listener_from_native. The "del" statements in the tests were necessary before, otherwise the handles would keep the trace class / trace alive, and the destruction listeners would not get called. I removed them, so it now tests that keeping a listener handle doesn't keep the target object alive. Change-Id: I668cf29b5a6046a89d4eff73d322cb0cd83e5109 Signed-off-by: Simon Marchi <simon.marchi@efficios.com> Reviewed-on: https://review.lttng.org/c/babeltrace/+/2426 Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
- Loading branch information
Showing
5 changed files
with
31 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters