[systemd-commits] 3 commits - TODO src/libsystemd src/systemd

Lennart Poettering lennart at kemper.freedesktop.org
Wed Jan 22 11:30:03 PST 2014


 TODO                                    |   10 +++++-----
 src/libsystemd/libsystemd.sym           |    3 +++
 src/libsystemd/sd-bus/bus-dump.c        |    5 +++--
 src/libsystemd/sd-bus/bus-kernel.c      |    8 +++++++-
 src/libsystemd/sd-bus/bus-kernel.h      |    2 +-
 src/libsystemd/sd-bus/bus-message.c     |   16 ++++++++++++++++
 src/libsystemd/sd-bus/bus-message.h     |    1 +
 src/libsystemd/sd-bus/sd-bus.c          |   30 +++++++++++++++++++++---------
 src/libsystemd/sd-bus/test-bus-kernel.c |    3 +++
 src/systemd/sd-bus.h                    |    3 +++
 10 files changed, 63 insertions(+), 18 deletions(-)

New commits:
commit ab9716c2489f9141ed13ec22dbb216b3e6fbd6b5
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jan 22 20:29:57 2014 +0100

    update TODO

diff --git a/TODO b/TODO
index 0999c90..583b42d 100644
--- a/TODO
+++ b/TODO
@@ -147,7 +147,6 @@ Features:
   ReadOnlyDirectories=... for whitelisting files for a service.
 
 * sd-bus:
-  - let the activator peek the peer connection with KDBUS_CMD_MSG_SRC and log it
   - when kdbus doesn't take our message without memfds, try again with memfds
   - implement monitor logic
   - see if we can drop more message validation on the sending side
@@ -155,9 +154,7 @@ Features:
   - systemd-bus-proxyd needs to enforce good old XML policy
   - upload minimal kdbus policy into the kernel at boot
   - kdbus: matches against source or destination pids for an "strace -p"-like feel. Problem: The PID info needs to be available in userspace too...
-  - longer term:
-    * priority queues
-    * priority inheritance
+  - longer term: priority inheritance
   - check sender of response messages
   - dbus spec updates:
        - kdbus mapping
@@ -165,11 +162,14 @@ Features:
        - GVariant
        - "const" properties (posted)
   - port exit-on-idle logic to byebye ioctl
-  - make use of "drop" ioctl in pid 1 bus activation
   - bus proxy: override unique id sender for messages from driver to match the well-known name
   - bus driver: GetNameOwner() for "org.freedesktop.DBus" should return "org.freedesktop.DBus"
   - update systemd.special(7) to mention that dbus.socket is only about the compatibility socket now
   - bus proxy should fake seclabel when connecting to kdbus
+  - sd_bus_message_set_no_reply() → sd_bus_message_set_expect_reply() and similar for no_auto_start
+  - allow updating attach flags during runtime
+  - pid1: peek into activating message when activating a service
+  - when service activation failed, drop one message from the activator queue
 
 * sd-event
   - allow multiple signal handlers per signal?

commit 766c580959336be16f7c724b158f8e8fbaba2e9a
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jan 22 20:26:58 2014 +0100

    bus: add sd_bus_process_priority() to support prioq mode of kdbus

diff --git a/src/libsystemd/libsystemd.sym b/src/libsystemd/libsystemd.sym
index fc9c4f8..984bc15 100644
--- a/src/libsystemd/libsystemd.sym
+++ b/src/libsystemd/libsystemd.sym
@@ -46,6 +46,7 @@ global:
         sd_bus_get_events;
         sd_bus_get_timeout;
         sd_bus_process;
+        sd_bus_process_priority;
         sd_bus_wait;
         sd_bus_flush;
         sd_bus_get_current;
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 77ad5ca..27c2e0e 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -1039,7 +1039,7 @@ static int bus_kernel_translate_message(sd_bus *bus, struct kdbus_msg *k) {
         return translate[found->type - _KDBUS_ITEM_KERNEL_BASE](bus, k, found);
 }
 
