[systemd-commits] 3 commits - src/core src/import src/libsystemd src/login src/machine src/resolve
Lennart Poettering
lennart at kemper.freedesktop.org
Wed Apr 29 10:10:54 PDT 2015
src/core/dbus-manager.c | 9 ++++-----
src/core/dbus.c | 19 +++++--------------
src/core/manager.h | 8 +++-----
src/import/importd.c | 2 +-
src/libsystemd/sd-bus/sd-bus.c | 20 ++++++++++++++++----
src/login/logind-dbus.c | 8 ++++----
src/machine/machine-dbus.c | 8 ++++----
src/machine/machined-dbus.c | 4 ++--
src/resolve/resolved-bus.c | 6 +++---
src/resolve/resolved-dns-query.c | 4 ++--
src/resolve/resolved-dns-query.h | 2 +-
11 files changed, 45 insertions(+), 45 deletions(-)
New commits:
commit 966c66e34940001a40806142ecebaae61b478444
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Apr 29 19:10:09 2015 +0200
tree-wide: get rid of a few more explicit bus parameters
diff --git a/src/core/dbus.c b/src/core/dbus.c
index d1843aa..4005aac 100644
--- a/src/core/dbus.c
+++ b/src/core/dbus.c
@@ -147,13 +147,11 @@ static int signal_activation_request(sd_bus_message *message, void *userdata, sd
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
Manager *m = userdata;
const char *name;
- sd_bus *bus;
Unit *u;
int r;
assert(message);
assert(m);
- assert_se(bus = sd_bus_message_get_bus(message));
r = sd_bus_message_read(message, "s", &name);
if (r < 0) {
@@ -189,7 +187,7 @@ failed:
log_debug("D-Bus activation failed for %s: %s", name, bus_error_message(&error, r));
- r = sd_bus_message_new_signal(bus, &reply, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Activator", "ActivationFailure");
+ r = sd_bus_message_new_signal(sd_bus_message_get_bus(message), &reply, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Activator", "ActivationFailure");
if (r < 0) {
bus_log_create_error(r);
return 0;
@@ -201,7 +199,7 @@ failed:
return 0;
}
- r = sd_bus_send_to(bus, reply, "org.freedesktop.DBus", NULL);
+ r = sd_bus_send_to(NULL, reply, "org.freedesktop.DBus", NULL);
if (r < 0)
return log_error_errno(r, "Failed to respond with to bus activation request: %m");
diff --git a/src/resolve/resolved-bus.c b/src/resolve/resolved-bus.c
index 0ea585e..171141e 100644
--- a/src/resolve/resolved-bus.c
+++ b/src/resolve/resolved-bus.c
@@ -339,7 +339,7 @@ static int bus_method_resolve_hostname(sd_bus_message *message, void *userdata,
q->request_hostname = hostname;
q->complete = bus_method_resolve_hostname_complete;
- r = dns_query_bus_track(q, sd_bus_message_get_bus(message), message);
+ r = dns_query_bus_track(q, message);
if (r < 0)
return r;
@@ -491,7 +491,7 @@ static int bus_method_resolve_address(sd_bus_message *message, void *userdata, s
memcpy(&q->request_address, d, sz);
q->complete = bus_method_resolve_address_complete;
- r = dns_query_bus_track(q, sd_bus_message_get_bus(message), message);
+ r = dns_query_bus_track(q, message);
if (r < 0)
return r;
@@ -643,7 +643,7 @@ static int bus_method_resolve_record(sd_bus_message *message, void *userdata, sd
q->request_hostname = name;
q->complete = bus_method_resolve_record_complete;
- r = dns_query_bus_track(q, sd_bus_message_get_bus(message), message);
+ r = dns_query_bus_track(q, message);
if (r < 0)
return r;
diff --git a/src/resolve/resolved-dns-query.c b/src/resolve/resolved-dns-query.c
index d619fae..418d972 100644
--- a/src/resolve/resolved-dns-query.c
+++ b/src/resolve/resolved-dns-query.c
@@ -467,14 +467,14 @@ static int on_bus_track(sd_bus_track *t, void *userdata) {
return 0;
}
-int dns_query_bus_track(DnsQuery *q, sd_bus *bus, sd_bus_message *m) {
+int dns_query_bus_track(DnsQuery *q, sd_bus_message *m) {
int r;
assert(q);
assert(m);
if (!q->bus_track) {
- r = sd_bus_track_new(bus, &q->bus_track, on_bus_track, q);
+ r = sd_bus_track_new(sd_bus_message_get_bus(m), &q->bus_track, on_bus_track, q);
if (r < 0)
return r;
}
diff --git a/src/resolve/resolved-dns-query.h b/src/resolve/resolved-dns-query.h
index 788992e..5a319f0 100644
--- a/src/resolve/resolved-dns-query.h
+++ b/src/resolve/resolved-dns-query.h
@@ -75,6 +75,6 @@ void dns_query_ready(DnsQuery *q);
int dns_query_cname_redirect(DnsQuery *q, const char *name);
-int dns_query_bus_track(DnsQuery *q, sd_bus *bus, sd_bus_message *m);
+int dns_query_bus_track(DnsQuery *q, sd_bus_message *m);
DEFINE_TRIVIAL_CLEANUP_FUNC(DnsQuery*, dns_query_free);
commit 8f88ecf6232fe6c46eecafad7c421096bb29b617
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Apr 29 19:02:08 2015 +0200
core: for queued reload message there is no need to store the bus explicitly
After all it can be derived from the message directly, and already is.
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index 632529f..18a379f 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -1166,7 +1166,6 @@ static int method_reload(sd_bus_message *message, void *userdata, sd_bus_error *
if (r < 0)
return r;
- m->queued_message_bus = sd_bus_ref(sd_bus_message_get_bus(message));
m->exit_code = MANAGER_RELOAD;
return 1;
diff --git a/src/core/dbus.c b/src/core/dbus.c
index 8d72502..d1843aa 100644
--- a/src/core/dbus.c
+++ b/src/core/dbus.c
@@ -55,18 +55,15 @@ int bus_send_queued_message(Manager *m) {
if (!m->queued_message)
return 0;
- assert(m->queued_message_bus);
-
/* If we cannot get rid of this message we won't dispatch any
* D-Bus messages, so that we won't end up wanting to queue
* another message. */
- r = sd_bus_send(m->queued_message_bus, m->queued_message, NULL);
+ r = sd_bus_send(NULL, m->queued_message, NULL);
if (r < 0)
log_warning_errno(r, "Failed to send queued message: %m");
m->queued_message = sd_bus_message_unref(m->queued_message);
- m->queued_message_bus = sd_bus_unref(m->queued_message_bus);
return 0;
}
@@ -1031,12 +1028,8 @@ static void destroy_bus(Manager *m, sd_bus **bus) {
j->clients = sd_bus_track_unref(j->clients);
/* Get rid of queued message on this bus */
- if (m->queued_message_bus == *bus) {
- m->queued_message_bus = sd_bus_unref(m->queued_message_bus);
-
- if (m->queued_message)
- m->queued_message = sd_bus_message_unref(m->queued_message);
- }
+ if (m->queued_message && sd_bus_message_get_bus(m->queued_message) == *bus)
+ m->queued_message = sd_bus_message_unref(m->queued_message);
/* Possibly flush unwritten data, but only if we are
* unprivileged, since we don't want to sync here */
diff --git a/src/core/manager.h b/src/core/manager.h
index a1caab4..a9834a9 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -199,11 +199,9 @@ struct Manager {
sd_bus_track *subscribed;
char **deserialized_subscribed;
- sd_bus_message *queued_message; /* This is used during reloading:
- * before the reload we queue the
- * reply message here, and
- * afterwards we send it */
- sd_bus *queued_message_bus; /* The connection to send the queued message on */
+ /* This is used during reloading: before the reload we queue
+ * the reply message here, and afterwards we send it */
+ sd_bus_message *queued_message;
Hashmap *watch_bus; /* D-Bus names => Unit object n:1 */
commit 9030ca462bd13cd6536299814e4a71d5c5e85be9
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Apr 29 18:58:30 2015 +0200
sd-bus: allow passing NULL as bus parameter to sd_bus_send()
If NULL is specified for the bus it is now automatically derived from
the passed in message.
This commit also changes a number of invocations of sd_bus_send() to
make use of this.
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index 5fb0da2..632529f 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -916,7 +916,7 @@ static int list_units_filtered(sd_bus_message *message, void *userdata, sd_bus_e
if (r < 0)
return r;
- return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL);
+ return sd_bus_send(NULL, reply, NULL);
}
static int method_list_units(sd_bus_message *message, void *userdata, sd_bus_error *error) {
@@ -985,7 +985,7 @@ static int method_list_jobs(sd_bus_message *message, void *userdata, sd_bus_erro
if (r < 0)
return r;
- return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL);
+ return sd_bus_send(NULL, reply, NULL);
}
static int method_subscribe(sd_bus_message *message, void *userdata, sd_bus_error *error) {
@@ -1502,7 +1502,7 @@ static int method_list_unit_files(sd_bus_message *message, void *userdata, sd_bu
if (r < 0)
return r;
- return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL);
+ return sd_bus_send(NULL, reply, NULL);
fail:
unit_file_list_free(h);
@@ -1620,7 +1620,7 @@ static int reply_unit_file_changes_and_free(
if (r < 0)
goto fail;
- return sd_bus_send(sd_bus_message_get_bus(message), reply, NULL);
+ return sd_bus_send(NULL, reply, NULL);
fail:
unit_file_changes_free(changes, n_changes);
diff --git a/src/import/importd.c b/src/import/importd.c
index 4f3701f..45d1d93 100644
--- a/src/import/importd.c
+++ b/src/import/importd.c
@@ -1064,7 +1064,7 @@ static int method_list_transfers(sd_bus_message *msg, void *userdata, sd_bus_err
if (r < 0)
return r;
- return sd_bus_send(sd_bus_message_get_bus(msg), reply, NULL);
+ return sd_bus_send(NULL, reply, NULL);
}
static int method_cancel(sd_bus_message *msg, void *userdata, sd_bus_error *error) {
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index 41fbe7d..214b3d0 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -1695,8 +1695,11 @@ static int bus_send_internal(sd_bus *bus, sd_bus_message *_m, uint64_t *cookie,
_cleanup_bus_message_unref_ sd_bus_message *m = sd_bus_message_ref(_m);
int r;
- assert_return(bus, -EINVAL);
assert_return(m, -EINVAL);
+
+ if (!bus)
+ bus = m->bus;
+
assert_return(!bus_pid_changed(bus), -ECHILD);
assert_return(!bus->is_kernel || !(bus->hello_flags & KDBUS_HELLO_MONITOR), -EROFS);
@@ -1781,8 +1784,11 @@ _public_ int sd_bus_send(sd_bus *bus, sd_bus_message *m, uint64_t *cookie) {
_public_ int sd_bus_send_to(sd_bus *bus, sd_bus_message *m, const char *destination, uint64_t *cookie) {
int r;
- assert_return(bus, -EINVAL);
assert_return(m, -EINVAL);
+
+ if (!bus)
+ bus = m->bus;
+
assert_return(!bus_pid_changed(bus), -ECHILD);
if (!BUS_IS_OPEN(bus->state))
@@ -1838,11 +1844,14 @@ _public_ int sd_bus_call_async(
_cleanup_bus_slot_unref_ sd_bus_slot *s = NULL;
int r;
- assert_return(bus, -EINVAL);
assert_return(m, -EINVAL);
assert_return(m->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL);
assert_return(!(m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED), -EINVAL);
assert_return(callback, -EINVAL);
+
+ if (!bus)
+ bus = m->bus;
+
assert_return(!bus_pid_changed(bus), -ECHILD);
assert_return(!bus->is_kernel || !(bus->hello_flags & KDBUS_HELLO_MONITOR), -EROFS);
@@ -1936,11 +1945,14 @@ _public_ int sd_bus_call(
unsigned i;
int r;
- assert_return(bus, -EINVAL);
assert_return(m, -EINVAL);
assert_return(m->header->type == SD_BUS_MESSAGE_METHOD_CALL, -EINVAL);
assert_return(!(m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED), -EINVAL);
assert_return(!bus_error_is_dirty(error), -EINVAL);
+
+ if (!bus)
+ bus = m->bus;
+
assert_return(!bus_pid_changed(bus), -ECHILD);
assert_return(!bus->is_kernel || !(bus->hello_flags & KDBUS_HELLO_MONITOR), -EROFS);
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 7603b0e..1f5cf86 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -428,7 +428,7 @@ static int method_list_sessions(sd_bus_message *message, void *userdata, sd_bus_
if (r < 0)
return r;
- return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL);
+ return sd_bus_send(NULL, reply, NULL);
}
static int method_list_users(sd_bus_message *message, void *userdata, sd_bus_error *error) {
@@ -468,7 +468,7 @@ static int method_list_users(sd_bus_message *message, void *userdata, sd_bus_err
if (r < 0)
return r;
- return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL);
+ return sd_bus_send(NULL, reply, NULL);
}
static int method_list_seats(sd_bus_message *message, void *userdata, sd_bus_error *error) {
@@ -505,7 +505,7 @@ static int method_list_seats(sd_bus_message *message, void *userdata, sd_bus_err
if (r < 0)
return r;
- return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL);
+ return sd_bus_send(NULL, reply, NULL);
}
static int method_list_inhibitors(sd_bus_message *message, void *userdata, sd_bus_error *error) {
@@ -543,7 +543,7 @@ static int method_list_inhibitors(sd_bus_message *message, void *userdata, sd_bu
if (r < 0)
return r;
- return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL);
+ return sd_bus_send(NULL, reply, NULL);
}
static int method_create_session(sd_bus_message *message, void *userdata, sd_bus_error *error) {
diff --git a/src/machine/machine-dbus.c b/src/machine/machine-dbus.c
index 4e73467..0892479 100644
--- a/src/machine/machine-dbus.c
+++ b/src/machine/machine-dbus.c
@@ -335,7 +335,7 @@ int bus_machine_method_get_addresses(sd_bus_message *message, void *userdata, sd
if (r < 0)
return r;
- return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL);
+ return sd_bus_send(NULL, reply, NULL);
}
int bus_machine_method_get_os_release(sd_bus_message *message, void *userdata, sd_bus_error *error) {
@@ -426,7 +426,7 @@ int bus_machine_method_get_os_release(sd_bus_message *message, void *userdata, s
if (r < 0)
return r;
- return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL);
+ return sd_bus_send(NULL, reply, NULL);
}
int bus_machine_method_open_pty(sd_bus_message *message, void *userdata, sd_bus_error *error) {
@@ -458,7 +458,7 @@ int bus_machine_method_open_pty(sd_bus_message *message, void *userdata, sd_bus_
if (r < 0)
return r;
- return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL);
+ return sd_bus_send(NULL, reply, NULL);
}
int bus_machine_method_open_login(sd_bus_message *message, void *userdata, sd_bus_error *error) {
@@ -551,7 +551,7 @@ int bus_machine_method_open_login(sd_bus_message *message, void *userdata, sd_bu
if (r < 0)
return r;
- return sd_bus_send(sd_bus_message_get_bus(reply), reply, NULL);
+ return sd_bus_send(NULL, reply, NULL);
}
int bus_machine_method_bind_mount(sd_bus_message *message, void *userdata, sd_bus_error *error) {
diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c
index 5036a63..0e971a6 100644
--- a/src/machine/machined-dbus.c
+++ b/src/machine/machined-dbus.c
@@ -255,7 +255,7 @@ static int method_list_machines(sd_bus_message *message, void *userdata, sd_bus_
if (r < 0)
return sd_bus_error_set_errno(error, r);
- return sd_bus_send(sd_bus_message_get_bus(message), reply, NULL);
+ return sd_bus_send(NULL, reply, NULL);
}
static int method_create_or_register_machine(Manager *manager, sd_bus_message *message, bool read_network, Machine **_m, sd_bus_error *error) {
@@ -593,7 +593,7 @@ static int method_list_images(sd_bus_message *message, void *userdata, sd_bus_er
if (r < 0)
return r;
- return sd_bus_send(sd_bus_message_get_bus(message), reply, NULL);
+ return sd_bus_send(NULL, reply, NULL);
}
static int method_open_machine_pty(sd_bus_message *message, void *userdata, sd_bus_error *error) {
More information about the systemd-commits
mailing list