mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-12 21:57:27 +03:00
Merge pull request #19250 from keszybz/sd-bus-is-ready-simplification
Simplify how sd_bus_is_ready() is used
This commit is contained in:
commit
d8e4c59785
@ -57,6 +57,9 @@
|
||||
zero outside of this state, and positive otherwise. Effectively, this function returns positive while regular
|
||||
messages can be sent or received on the connection.</para>
|
||||
|
||||
<para>The <parameter>bus</parameter> argument may be <constant>NULL</constant>, zero is also returned in
|
||||
that case.</para>
|
||||
|
||||
<para>To be notified when the connection is fully established, use
|
||||
<citerefentry><refentrytitle>sd_bus_set_connected_signal</refentrytitle><manvolnum>3</manvolnum></citerefentry> and
|
||||
install a match for the <function>Connected()</function> signal on the
|
||||
@ -68,8 +71,8 @@
|
||||
<refsect1>
|
||||
<title>Return Value</title>
|
||||
|
||||
<para>On success, these functions return 0 or a positive integer. On failure, they return a negative errno-style
|
||||
error code.</para>
|
||||
<para>Those functions return 0 if the bus is <emphasis>not</emphasis> in the given state, and a positive
|
||||
integer when it is. On failure, a negative errno-style error code is returned.</para>
|
||||
|
||||
<refsect2>
|
||||
<title>Errors</title>
|
||||
|
@ -1800,7 +1800,9 @@ void bus_enter_closing(sd_bus *bus) {
|
||||
DEFINE_PUBLIC_TRIVIAL_REF_UNREF_FUNC(sd_bus, sd_bus, bus_free);
|
||||
|
||||
_public_ int sd_bus_is_open(sd_bus *bus) {
|
||||
assert_return(bus, -EINVAL);
|
||||
if (!bus)
|
||||
return 0;
|
||||
|
||||
assert_return(bus = bus_resolve(bus), -ENOPKG);
|
||||
assert_return(!bus_pid_changed(bus), -ECHILD);
|
||||
|
||||
@ -1808,7 +1810,9 @@ _public_ int sd_bus_is_open(sd_bus *bus) {
|
||||
}
|
||||
|
||||
_public_ int sd_bus_is_ready(sd_bus *bus) {
|
||||
assert_return(bus, -EINVAL);
|
||||
if (!bus)
|
||||
return 0;
|
||||
|
||||
assert_return(bus = bus_resolve(bus), -ENOPKG);
|
||||
assert_return(!bus_pid_changed(bus), -ECHILD);
|
||||
|
||||
|
@ -167,7 +167,7 @@ int manager_request_product_uuid(Manager *m, Link *link) {
|
||||
return log_oom();
|
||||
}
|
||||
|
||||
if (!m->bus || sd_bus_is_ready(m->bus) <= 0) {
|
||||
if (sd_bus_is_ready(m->bus) <= 0) {
|
||||
log_debug("Not connected to system bus, requesting product UUID later.");
|
||||
return 0;
|
||||
}
|
||||
|
@ -854,7 +854,7 @@ int link_send_changed_strv(Link *link, char **properties) {
|
||||
assert(link->manager);
|
||||
assert(properties);
|
||||
|
||||
if (!link->manager->bus || sd_bus_is_ready(link->manager->bus) <= 0)
|
||||
if (sd_bus_is_ready(link->manager->bus) <= 0)
|
||||
return 0;
|
||||
|
||||
p = link_bus_path(link);
|
||||
|
@ -339,7 +339,7 @@ int manager_send_changed_strv(Manager *manager, char **properties) {
|
||||
assert(manager);
|
||||
assert(properties);
|
||||
|
||||
if (!manager->bus || sd_bus_is_ready(manager->bus) <= 0)
|
||||
if (sd_bus_is_ready(manager->bus) <= 0)
|
||||
return 0;
|
||||
|
||||
return sd_bus_emit_properties_changed_strv(
|
||||
|
@ -767,8 +767,8 @@ int manager_set_hostname(Manager *m, const char *hostname) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (!m->bus || sd_bus_is_ready(m->bus) <= 0) {
|
||||
log_debug("Not connected to system bus, setting hostname later.");
|
||||
if (sd_bus_is_ready(m->bus) <= 0) {
|
||||
log_debug("Not connected to system bus, setting system hostname later.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -784,7 +784,6 @@ int manager_set_hostname(Manager *m, const char *hostname) {
|
||||
"sb",
|
||||
hostname,
|
||||
false);
|
||||
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not set transient hostname: %m");
|
||||
|
||||
@ -817,8 +816,8 @@ int manager_set_timezone(Manager *m, const char *tz) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (!m->bus || sd_bus_is_ready(m->bus) <= 0) {
|
||||
log_debug("Not connected to system bus, setting timezone later.");
|
||||
if (sd_bus_is_ready(m->bus) <= 0) {
|
||||
log_debug("Not connected to system bus, setting system timezone later.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user