-int bus_kernel_read_message(sd_bus *bus) {
+int bus_kernel_read_message(sd_bus *bus, bool hint_priority, int64_t priority) {
         struct kdbus_cmd_recv recv = {};
         struct kdbus_msg *k;
         int r;
@@ -1050,6 +1050,11 @@ int bus_kernel_read_message(sd_bus *bus) {
         if (r < 0)
                 return r;
 
+        if (hint_priority) {
+                recv.flags |= KDBUS_RECV_USE_PRIORITY;
+                recv.priority = priority;
+        }
+
         r = ioctl(bus->input_fd, KDBUS_CMD_MSG_RECV, &recv);
         if (r < 0) {
                 if (errno == EAGAIN)
diff --git a/src/libsystemd/sd-bus/bus-kernel.h b/src/libsystemd/sd-bus/bus-kernel.h
index b516396..63df63e 100644
--- a/src/libsystemd/sd-bus/bus-kernel.h
+++ b/src/libsystemd/sd-bus/bus-kernel.h
@@ -61,7 +61,7 @@ int bus_kernel_connect(sd_bus *b);
 int bus_kernel_take_fd(sd_bus *b);
 
 int bus_kernel_write_message(sd_bus *bus, sd_bus_message *m, bool hint_sync_call);
-int bus_kernel_read_message(sd_bus *bus);
+int bus_kernel_read_message(sd_bus *bus, bool hint_priority, int64_t priority);
 
 int bus_kernel_create_bus(const char *name, bool world, char **s);
 int bus_kernel_create_namespace(const char *name, char **s);
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index a8295b2..9f8c244 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -1458,11 +1458,11 @@ static int dispatch_wqueue(sd_bus *bus) {
         return ret;
 }
 
-static int bus_read_message(sd_bus *bus) {
+static int bus_read_message(sd_bus *bus, bool hint_priority, int64_t priority) {
         assert(bus);
 
         if (bus->is_kernel)
-                return bus_kernel_read_message(bus);
+                return bus_kernel_read_message(bus, hint_priority, priority);
         else
                 return bus_socket_read_message(bus);
 }
@@ -1479,13 +1479,17 @@ int bus_rqueue_make_room(sd_bus *bus) {
         return 0;
 }
 
-static int dispatch_rqueue(sd_bus *bus, sd_bus_message **m) {
+static int dispatch_rqueue(sd_bus *bus, bool hint_priority, int64_t priority, sd_bus_message **m) {
         int r, ret = 0;
 
         assert(bus);
         assert(m);
         assert(bus->state == BUS_RUNNING || bus->state == BUS_HELLO);
 
+        /* Note that the priority logic is only available on kdbus,
+         * where the rqueue is unused. We check the rqueue here
+         * anyway, because it's simple... */
+
         for (;;) {
                 if (bus->rqueue_size > 0) {
                         /* Dispatch a queued message */
@@ -1497,7 +1501,7 @@ static int dispatch_rqueue(sd_bus *bus, sd_bus_message **m) {
                 }
 
                 /* Try to read a new message */
-                r = bus_read_message(bus);
+                r = bus_read_message(bus, hint_priority, priority);
                 if (r < 0)
                         return r;
                 if (r == 0)
@@ -1837,7 +1841,7 @@ _public_ int sd_bus_call(
                         i++;
                 }
 
-                r = bus_read_message(bus);
+                r = bus_read_message(bus, false, 0);
                 if (r < 0) {
                         if (r == -ENOTCONN || r == -ECONNRESET || r == -EPIPE || r == -ESHUTDOWN) {
                                 bus_enter_closing(bus);
@@ -2203,7 +2207,7 @@ finish:
         return r;
 }
 
-static int process_running(sd_bus *bus, sd_bus_message **ret) {
+static int process_running(sd_bus *bus, bool hint_priority, int64_t priority, sd_bus_message **ret) {
         _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
         int r;
 
@@ -2218,7 +2222,7 @@ static int process_running(sd_bus *bus, sd_bus_message **ret) {
         if (r != 0)
                 goto null_message;
 
-        r = dispatch_rqueue(bus, &m);
+        r = dispatch_rqueue(bus, hint_priority, priority, &m);
         if (r < 0)
                 return r;
         if (!m)
@@ -2344,7 +2348,7 @@ finish:
         return r;
 }
 
-_public_ int sd_bus_process(sd_bus *bus, sd_bus_message **ret) {
+static int bus_process_internal(sd_bus *bus, bool hint_priority, int64_t priority, sd_bus_message **ret) {
         BUS_DONT_DESTROY(bus);
         int r;
 
@@ -2393,7 +2397,7 @@ _public_ int sd_bus_process(sd_bus *bus, sd_bus_message **ret) {
 
         case BUS_RUNNING:
         case BUS_HELLO:
-                r = process_running(bus, ret);
+                r = process_running(bus, hint_priority, priority, ret);
                 if (r == -ENOTCONN || r == -ECONNRESET || r == -EPIPE || r == -ESHUTDOWN) {
                         bus_enter_closing(bus);
                         r = 1;
@@ -2411,6 +2415,14 @@ _public_ int sd_bus_process(sd_bus *bus, sd_bus_message **ret) {
         assert_not_reached("Unknown state");
 }
 
+_public_ int sd_bus_process(sd_bus *bus, sd_bus_message **ret) {
+        return bus_process_internal(bus, false, 0, ret);
+}
+
+_public_ int sd_bus_process_priority(sd_bus *bus, int64_t priority, sd_bus_message **ret) {
+        return bus_process_internal(bus, true, priority, ret);
+}
+
 static int bus_poll(sd_bus *bus, bool need_more, uint64_t timeout_usec) {
         struct pollfd p[2] = {};
         int r, e, n;
diff --git a/src/libsystemd/sd-bus/test-bus-kernel.c b/src/libsystemd/sd-bus/test-bus-kernel.c
index 0fab880..30cc313 100644
--- a/src/libsystemd/sd-bus/test-bus-kernel.c
+++ b/src/libsystemd/sd-bus/test-bus-kernel.c
@@ -110,6 +110,9 @@ int main(int argc, char *argv[]) {
         r = sd_bus_try_close(b);
         assert_se(r == -EBUSY);
 
+        r = sd_bus_process_priority(b, -10, &m);
+        assert_se(r == -ENOMSG);
+
         r = sd_bus_process(b, &m);
         assert_se(r > 0);
         assert_se(m);
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index 6f9443a..01f6275 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -139,6 +139,7 @@ int sd_bus_get_fd(sd_bus *bus);
 int sd_bus_get_events(sd_bus *bus);
 int sd_bus_get_timeout(sd_bus *bus, uint64_t *timeout_usec);
 int sd_bus_process(sd_bus *bus, sd_bus_message **r);
+int sd_bus_process_priority(sd_bus *bus, int64_t max_priority, sd_bus_message **r);
 int sd_bus_wait(sd_bus *bus, uint64_t timeout_usec);
 int sd_bus_flush(sd_bus *bus);
 

commit ca7b42c81652c342288a3e0a10abd885c66ac5b2
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jan 22 20:01:23 2014 +0100

    bus: expose priority field of messages, in preparation for prioq support

diff --git a/src/libsystemd/libsystemd.sym b/src/libsystemd/libsystemd.sym
index 0337e4e..fc9c4f8 100644
--- a/src/libsystemd/libsystemd.sym
+++ b/src/libsystemd/libsystemd.sym
@@ -86,6 +86,7 @@ global:
         sd_bus_message_get_reply_cookie;
         sd_bus_message_get_no_reply;
         sd_bus_message_get_no_auto_start;
+        sd_bus_message_get_priority;
         sd_bus_message_get_signature;
         sd_bus_message_get_path;
         sd_bus_message_get_interface;
@@ -104,6 +105,7 @@ global:
         sd_bus_message_set_no_reply;
         sd_bus_message_set_no_auto_start;
         sd_bus_message_set_destination;
+        sd_bus_message_set_priority;
         sd_bus_message_append;
         sd_bus_message_append_basic;
         sd_bus_message_append_array;
diff --git a/src/libsystemd/sd-bus/bus-dump.c b/src/libsystemd/sd-bus/bus-dump.c
index a2b6358..0e41549 100644
--- a/src/libsystemd/sd-bus/bus-dump.c
+++ b/src/libsystemd/sd-bus/bus-dump.c
@@ -54,14 +54,15 @@ int bus_message_dump(sd_bus_message *m, FILE *f, bool with_header) {
 
         if (with_header) {
                 fprintf(f,
-                        "%s%s%sType=%s%s%s  Endian=%c  Flags=%u  Version=%u",
+                        "%s%s%sType=%s%s%s  Endian=%c  Flags=%u  Version=%u  Priority=%lli",
                         m->header->type == SD_BUS_MESSAGE_METHOD_ERROR ? ansi_highlight_red() :
                         m->header->type == SD_BUS_MESSAGE_METHOD_RETURN ? ansi_highlight_green() :
                         m->header->type != SD_BUS_MESSAGE_SIGNAL ? ansi_highlight() : "", draw_special_char(DRAW_TRIANGULAR_BULLET), ansi_highlight_off(),
                         ansi_highlight(), bus_message_type_to_string(m->header->type), ansi_highlight_off(),
                         m->header->endian,
                         m->header->flags,
-                        m->header->version);
+                        m->header->version,
+                        (long long) m->priority);
 
                 /* Display synthetic message serial number in a more readable
                  * format than (uint32_t) -1 */
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index f547ebf..77ad5ca 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -260,6 +260,7 @@ static int bus_message_setup_kmsg(sd_bus *b, sd_bus_message *m) {
                 m->destination ? unique : KDBUS_DST_ID_BROADCAST;
         m->kdbus->payload_type = KDBUS_PAYLOAD_DBUS;
         m->kdbus->cookie = m->header->serial;
+        m->kdbus->priority = m->priority;
 
         if (m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED)
                 m->kdbus->cookie_reply = m->reply_cookie;
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index 2c25b3f..b42c491 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -5548,3 +5548,19 @@ int bus_message_append_sender(sd_bus_message *m, const char *sender) {
 
         return message_append_field_string(m, BUS_MESSAGE_HEADER_SENDER, SD_BUS_TYPE_STRING, sender, &m->sender);
 }
+
+_public_ int sd_bus_message_get_priority(sd_bus_message *m, int64_t *priority) {
+        assert_return(m, -EINVAL);
+        assert_return(priority, -EINVAL);
+
+        *priority = m->priority;
+        return 0;
+}
+
+_public_ int sd_bus_message_set_priority(sd_bus_message *m, int64_t priority) {
+        assert_return(m, -EINVAL);
+        assert_return(!m->sealed, -EPERM);
+
+        m->priority = priority;
+        return 0;
+}
diff --git a/src/libsystemd/sd-bus/bus-message.h b/src/libsystemd/sd-bus/bus-message.h
index 0c90e72..5fbe3e6 100644
--- a/src/libsystemd/sd-bus/bus-message.h
+++ b/src/libsystemd/sd-bus/bus-message.h
@@ -99,6 +99,7 @@ struct sd_bus_message {
         usec_t monotonic;
         usec_t realtime;
         uint64_t seqnum;
+        int64_t priority;
 
         bool sealed:1;
         bool dont_send:1;
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index 9992888..6f9443a 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -193,6 +193,7 @@ int sd_bus_message_get_cookie(sd_bus_message *m, uint64_t *cookie);
 int sd_bus_message_get_reply_cookie(sd_bus_message *m, uint64_t *cookie);
 int sd_bus_message_get_no_reply(sd_bus_message *m);
 int sd_bus_message_get_no_auto_start(sd_bus_message *m);
+int sd_bus_message_get_priority(sd_bus_message *m, int64_t *priority);
 
 const char *sd_bus_message_get_signature(sd_bus_message *m, int complete);
 const char *sd_bus_message_get_path(sd_bus_message *m);
@@ -216,6 +217,7 @@ int sd_bus_message_is_method_error(sd_bus_message *m, const char *name);
 int sd_bus_message_set_no_reply(sd_bus_message *m, int b);
 int sd_bus_message_set_no_auto_start(sd_bus_message *m, int b);
 int sd_bus_message_set_destination(sd_bus_message *m, const char *destination);
+int sd_bus_message_set_priority(sd_bus_message *m, int64_t priority);
 
 int sd_bus_message_append(sd_bus_message *m, const char *types, ...);
 int sd_bus_message_append_basic(sd_bus_message *m, char type, const void *p);



More information about the systemd-commits mailing list