chiark / gitweb /
bus: when closing a bus, drop all refs to queued messages, so that the bus can be...
[elogind.git] / src / libsystemd-bus / bus-kernel.c
index ad0d5731490d2fef760be1f4e89d46dca05af079..da9474dc51e51cd04cf0065bbd98070dd1e8e185 100644 (file)
@@ -485,7 +485,7 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k, sd_bus_mess
         if (n_bytes != total)
                 return -EBADMSG;
 
-        r = bus_message_from_header(h, sizeof(struct bus_header), fds, n_fds, NULL, seclabel, 0, &m);
+        r = bus_message_from_header(bus, h, sizeof(struct bus_header), fds, n_fds, NULL, seclabel, 0, &m);
         if (r < 0)
                 return r;
 
@@ -603,7 +603,6 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k, sd_bus_mess
 
         /* We take possession of the kmsg struct now */
         m->kdbus = k;
-        m->bus = sd_bus_ref(bus);
         m->release_kdbus = true;
         m->free_fds = true;
 
@@ -654,7 +653,7 @@ int bus_kernel_read_message(sd_bus *bus, sd_bus_message **m) {
 
 int bus_kernel_create(const char *name, char **s) {
         struct kdbus_cmd_bus_make *make;
-        struct kdbus_item *n, *cg;
+        struct kdbus_item *n;
         size_t l;
         int fd;
         char *p;
@@ -671,17 +670,12 @@ int bus_kernel_create(const char *name, char **s) {
                        KDBUS_ITEM_HEADER_SIZE + sizeof(uint64_t) +
                        KDBUS_ITEM_HEADER_SIZE + DECIMAL_STR_MAX(uid_t) + 1 + l + 1);
 
-        cg = make->items;
-        cg->type = KDBUS_MAKE_CGROUP;
-        cg->data64[0] = 1;
-        cg->size = KDBUS_ITEM_HEADER_SIZE + sizeof(uint64_t);
-
-        n = KDBUS_ITEM_NEXT(cg);
+        n = make->items;
         n->type = KDBUS_MAKE_NAME;
         sprintf(n->str, "%lu-%s", (unsigned long) getuid(), name);
         n->size = KDBUS_ITEM_HEADER_SIZE + strlen(n->str) + 1;
 
-        make->size = offsetof(struct kdbus_cmd_bus_make, items) + cg->size + n->size;
+        make->size = offsetof(struct kdbus_cmd_bus_make, items) + n->size;
         make->flags = KDBUS_MAKE_POLICY_OPEN;
         make->bus_flags = 0;
         make->bloom_size = BLOOM_SIZE;
@@ -729,7 +723,7 @@ int bus_kernel_pop_memfd(sd_bus *bus, void **address, size_t *size) {
                 return fd;
         }
 
-        c = &bus->memfd_cache[-- bus->n_memfd_cache];
+        c = &bus->memfd_cache[--bus->n_memfd_cache];
 
         assert(c->fd >= 0);
         assert(c->size == 0 || c->address);