chiark / gitweb /
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)
committerSven Eden <yamakuzure@gmx.net>
Fri, 24 Aug 2018 14:47:08 +0000 (16:47 +0200)
commit1aa207c0a5005a80bf30924c2325f901d7f7f80c
tree84c65d2062737310d6b8f2b8bffe57031e85ffe2
parentf44b01c3269d71cff4566a894fe48c35ca77e11c
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/libelogind/libelogind.sym
src/libelogind/sd-bus/bus-internal.h
src/libelogind/sd-bus/bus-slot.c
src/systemd/sd-bus.h