[systemd-commits] 3 commits - src/libsystemd-bus
Lennart Poettering
lennart at kemper.freedesktop.org
Tue Dec 10 12:39:17 PST 2013
src/libsystemd-bus/bus-creds.c | 4 +++-
src/libsystemd-bus/bus-kernel.c | 26 +++++++++++++++++++++++---
src/libsystemd-bus/bus-kernel.h | 2 ++
src/libsystemd-bus/bus-message.c | 4 +++-
src/libsystemd-bus/sd-bus.c | 4 +++-
src/libsystemd-bus/sd-event.c | 8 ++++++--
6 files changed, 40 insertions(+), 8 deletions(-)
New commits:
commit ff4994c50717be97ad4df3dc77fce5125f881c7c
Author: Lennart Poettering <lennart at poettering.net>
Date: Tue Dec 10 20:38:51 2013 +0000
bus: generate debug messages when we cannot deliver messages via kdbus
diff --git a/src/libsystemd-bus/bus-kernel.c b/src/libsystemd-bus/bus-kernel.c
index e2e825f..f66cf04 100644
--- a/src/libsystemd-bus/bus-kernel.c
+++ b/src/libsystemd-bus/bus-kernel.c
@@ -418,8 +418,10 @@ int bus_kernel_write_message(sd_bus *bus, sd_bus_message *m) {
if (m->header->type == SD_BUS_MESSAGE_METHOD_CALL)
sd_bus_error_setf(&error, SD_BUS_ERROR_SERVICE_UNKNOWN, "Destination %s not known", m->destination);
- else
+ else {
+ log_debug("Could not deliver message to %s as destination is not known. Ignoring.", m->destination);
return 0;
+ }
} else if (errno == EADDRNOTAVAIL) {
@@ -427,8 +429,10 @@ int bus_kernel_write_message(sd_bus *bus, sd_bus_message *m) {
if (m->header->type == SD_BUS_MESSAGE_METHOD_CALL)
sd_bus_error_setf(&error, SD_BUS_ERROR_SERVICE_UNKNOWN, "Activation of %s not requested", m->destination);
- else
+ else {
+ log_debug("Could not deliver message to %s as destination is not activated. Ignoring.", m->destination);
return 0;
+ }
} else
return -errno;
@@ -897,7 +901,7 @@ int bus_kernel_read_message(sd_bus *bus) {
/* Anybody can send us invalid messages, let's just drop them. */
if (r == -EBADMSG || r == -EPROTOTYPE) {
- log_error("Ignoring invalid message: %s", strerror(-r));
+ log_debug("Ignoring invalid message: %s", strerror(-r));
r = 0;
}
commit 5b1bc83f81bf318aa365dc539b2e0be00fdaa63b
Author: Lennart Poettering <lennart at poettering.net>
Date: Tue Dec 10 20:38:04 2013 +0000
bus: when we _unref() a NULL pointer, don't use assert_return()
We support unreffing NULL pointers just fine and we shouldn't pay the
_unlikely_() price for it, not get a debug message if we do, hence let's
not use assert_return() here.
diff --git a/src/libsystemd-bus/bus-creds.c b/src/libsystemd-bus/bus-creds.c
index 1eb0e02..9d90c49 100644
--- a/src/libsystemd-bus/bus-creds.c
+++ b/src/libsystemd-bus/bus-creds.c
@@ -72,7 +72,9 @@ _public_ sd_bus_creds *sd_bus_creds_ref(sd_bus_creds *c) {
}
_public_ sd_bus_creds *sd_bus_creds_unref(sd_bus_creds *c) {
- assert_return(c, NULL);
+
+ if (!c)
+ return NULL;
if (c->allocated) {
assert(c->n_ref > 0);
diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c
index 9e71271..0f19ee2 100644
--- a/src/libsystemd-bus/bus-message.c
+++ b/src/libsystemd-bus/bus-message.c
@@ -791,7 +791,9 @@ _public_ sd_bus_message* sd_bus_message_ref(sd_bus_message *m) {
}
_public_ sd_bus_message* sd_bus_message_unref(sd_bus_message *m) {
- assert_return(m, NULL);
+
+ if (!m)
+ return NULL;
assert(m->n_ref > 0);
m->n_ref--;
diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c
index 81bfe0d..91fac48 100644
--- a/src/libsystemd-bus/sd-bus.c
+++ b/src/libsystemd-bus/sd-bus.c
@@ -1214,7 +1214,9 @@ _public_ sd_bus *sd_bus_ref(sd_bus *bus) {
}
_public_ sd_bus *sd_bus_unref(sd_bus *bus) {
- assert_return(bus, NULL);
+
+ if (!bus)
+ return NULL;
if (REFCNT_DEC(bus->n_ref) <= 0)
bus_free(bus);
diff --git a/src/libsystemd-bus/sd-event.c b/src/libsystemd-bus/sd-event.c
index b5ddf71..282e914 100644
--- a/src/libsystemd-bus/sd-event.c
+++ b/src/libsystemd-bus/sd-event.c
@@ -384,7 +384,9 @@ _public_ sd_event* sd_event_ref(sd_event *e) {
}
_public_ sd_event* sd_event_unref(sd_event *e) {
- assert_return(e, NULL);
+
+ if (!e)
+ return NULL;
assert(e->n_ref >= 1);
e->n_ref--;
@@ -973,7 +975,9 @@ _public_ sd_event_source* sd_event_source_ref(sd_event_source *s) {
}
_public_ sd_event_source* sd_event_source_unref(sd_event_source *s) {
- assert_return(s, NULL);
+
+ if (!s)
+ return NULL;
assert(s->n_ref >= 1);
s->n_ref--;
commit c8fa3f60302f6d1bf7b2f7b31fb7e5a46b3d53c1
Author: Lukasz Skalski <l.skalski at partner.samsung.com>
Date: Tue Dec 3 15:17:55 2013 +0100
bus: Add bus_kernel_monitor function
diff --git a/src/libsystemd-bus/bus-kernel.c b/src/libsystemd-bus/bus-kernel.c
index d0a9fbc..e2e825f 100644
--- a/src/libsystemd-bus/bus-kernel.c
+++ b/src/libsystemd-bus/bus-kernel.c
@@ -1211,3 +1211,19 @@ int bus_kernel_create_namespace(const char *name, char **s) {
return fd;
}
+
+int bus_kernel_monitor(sd_bus *bus) {
+ struct kdbus_cmd_monitor cmd_monitor;
+ int r;
+
+ assert(bus);
+
+ cmd_monitor.id = 0;
+ cmd_monitor.flags = KDBUS_MONITOR_ENABLE;
+
+ r = ioctl(bus->input_fd, KDBUS_CMD_MONITOR, &cmd_monitor);
+ if (r < 0)
+ return -errno;
+
+ return 1;
+}
diff --git a/src/libsystemd-bus/bus-kernel.h b/src/libsystemd-bus/bus-kernel.h
index 1771020..c5d469c 100644
--- a/src/libsystemd-bus/bus-kernel.h
+++ b/src/libsystemd-bus/bus-kernel.h
@@ -73,3 +73,5 @@ int bus_kernel_parse_unique_name(const char *s, uint64_t *id);
int kdbus_translate_request_name_flags(uint64_t sd_bus_flags, uint64_t *kdbus_flags);
int kdbus_translate_attach_flags(uint64_t sd_bus_flags, uint64_t *kdbus_flags);
+
+int bus_kernel_monitor(sd_bus *bus);
More information about the systemd-commits
mailing list