bt2: free port user data when finalizing components
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 7 Jan 2020 01:47:20 +0000 (20:47 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 8 Jan 2020 18:06:42 +0000 (18:06 +0000)
commit9675ad631e70525a5038995374ceea935a630def
treed022f5310de1f82eb0cc65ef1ee499ba14cc0aff
parent2d786d152cfbc684e9c800929debd423d6c56812
bt2: free port user data when finalizing components

When creating component ports in Python, it is possible to pass a Python
object as user data:

    class MySource(
        bt2._UserSourceComponent, message_iterator_class=MyIter
    ):
        def __init__(self, config, params, obj):
            self._add_output_port('out', MyUserData())

The port takes a reference to this Python object, thanks to the `void *`
typemap in native_bt_port.i:

    %typemap(out) void * {
            Py_INCREF($1);
            $result = $1;
    }

However, this reference is never released.

This patches makes it so that when a component is finalized, it releases
the reference for the user data of all of its ports.

Change-Id: Ifebecc3b242c2ccf2bd65347a9087b90093f286c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2734
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/bindings/python/bt2/bt2/native_bt_component_class.i.h
tests/bindings/python/bt2/test_port.py
This page took 0.024038 seconds and 4 git commands to generate.