[systemd-commits] 2 commits - src/libsystemd

David Herrmann dvdhrm at kemper.freedesktop.org
Tue Feb 17 09:16:18 PST 2015


 src/libsystemd/sd-bus/bus-kernel.c         |    7 ++-----
 src/libsystemd/sd-bus/kdbus.h              |   16 ++++++++++++----
 src/libsystemd/sd-bus/test-bus-kernel.c    |    2 +-
 src/libsystemd/sd-bus/test-bus-zero-copy.c |    6 +++++-
 4 files changed, 20 insertions(+), 11 deletions(-)

New commits:
commit 83e30358f2775b581a5501d14873e409285275f5
Author: David Herrmann <dh.herrmann at gmail.com>
Date:   Tue Feb 17 18:05:32 2015 +0100

    bus: sync with kdbus
    
    Pull in new kdbus changes, namely:
     - EOVERFLOW is replaces by KDBUS_RECV_RETURN_DROPPED_MSGS
     - ENOMSG is merged with EAGAIN for consistency

diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index e90ee44..df77203 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -1345,15 +1345,12 @@ int bus_kernel_read_message(sd_bus *bus, bool hint_priority, int64_t priority) {
         }
 
         r = ioctl(bus->input_fd, KDBUS_CMD_RECV, &recv);
+        if (recv.return_flags & KDBUS_RECV_RETURN_DROPPED_MSGS)
+                log_debug("%s: kdbus reports %" PRIu64 " dropped broadcast messages, ignoring.", strna(bus->description), (uint64_t) recv.dropped_msgs);
         if (r < 0) {
                 if (errno == EAGAIN)
                         return 0;
 
-                if (errno == EOVERFLOW) {
-                        log_debug("%s: kdbus reports %" PRIu64 " dropped broadcast messages, ignoring.", strna(bus->description), (uint64_t) recv.dropped_msgs);
-                        return 0;
-                }
-
                 return -errno;
         }
 
diff --git a/src/libsystemd/sd-bus/kdbus.h b/src/libsystemd/sd-bus/kdbus.h
index 1cc475e..f7fbfd9 100644
--- a/src/libsystemd/sd-bus/kdbus.h
+++ b/src/libsystemd/sd-bus/kdbus.h
@@ -602,9 +602,15 @@ enum kdbus_recv_flags {
  * @KDBUS_RECV_RETURN_INCOMPLETE_FDS:	One or more file descriptors could not
  *					be installed. These descriptors in
  *					KDBUS_ITEM_FDS will carry the value -1.
+ * @KDBUS_RECV_RETURN_DROPPED_MSGS:	There have been dropped messages since
+ *					the last time a message was received.
+ *					The 'dropped_msgs' counter contains the
+ *					number of messages dropped pool
+ *					overflows or other missed broadcasts.
  */
 enum kdbus_recv_return_flags {
 	KDBUS_RECV_RETURN_INCOMPLETE_FDS	= 1ULL <<  0,
+	KDBUS_RECV_RETURN_DROPPED_MSGS		= 1ULL <<  1,
 };
 
 /**
@@ -614,10 +620,12 @@ enum kdbus_recv_return_flags {
  * @return_flags:	Command return flags, kernel → userspace
  * @priority:		Minimum priority of the messages to de-queue. Lowest
  *			values have the highest priority.
- * @dropped_msgs:	In case the KDBUS_CMD_RECV ioctl returns
- *			-EOVERFLOW, this field will contain the number of
- *			broadcast messages that have been lost since the
- *			last call.
+ * @dropped_msgs:	In case there were any dropped messages since the last
+ *			time a message was received, this will be set to the
+ *			number of lost messages and
+ *			KDBUS_RECV_RETURN_DROPPED_MSGS will be set in
+ *			'return_flags'. This can only happen if the ioctl
+ *			returns 0 or EAGAIN.
  * @msg:		Return storage for received message.
  * @items:		Additional items for this command.
  *
diff --git a/src/libsystemd/sd-bus/test-bus-kernel.c b/src/libsystemd/sd-bus/test-bus-kernel.c
index 3aec568..c396eac 100644
--- a/src/libsystemd/sd-bus/test-bus-kernel.c
+++ b/src/libsystemd/sd-bus/test-bus-kernel.c
@@ -119,7 +119,7 @@ int main(int argc, char *argv[]) {
         assert_se(r == -EBUSY);
 
         r = sd_bus_process_priority(b, -10, &m);
-        assert_se(r == -ENOMSG);
+        assert_se(r == 0);
 
         r = sd_bus_process(b, &m);
         assert_se(r > 0);

commit 4d2b1e0a3f98d8cf93beb943b05868b55231006a
Author: David Herrmann <dh.herrmann at gmail.com>
Date:   Tue Feb 17 18:03:50 2015 +0100

    bus: don't rely on static IDs in tests
    
    We should never put any constraints on the IDs returned by the kernel. Use
    sd_bus_get_unique_name() to retrieve the ID of a peer.

diff --git a/src/libsystemd/sd-bus/test-bus-zero-copy.c b/src/libsystemd/sd-bus/test-bus-zero-copy.c
index a054f74..4ea9f9f 100644
--- a/src/libsystemd/sd-bus/test-bus-zero-copy.c
+++ b/src/libsystemd/sd-bus/test-bus-zero-copy.c
@@ -39,6 +39,7 @@
 
 int main(int argc, char *argv[]) {
         _cleanup_free_ char *name = NULL, *bus_name = NULL, *address = NULL;
+        const char *unique;
         uint8_t *p;
         sd_bus *a, *b;
         int r, bus_ref;
@@ -81,7 +82,10 @@ int main(int argc, char *argv[]) {
         r = sd_bus_start(b);
         assert_se(r >= 0);
 
-        r = sd_bus_message_new_method_call(b, &m, ":1.1", "/a/path", "an.inter.face", "AMethod");
+        r = sd_bus_get_unique_name(a, &unique);
+        assert_se(r >= 0);
+
+        r = sd_bus_message_new_method_call(b, &m, unique, "/a/path", "an.inter.face", "AMethod");
         assert_se(r >= 0);
 
         r = sd_bus_message_open_container(m, 'r', "aysay");



More information about the systemd-commits mailing list