2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
6 <refentry id=
"sd_bus_slot_set_destroy_callback"
7 xmlns:
xi=
"http://www.w3.org/2001/XInclude">
10 <title>sd_bus_slot_set_destroy_callback
</title>
11 <productname>systemd
</productname>
15 <refentrytitle>sd_bus_slot_set_destroy_callback
</refentrytitle>
16 <manvolnum>3</manvolnum>
20 <refname>sd_bus_slot_set_destroy_callback
</refname>
21 <refname>sd_bus_slot_get_destroy_callback
</refname>
22 <refname>sd_bus_track_set_destroy_callback
</refname>
23 <refname>sd_bus_track_get_destroy_callback
</refname>
24 <refname>sd_bus_destroy_t
</refname>
26 <refpurpose>Define the callback function for resource cleanup
</refpurpose>
31 <funcsynopsisinfo>#include
<systemd/sd-bus.h
></funcsynopsisinfo>
34 <funcdef>typedef int (*
<function>sd_bus_destroy_t
</function>)
</funcdef>
35 <paramdef>void *
<parameter>userdata
</parameter></paramdef>
39 <funcdef>int
<function>sd_bus_slot_set_destroy_callback
</function></funcdef>
40 <paramdef>sd_bus_slot *
<parameter>slot
</parameter></paramdef>
41 <paramdef>sd_bus_destroy_t
<parameter>callback
</parameter></paramdef>
45 <funcdef>int
<function>sd_bus_slot_get_destroy_callback
</function></funcdef>
46 <paramdef>sd_bus_slot *
<parameter>slot
</parameter></paramdef>
47 <paramdef>sd_bus_destroy_t *
<parameter>callback
</parameter></paramdef>
51 <funcdef>int
<function>sd_bus_track_set_destroy_callback
</function></funcdef>
52 <paramdef>sd_bus_track *
<parameter>track
</parameter></paramdef>
53 <paramdef>sd_bus_destroy_t
<parameter>callback
</parameter></paramdef>
57 <funcdef>int
<function>sd_bus_track_get_destroy_callback
</function></funcdef>
58 <paramdef>sd_bus_track *
<parameter>track
</parameter></paramdef>
59 <paramdef>sd_bus_destroy_t *
<parameter>callback
</parameter></paramdef>
65 <title>Description
</title>
67 <para><function>sd_bus_slot_set_destroy_callback()
</function> sets
<parameter>callback
</parameter> as the callback
68 function to be called right before the bus slot object
<parameter>slot
</parameter> is deallocated. The
69 <parameter>userdata
</parameter> pointer from the slot object will be passed as the
<parameter>userdata
</parameter>
70 parameter. This pointer can be set by an argument to the constructor functions, see
71 <citerefentry><refentrytitle>sd_bus_add_match
</refentrytitle><manvolnum>3</manvolnum></citerefentry>, or directly,
72 see
<citerefentry><refentrytitle>sd_bus_slot_set_userdata
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
73 This callback function is called even if
<parameter>userdata
</parameter> is
<constant>NULL
</constant>. Note that
74 this callback is invoked at a time where the bus slot object itself is already invalidated, and executing
75 operations or taking new references to the bus slot object is not permissible.
</para>
77 <para><function>sd_bus_slot_get_destroy_callback()
</function> returns the current callback
78 for
<parameter>slot
</parameter> in the
<parameter>callback
</parameter> parameter.
</para>
80 <para><function>sd_bus_track_set_destroy_callback()
</function> and
81 <function>sd_bus_track_get_destroy_callback()
</function> provide equivalent functionality for the
82 <parameter>userdata
</parameter> pointer associated with bus peer tracking objects. For details about bus peer
84 <citerefentry><refentrytitle>sd_bus_track_new
</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
</para>
88 <title>Return Value
</title>
90 <para>On success,
<function>sd_bus_slot_set_destroy_callback()
</function> and
91 <function>sd_bus_track_set_destroy_callback()
</function> return
0 or a positive integer. On failure, they
92 return a negative errno-style error code.
</para>
94 <para><function>sd_bus_slot_get_destroy_callback()
</function> and
95 <function>sd_bus_track_get_destroy_callback()
</function> return positive if the destroy callback function
96 is set,
0 if not. On failure, they return a negative errno-style error code.
</para>
101 <para>Returned errors may indicate the following problems:
</para>
105 <term><constant>-EINVAL
</constant></term>
107 <listitem><para>The
<parameter>slot
</parameter> or
<parameter>track
</parameter> parameter is
108 <constant>NULL
</constant>.
</para></listitem>
114 <xi:include href=
"libsystemd-pkgconfig.xml" />
117 <title>History
</title>
118 <para><function>sd_bus_slot_get_destroy_callback()
</function> was added in version
239.
</para>
119 <para><function>sd_bus_slot_set_destroy_callback()
</function> was added in version
239.
</para>
120 <para><function>sd_bus_track_get_destroy_callback()
</function> was added in version
239.
</para>
121 <para><function>sd_bus_track_set_destroy_callback()
</function> was added in version
239.
</para>
125 <title>See Also
</title>
128 <citerefentry><refentrytitle>systemd
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
129 <citerefentry><refentrytitle>sd-bus
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
130 <citerefentry><refentrytitle>sd_bus_slot_set_floating
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
131 <citerefentry><refentrytitle>sd_bus_add_match
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
132 <citerefentry><refentrytitle>sd_bus_track_new
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
133 <citerefentry><refentrytitle>sd_bus_slot_set_userdata
</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
134 <citerefentry><refentrytitle>sd_bus_track_set_userdata
</refentrytitle><manvolnum>3</manvolnum></citerefentry>