mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-03 01:17:45 +03:00
sd-bus: simplify sd_bus_reply()
there's no point in having two arguments, if one does as well.
This commit is contained in:
parent
fa98c99ea7
commit
6c41cf4459
5
NEWS
5
NEWS
@ -123,8 +123,9 @@ CHANGES WITH 248:
|
||||
|
||||
systemctl --user -M lennart@ start quux
|
||||
|
||||
* sd-bus also gained a convenience function sd_bus_reply() to call
|
||||
sd_bus_send() with an existing reply message.
|
||||
* sd-bus also gained a convenience function sd_bus_message_send() to
|
||||
simplify invocations of sd_bus_send(), taking only a single
|
||||
parameter: the message to send.
|
||||
|
||||
* sd-event allows rate limits to be set on event sources, for dealing
|
||||
with high-priority event sources that might starve out others. See
|
||||
|
@ -405,17 +405,14 @@ manpages = [
|
||||
'sd_bus_reply_method_errorf',
|
||||
'sd_bus_reply_method_errorfv'],
|
||||
''],
|
||||
['sd_bus_reply_method_return',
|
||||
'3',
|
||||
['sd_bus_reply', 'sd_bus_reply_method_returnv'],
|
||||
''],
|
||||
['sd_bus_reply_method_return', '3', ['sd_bus_reply_method_returnv'], ''],
|
||||
['sd_bus_request_name',
|
||||
'3',
|
||||
['sd_bus_release_name',
|
||||
'sd_bus_release_name_async',
|
||||
'sd_bus_request_name_async'],
|
||||
''],
|
||||
['sd_bus_send', '3', ['sd_bus_send_to'], ''],
|
||||
['sd_bus_send', '3', ['sd_bus_message_send', 'sd_bus_send_to'], ''],
|
||||
['sd_bus_set_address', '3', ['sd_bus_get_address', 'sd_bus_set_exec'], ''],
|
||||
['sd_bus_set_close_on_exit', '3', ['sd_bus_get_close_on_exit'], ''],
|
||||
['sd_bus_set_connected_signal', '3', ['sd_bus_get_connected_signal'], ''],
|
||||
|
@ -54,9 +54,9 @@
|
||||
<citerefentry><refentrytitle>sd_bus_call_method</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_call_method_async</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_can_send</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_close</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_creds_get_pid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_creds_new_from_pid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_close</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_default</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_emit_interfaces_added</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_emit_interfaces_added_strv</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
@ -83,19 +83,19 @@
|
||||
<citerefentry><refentrytitle>sd_bus_get_fd</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_get_method_call_timeout</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_get_n_queued_read</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_get_name_machine_id</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_get_name_creds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_get_name_machine_id</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_get_owner_creds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_get_property</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_get_property_trivial</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_get_property_string</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_get_property_strv</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_get_property_trivial</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_get_scope</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_get_tid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_get_unique_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_interface_name_is_valid</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_is_monitor</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_is_bus_client</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_is_monitor</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_is_server</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_list_names</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
@ -128,12 +128,13 @@
|
||||
<citerefentry><refentrytitle>sd_bus_message_read_array</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_message_read_basic</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_message_read_strv</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_message_reply</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_message_rewind</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_message_seal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_message_set_allow_interactive_authorization</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_message_set_destination</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_message_set_sender</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_message_set_expect_reply</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_message_set_sender</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_message_skip</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_message_verify_type</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_negotiate_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
@ -142,9 +143,8 @@
|
||||
<citerefentry><refentrytitle>sd_bus_process</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_query_sender_creds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_query_sender_privilege</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_reply_method_return</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_reply_method_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_reply</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_reply_method_return</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_request_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_send</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
<citerefentry><refentrytitle>sd_bus_send_to</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
|
||||
|
@ -19,7 +19,6 @@
|
||||
<refnamediv>
|
||||
<refname>sd_bus_reply_method_return</refname>
|
||||
<refname>sd_bus_reply_method_returnv</refname>
|
||||
<refname>sd_bus_reply</refname>
|
||||
|
||||
<refpurpose>Reply to a D-Bus method call</refpurpose>
|
||||
</refnamediv>
|
||||
@ -41,12 +40,6 @@
|
||||
<paramdef>const char *<parameter>types</parameter></paramdef>
|
||||
<paramdef>va_list <parameter>ap</parameter></paramdef>
|
||||
</funcprototype>
|
||||
|
||||
<funcprototype>
|
||||
<funcdef>int sd_bus_reply</funcdef>
|
||||
<paramdef>const sd_bus_message *<parameter>call</parameter></paramdef>
|
||||
<paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
@ -59,12 +52,6 @@
|
||||
<citerefentry><refentrytitle>sd_bus_message_append</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
|
||||
If no reply is expected to <parameter>call</parameter>, this function succeeds without sending a
|
||||
reply.</para>
|
||||
|
||||
<para><function>sd_bus_reply()</function> takes a complete bus message object created with either
|
||||
<citerefentry><refentrytitle>sd_bus_message_new_method_return</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
||||
or
|
||||
<citerefentry><refentrytitle>sd_bus_message_new_method_error</refentrytitle><manvolnum>3</manvolnum></citerefentry>
|
||||
and sends it as a reply to the <parameter>call</parameter> message.</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
|
@ -19,6 +19,7 @@
|
||||
<refnamediv>
|
||||
<refname>sd_bus_send</refname>
|
||||
<refname>sd_bus_send_to</refname>
|
||||
<refname>sd_bus_message_send</refname>
|
||||
|
||||
<refpurpose>Queue a D-Bus message for transfer</refpurpose>
|
||||
</refnamediv>
|
||||
@ -41,6 +42,11 @@
|
||||
<paramdef>const char *<parameter>destination</parameter></paramdef>
|
||||
<paramdef>uint64_t *<parameter>cookie</parameter></paramdef>
|
||||
</funcprototype>
|
||||
|
||||
<funcprototype>
|
||||
<funcdef>int sd_bus_message_send</funcdef>
|
||||
<paramdef>sd_bus_message *<parameter>m</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
@ -76,6 +82,10 @@
|
||||
call fails.
|
||||
<citerefentry><refentrytitle>sd_bus_process</refentrytitle><manvolnum>3</manvolnum></citerefentry> should
|
||||
be invoked to write out any queued message data to the transport.</para>
|
||||
|
||||
<para><function>sd_bus_message_send()</function> is the same as <function>sd_bus_send()</function> but
|
||||
without the first and last argument. It's equivalent to
|
||||
<function>sd_bus_message_send(sd_bus_message_get_bus(m), m, NULL)</function>.</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
|
@ -740,7 +740,7 @@ global:
|
||||
LIBSYSTEMD_248 {
|
||||
global:
|
||||
sd_bus_open_user_machine;
|
||||
sd_bus_reply;
|
||||
sd_bus_message_send;
|
||||
|
||||
sd_event_source_set_ratelimit;
|
||||
sd_event_source_get_ratelimit;
|
||||
|
@ -9,6 +9,14 @@
|
||||
#include "bus-type.h"
|
||||
#include "string-util.h"
|
||||
|
||||
_public_ int sd_bus_message_send(sd_bus_message *reply) {
|
||||
assert_return(reply, -EINVAL);
|
||||
assert_return(reply->bus, -EINVAL);
|
||||
assert_return(!bus_pid_changed(reply->bus), -ECHILD);
|
||||
|
||||
return sd_bus_send(reply->bus, reply, NULL);
|
||||
}
|
||||
|
||||
_public_ int sd_bus_emit_signalv(
|
||||
sd_bus *bus,
|
||||
const char *path,
|
||||
@ -198,7 +206,7 @@ _public_ int sd_bus_reply_method_returnv(
|
||||
return r;
|
||||
}
|
||||
|
||||
return sd_bus_reply(call, m);
|
||||
return sd_bus_message_send(m);
|
||||
}
|
||||
|
||||
_public_ int sd_bus_reply_method_return(
|
||||
@ -239,7 +247,7 @@ _public_ int sd_bus_reply_method_error(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return sd_bus_reply(call, m);
|
||||
return sd_bus_message_send(m);
|
||||
}
|
||||
|
||||
_public_ int sd_bus_reply_method_errorfv(
|
||||
|
@ -2604,20 +2604,6 @@ _public_ int sd_bus_get_timeout(sd_bus *bus, uint64_t *timeout_usec) {
|
||||
}
|
||||
}
|
||||
|
||||
int sd_bus_reply(const sd_bus_message *call, sd_bus_message *reply) {
|
||||
assert_return(call, -EINVAL);
|
||||
assert_return(call->sealed, -EPERM);
|
||||
assert_return(call->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL);
|
||||
assert_return(call->bus, -EINVAL);
|
||||
assert_return(!bus_pid_changed(call->bus), -ECHILD);
|
||||
assert_return(reply, -EINVAL);
|
||||
assert_return(
|
||||
IN_SET(reply->header->type, SD_BUS_MESSAGE_METHOD_RETURN, SD_BUS_MESSAGE_METHOD_ERROR),
|
||||
-EINVAL);
|
||||
|
||||
return sd_bus_send(call->bus, reply, NULL);
|
||||
}
|
||||
|
||||
static int process_timeout(sd_bus *bus) {
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
|
||||
_cleanup_(sd_bus_message_unrefp) sd_bus_message* m = NULL;
|
||||
|
@ -201,7 +201,6 @@ int sd_bus_send(sd_bus *bus, sd_bus_message *m, uint64_t *cookie);
|
||||
int sd_bus_send_to(sd_bus *bus, sd_bus_message *m, const char *destination, uint64_t *cookie);
|
||||
int sd_bus_call(sd_bus *bus, sd_bus_message *m, uint64_t usec, sd_bus_error *ret_error, sd_bus_message **reply);
|
||||
int sd_bus_call_async(sd_bus *bus, sd_bus_slot **slot, sd_bus_message *m, sd_bus_message_handler_t callback, void *userdata, uint64_t usec);
|
||||
int sd_bus_reply(const sd_bus_message *call, sd_bus_message *reply);
|
||||
|
||||
int sd_bus_get_fd(sd_bus *bus);
|
||||
int sd_bus_get_events(sd_bus *bus);
|
||||
@ -355,6 +354,7 @@ int sd_bus_get_name_machine_id(sd_bus *bus, const char *name, sd_id128_t *machin
|
||||
|
||||
/* Convenience calls */
|
||||
|
||||
int sd_bus_message_send(sd_bus_message *m);
|
||||
int sd_bus_call_methodv(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *ret_error, sd_bus_message **reply, const char *types, va_list ap);
|
||||
int sd_bus_call_method(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_error *ret_error, sd_bus_message **reply, const char *types, ...);
|
||||
int sd_bus_call_method_asyncv(sd_bus *bus, sd_bus_slot **slot, const char *destination, const char *path, const char *interface, const char *member, sd_bus_message_handler_t callback, void *userdata, const char *types, va_list ap);
|
||||
|
Loading…
Reference in New Issue
Block a user