chiark / gitweb /
bus: reenable id change subscriptions
[elogind.git] / src / libsystemd-bus / bus-control.c
index b51007d1e23b2f6eb7bff0b5e62ca1889c393a39..dc7237a532da7766f1810e91c84443a0d13e060f 100644 (file)
@@ -775,12 +775,12 @@ static int add_name_change_match(sd_bus *bus,
                  * name, then add KDBUS_MATCH_NAME_{ADD,REMOVE,CHANGE}
                  * matches for it */
 
-                l = name ? strlen(name) : 0;
+                l = name ? strlen(name) + 1 : 0;
 
                 sz = ALIGN8(offsetof(struct kdbus_cmd_match, items) +
                             offsetof(struct kdbus_item, name_change) +
                             offsetof(struct kdbus_notify_name_change, name) +
-                            l+1);
+                            l);
 
                 m = alloca0(sz);
                 m->size = sz;
@@ -791,7 +791,7 @@ static int add_name_change_match(sd_bus *bus,
                 item->size =
                         offsetof(struct kdbus_item, name_change) +
                         offsetof(struct kdbus_notify_name_change, name) +
-                        l+1;
+                        l;
 
                 item->name_change.old.id = old_owner_id;
                 item->name_change.new.id = new_owner_id;
@@ -877,9 +877,9 @@ static int add_name_change_match(sd_bus *bus,
         return 0;
 }
 
-static int bus_add_match_internal_kernel(
+int bus_add_match_internal_kernel(
                 sd_bus *bus,
-                const char *match,
+                uint64_t id,
                 struct bus_match_component *components,
                 unsigned n_components,
                 uint64_t cookie) {
@@ -898,7 +898,6 @@ static int bus_add_match_internal_kernel(
         int r;
 
         assert(bus);
-        assert(match);
 
         zero(bloom);
 
@@ -1018,6 +1017,7 @@ static int bus_add_match_internal_kernel(
         m->size = sz;
         m->cookie = cookie;
         m->src_id = src_id;
+        m->id = id;
 
         item = m->items;
 
@@ -1084,25 +1084,25 @@ int bus_add_match_internal(
         assert(match);
 
         if (bus->is_kernel)
-                return bus_add_match_internal_kernel(bus, match, components, n_components, cookie);
+                return bus_add_match_internal_kernel(bus, 0, components, n_components, cookie);
         else
                 return bus_add_match_internal_dbus1(bus, match);
 }
 
-static int bus_remove_match_internal_kernel(
+int bus_remove_match_internal_kernel(
                 sd_bus *bus,
-                const char *match,
+                uint64_t id,
                 uint64_t cookie) {
 
         struct kdbus_cmd_match m;
         int r;
 
         assert(bus);
-        assert(match);
 
         zero(m);
         m.size = offsetof(struct kdbus_cmd_match, items);
         m.cookie = cookie;
+        m.id = id;
 
         r = ioctl(bus->input_fd, KDBUS_CMD_MATCH_REMOVE, &m);
         if (r < 0)
@@ -1139,7 +1139,7 @@ int bus_remove_match_internal(
         assert(match);
 
         if (bus->is_kernel)
-                return bus_remove_match_internal_kernel(bus, match, cookie);
+                return bus_remove_match_internal_kernel(bus, 0, cookie);
         else
                 return bus_remove_match_internal_dbus1(bus, match);
 }