RFC: talloc contexts / automatic free at select loop

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Neels Hofmeyr nhofmeyr at sysmocom.de
Mon Mar 25 13:29:27 UTC 2019


On Sun, Mar 24, 2019 at 06:54:15AM +0100, Neels Hofmeyr wrote:
> So far I am talloc_steal()ing FSM instances "freed" in osmo_fsm_inst_term()
> cascades to the first/outermost osmo_fsm_inst_term() fi as talloc parent, so
> that all get freed once in the end.

Interesting to note here is that I can apparently steal a talloc parent to
become a talloc child (this is the result of the child osmo_fsm_inst_term()
also causing the parent to term)

 parent_fi
   |
   +- child_fi

talloc_steal(new_ctx=child_fi, parent_fi)

I guess this should result in:

      child_fi
        |
        +- parent_fi

I'm not entirely clear how this works out. Are those then still attached to
whatever parent_fi had as a parent context? Are they floating alone?
The test shows that it does work, no leaks, no loops.

Since child_fi is guaranteed to be deallocated, either way would be fine. If
this is bugging us we can use a different talloc_ctx to steal into -- I just
wanted to avoid allocating another short-lived ctx.

~N
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://lists.osmocom.org/pipermail/openbsc/attachments/20190325/3f1cf27b/attachment.bin>


More information about the OpenBSC mailing list