]> git.ipfire.org Git - thirdparty/systemd.git/commit
bus: optionally call a callbacks for cleanup
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 6 Jun 2018 09:07:02 +0000 (11:07 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 6 Jun 2018 21:01:57 +0000 (23:01 +0200)
commitfa17b4e8d93c715793e35242829b33fef54bddea
tree714dbc997b8217ccdeadf1964e2a4a8846b2f810
parente3736e02231dd71b6674091b4db79e2dee800bca
bus: optionally call a callbacks for cleanup

This adds a function sd_bus_slot_set_destroy_callback() to set a function
which can free userdata or perform other cleanups.

sd_bus_slot_get_destory_callback() queries the callback, and is included
for completeness.

Without something like this, for floating asynchronous callbacks, which might
be called or not, depending on the sequence of events, it's hard to perform
resource cleanup. The alternative would be to always perform the cleanup from
the caller too, but that requires more coordination and keeping of some shared
state. It's nicer to keep the cleanup contained between the callback and the
function that requests the callback.
man/rules/meson.build
man/sd_bus_slot_set_destroy_callback.xml [new file with mode: 0644]
man/sd_bus_slot_set_floating.xml
src/libsystemd/libsystemd.sym
src/libsystemd/sd-bus/bus-internal.h
src/libsystemd/sd-bus/bus-slot.c
src/systemd/sd-bus.h