summaryrefslogtreecommitdiffstats
path: root/upstream/debian-unstable/man3/sd_bus_request_name.3
blob: 49f93b61ebf9e773c06c34888d99c6a9905c3ffd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
'\" t
.TH "SD_BUS_REQUEST_NAME" "3" "" "systemd 256~rc3" "sd_bus_request_name"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
sd_bus_request_name, sd_bus_request_name_async, sd_bus_release_name, sd_bus_release_name_async \- Request or release a well\-known service name on a bus
.SH "SYNOPSIS"
.sp
.ft B
.nf
#include <systemd/sd\-bus\&.h>
.fi
.ft
.HP \w'typedef\ int\ (*sd_bus_message_handler_t)('u
.BI "typedef int (*sd_bus_message_handler_t)(sd_bus_message\ *" "m" ", void\ *" "userdata" ", sd_bus_error\ *" "ret_error" ");"
.HP \w'int\ sd_bus_request_name('u
.BI "int sd_bus_request_name(sd_bus\ *" "bus" ", const\ char\ *" "name" ", uint64_t\ " "flags" ");"
.HP \w'int\ sd_bus_request_name_async('u
.BI "int sd_bus_request_name_async(sd_bus\ *" "bus" ", sd_bus_slot\ **" "slot" ", const\ char\ *" "name" ", uint64_t\ " "flags" ", sd_bus_message_handler_t\ " "callback" ", void\ *" "userdata" ");"
.HP \w'int\ sd_bus_release_name('u
.BI "int sd_bus_release_name(sd_bus\ *" "bus" ", const\ char\ *" "name" ");"
.HP \w'int\ sd_bus_release_name_async('u
.BI "int sd_bus_release_name_async(sd_bus\ *" "bus" ", sd_bus_slot\ **" "slot" ", const\ char\ *" "name" ", sd_bus_message_handler_t\ " "callback" ", void\ *" "userdata" ");"
.SH "DESCRIPTION"
.PP
\fBsd_bus_request_name()\fR
requests a well\-known service name on a bus\&. It takes a bus connection, a valid bus name, and a flags parameter\&. The flags parameter is a combination of zero or more of the following flags:
.PP
\fBSD_BUS_NAME_ALLOW_REPLACEMENT\fR
.RS 4
After acquiring the name successfully, permit other peers to take over the name when they try to acquire it with the
\fBSD_BUS_NAME_REPLACE_EXISTING\fR
flag set\&. If
\fBSD_BUS_NAME_ALLOW_REPLACEMENT\fR
is not set on the original request, such a request by other peers will be denied\&.
.sp
Added in version 209\&.
.RE
.PP
\fBSD_BUS_NAME_REPLACE_EXISTING\fR
.RS 4
Take over the name if it was already acquired by another peer, and that other peer has permitted takeover by setting
\fBSD_BUS_NAME_ALLOW_REPLACEMENT\fR
while acquiring it\&.
.sp
Added in version 209\&.
.RE
.PP
\fBSD_BUS_NAME_QUEUE\fR
.RS 4
Queue the acquisition of the name when the name is already taken\&.
.sp
Added in version 209\&.
.RE
.PP
\fBsd_bus_request_name()\fR
operates in a synchronous fashion: a message requesting the name is sent to the bus broker, and the call waits until the broker responds\&.
.PP
\fBsd_bus_request_name_async()\fR
is an asynchronous version of
\fBsd_bus_request_name()\fR\&. Instead of waiting for the request to complete, the request message is enqueued\&. The specified
\fIcallback\fR
will be called when the broker\*(Aqs response is received\&. If the parameter is specified as
\fBNULL\fR
a default implementation is used instead which will terminate the connection when the name cannot be acquired\&. The function returns a slot object in its
\fIslot\fR
parameter \(em if it is passed as non\-\fBNULL\fR
\(em which may be used as a reference to the name request operation\&. Use
\fBsd_bus_slot_unref\fR(3)
to destroy this reference\&. Note that destroying the reference will not unregister the name, but simply ensure the specified callback is no longer called\&.
.PP
\fBsd_bus_release_name()\fR
releases an acquired well\-known name\&. It takes a bus connection and a valid bus name as parameters\&. This function operates synchronously, sending a release request message to the bus broker and waiting for it to reply\&.
.PP
\fBsd_bus_release_name_async()\fR
is an asynchronous version of
\fBsd_bus_release_name()\fR\&. The specified
\fIcallback\fR
function is called when the name has been released successfully\&. If specified as
\fBNULL\fR
a generic implementation is used that ignores the result of the operation\&. As above, the
\fIslot\fR
(if non\-\fBNULL\fR) is set to an object that may be used to reference the operation\&.
.PP
These functions are supported only on bus connections, i\&.e\&. connections to a bus broker and not on direct connections\&.
.SH "RETURN VALUE"
.PP
On success, these calls return 0 or a positive integer\&. On failure, these calls return a negative errno\-style error code\&.
.PP
If
\fBSD_BUS_NAME_QUEUE\fR
is specified,
\fBsd_bus_request_name()\fR
will return 0 when the name is already taken by another peer and the client has been added to the queue for the name\&. In that case, the caller can subscribe to
"NameOwnerChanged"
signals to be notified when the name is successfully acquired\&.
\fBsd_bus_request_name()\fR
returns > 0 when the name has immediately been acquired successfully\&.
.SS "Errors"
.PP
Returned errors may indicate the following problems:
.PP
\fB\-EALREADY\fR
.RS 4
The caller already is the owner of the specified name\&.
.RE
.PP
\fB\-EEXIST\fR
.RS 4
The name has already been acquired by a different peer, and SD_BUS_NAME_REPLACE_EXISTING was not specified or the other peer did not specify SD_BUS_NAME_ALLOW_REPLACEMENT while acquiring the name\&.
.RE
.PP
\fB\-ESRCH\fR
.RS 4
It was attempted to release a name that is currently not registered on the bus\&.
.RE
.PP
\fB\-EADDRINUSE\fR
.RS 4
It was attempted to release a name that is owned by a different peer on the bus\&.
.RE
.PP
\fB\-EINVAL\fR
.RS 4
A specified parameter is invalid\&. This is also generated when the requested name is a special service name reserved by the D\-Bus specification, or when the operation is requested on a connection that does not refer to a bus\&.
.RE
.PP
\fB\-ENOTCONN\fR
.RS 4
The bus connection has been disconnected\&.
.RE
.PP
\fB\-ECHILD\fR
.RS 4
The bus connection has been created in a different process than the current one\&.
.RE
.SH "NOTES"
.PP
Functions described here are available as a shared library, which can be compiled against and linked to with the
\fBlibsystemd\fR\ \&\fBpkg-config\fR(1)
file\&.
.PP
The code described here uses
\fBgetenv\fR(3), which is declared to be not multi\-thread\-safe\&. This means that the code calling the functions described here must not call
\fBsetenv\fR(3)
from a parallel thread\&. It is recommended to only do calls to
\fBsetenv()\fR
from an early phase of the program when no other threads have been started\&.
.SH "HISTORY"
.PP
\fBsd_bus_request_name()\fR
and
\fBsd_bus_release_name()\fR
were added in version 209\&.
.PP
\fBsd_bus_request_name_async()\fR
and
\fBsd_bus_release_name_async()\fR
were added in version 237\&.
.SH "SEE ALSO"
.PP
\fBsystemd\fR(1), \fBsd-bus\fR(3), \fBsd_bus_new\fR(3), \fBsd_bus_slot_unref\fR(3)