Debian Codegraph @

man/sd_bus_process.xml

raw
1 <?xml version='1.0'?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
4
5 <!--
6 SPDX-License-Identifier: LGPL-2.1-or-later
7
8 Copyright © 2016 Julian Orth
9 -->
10
11 <refentry id="sd_bus_process" xmlns:xi="http://www.w3.org/2001/XInclude">
12
13 <refentryinfo>
14 <title>sd_bus_process</title>
15 <productname>systemd</productname>
16 </refentryinfo>
17
18 <refmeta>
19 <refentrytitle>sd_bus_process</refentrytitle>
20 <manvolnum>3</manvolnum>
21 </refmeta>
22
23 <refnamediv>
24 <refname>sd_bus_process</refname>
25
26 <refpurpose>Drive the connection</refpurpose>
27 </refnamediv>
28
29 <refsynopsisdiv>
30 <funcsynopsis>
31 <funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
32
33 <funcprototype>
34 <funcdef>int <function>sd_bus_process</function></funcdef>
35 <paramdef>sd_bus *<parameter>bus</parameter></paramdef>
36 <paramdef>sd_bus_message **<parameter>ret</parameter></paramdef>
37 </funcprototype>
38 </funcsynopsis>
39 </refsynopsisdiv>
40
41 <refsect1>
42 <title>Description</title>
43
44 <para><function>sd_bus_process()</function> drives the connection between the client and the message bus.
45 That is, it handles connecting, authentication, and processing of messages. When invoked, pending I/O
46 work is executed, and queued incoming messages are dispatched to registered callbacks. Each time it is
47 invoked a single operation is executed. It returns zero when no operations were pending and positive if a
48 message was processed. When zero is returned the caller should poll for I/O events before calling into
49 <function>sd_bus_process()</function> again. For that either use the simple, blocking
50 <citerefentry><refentrytitle>sd_bus_wait</refentrytitle><manvolnum>3</manvolnum></citerefentry> call, or
51 hook up the bus connection object to an external or manual event loop using
52 <citerefentry><refentrytitle>sd_bus_get_fd</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
53 </para>
54
55 <para><function>sd_bus_process()</function> processes at most one incoming message per call. If the
56 parameter <parameter>ret</parameter> is not <constant>NULL</constant> and the call processed a message,
57 <parameter>*ret</parameter> is set to this message. The caller owns a reference to this message and
58 should call
59 <citerefentry><refentrytitle>sd_bus_message_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry>
60 when the message is no longer needed. If <parameter>ret</parameter> is not <constant>NULL</constant> and
61 progress was made, but no message was processed, <parameter>*ret</parameter> is set to
62 <constant>NULL</constant>. Note that only messages not already handled by the various types of registered
63 message handlers (i.e. by filters registered via
64 <citerefentry><refentrytitle>sd_bus_add_filter</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
65 object handlers registered via
66 <citerefentry><refentrytitle>sd_bus_add_object</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
67 matches registered via
68 <citerefentry><refentrytitle>sd_bus_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
69 and related) will be returned through this parameter. Also note that if such a message handler returns a
70 zero return value (as opposed to some value &gt; 0) an incoming message will not be considered handled,
71 and be passed to other suitable handlers (until one returns &gt; > 0), or returned by
72 <function>sd_bus_process()</function> (in case none returns &gt; 0).</para>
73
74 <para>If the bus object is connected to an
75 <citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry> event loop (with
76 <citerefentry><refentrytitle>sd_bus_attach_event</refentrytitle><manvolnum>3</manvolnum></citerefentry>), it is not
77 necessary to call <function>sd_bus_process()</function> directly as it is invoked automatically when
78 necessary.</para>
79 </refsect1>
80
81 <refsect1>
82 <title>Return Value</title>
83
84 <para>If progress was made, a positive integer is returned. If no progress was made, 0 is returned. If an
85 error occurs, a negative <varname>errno</varname>-style error code is returned.</para>
86
87 <refsect2>
88 <title>Errors</title>
89
90 <para>Returned errors may indicate the following problems:</para>
91
92 <variablelist>
93 <varlistentry>
94 <term><constant>-EINVAL</constant></term>
95
96 <listitem><para>An invalid bus object was passed.</para></listitem>
97 </varlistentry>
98
99 <varlistentry>
100 <term><constant>-ECHILD</constant></term>
101
102 <listitem><para>The bus connection was allocated in a parent process and is being reused in a child
103 process after <function>fork()</function>.</para></listitem>
104 </varlistentry>
105
106 <varlistentry>
107 <term><constant>-ENOTCONN</constant></term>
108
109 <listitem><para>The bus connection has been terminated already.</para></listitem>
110 </varlistentry>
111
112 <varlistentry>
113 <term><constant>-ECONNRESET</constant></term>
114
115 <listitem><para>The bus connection has been terminated just now.</para></listitem>
116 </varlistentry>
117
118 <varlistentry>
119 <term><constant>-EBUSY</constant></term>
120
121 <listitem><para>This function is already being called, i.e. <function>sd_bus_process()</function>
122 has been called from a callback function that itself was called by
123 <function>sd_bus_process()</function>.</para></listitem>
124 </varlistentry>
125 </variablelist>
126 </refsect2>
127 </refsect1>
128
129 <xi:include href="libsystemd-pkgconfig.xml" />
130
131 <refsect1>
132 <title>History</title>
133 <para><function>sd_bus_process()</function> was added in version 221.</para>
134 </refsect1>
135
136 <refsect1>
137 <title>See Also</title>
138
139 <para><simplelist type="inline">
140 <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
141 <member><citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
142 <member><citerefentry><refentrytitle>sd_bus_wait</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
143 <member><citerefentry><refentrytitle>sd_bus_get_fd</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
144 <member><citerefentry><refentrytitle>sd_bus_message_unref</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
145 <member><citerefentry><refentrytitle>sd-event</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
146 <member><citerefentry><refentrytitle>sd_bus_attach_event</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
147 </simplelist></para>
148 </refsect1>
149
150 </refentry>