chiark / gitweb /
bus: properly generate NameOwnerChanged messages when we take from/give back to queue...
authorLennart Poettering <lennart@poettering.net>
Thu, 12 Dec 2013 00:42:41 +0000 (01:42 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 12 Dec 2013 00:51:51 +0000 (01:51 +0100)
TODO
src/libsystemd-bus/bus-kernel.c
src/libsystemd-bus/kdbus.h

diff --git a/TODO b/TODO
index e60211a..7f56a26 100644 (file)
--- a/TODO
+++ b/TODO
@@ -127,7 +127,6 @@ Features:
   - kdbus: matches against source or destination pids for an "strace -p"-like feel. Problem: The PID info needs to be available in userspace too...
   - kdbus: we need a way to distuingish messages we got due to monitoring from normal messages, since we want to bind methods only to the latter
   - figure out what to do when fields in the kdbus header and in the payload header do not match
-  - nameownerchange cannot be properly synthesized since we cannot distuingish messages from kernel when a name changed ownership starter → real from real → starter
   - longer term:
     * priority queues
     * priority inheritance
index 92acbee..81dfba7 100644 (file)
@@ -514,17 +514,18 @@ static int translate_name_change(sd_bus *bus, struct kdbus_msg *k, struct kdbus_
         assert(k);
         assert(d);
 
-        if (d->name_change.flags & (KDBUS_NAME_IN_QUEUE|KDBUS_NAME_STARTER))
-                return 0;
-
-        if (d->type == KDBUS_ITEM_NAME_ADD)
+        if (d->type == KDBUS_ITEM_NAME_ADD || (d->name_change.old_flags & (KDBUS_NAME_IN_QUEUE|KDBUS_NAME_STARTER)))
                 old_owner[0] = 0;
         else
                 sprintf(old_owner, ":1.%llu", (unsigned long long) d->name_change.old_id);
 
-        if (d->type == KDBUS_ITEM_NAME_REMOVE)
+        if (d->type == KDBUS_ITEM_NAME_REMOVE || (d->name_change.new_flags & (KDBUS_NAME_IN_QUEUE|KDBUS_NAME_STARTER))) {
+
+                if (isempty(old_owner))
+                        return 0;
+
                 new_owner[0] = 0;
-        else
+        else
                 sprintf(new_owner, ":1.%llu", (unsigned long long) d->name_change.new_id);
 
         return push_name_owner_changed(bus, d->name_change.name, old_owner, new_owner);
index ccc65cb..168d08a 100644 (file)
@@ -30,7 +30,8 @@
  * struct kdbus_notify_name_change - name registry change message
  * @old_id:            Former owner of a name
  * @new_id:            New owner of a name
- * @flags:             flags from KDBUS_NAME_*
+ * @old_flags:         flags from KDBUS_NAME_* the name entry used to have
+ * @new_flags:         flags from KDBUS_NAME_* the name entry has now
  * @name:              Well-known name
  *
  * Sent from kernel to userspace when the owner or starter of
@@ -44,7 +45,8 @@
 struct kdbus_notify_name_change {
        __u64 old_id;
        __u64 new_id;
-       __u64 flags;
+       __u64 old_flags;
+       __u64 new_flags;
        char name[0];
 };