chiark / gitweb /
event: add ability to change fd of an active event source
[elogind.git] / src / libsystemd-bus / bus-kernel.c
index 92acbeec5eda9148dfbed97f17d9c80893e513f2..4b694804cbec99c30b7be0471503c2523f6744ca 100644 (file)
@@ -363,6 +363,7 @@ int bus_kernel_take_fd(sd_bus *b) {
         b->bus_client = true;
         b->can_fds = !!(hello.conn_flags & KDBUS_HELLO_ACCEPT_FD);
         b->message_version = 2;
+        b->message_endian = BUS_NATIVE_ENDIAN;
 
         /* the kernel told us the UUID of the underlying bus */
         memcpy(b->server_id.bytes, hello.id128, sizeof(b->server_id.bytes));
@@ -514,17 +515,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_ACTIVATOR)))
                 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_ACTIVATOR))) {
+
+                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);
@@ -1019,7 +1021,7 @@ int kdbus_translate_request_name_flags(uint64_t flags, uint64_t *kdbus_flags) {
         if (flags & SD_BUS_NAME_REPLACE_EXISTING)
                 f |= KDBUS_NAME_REPLACE_EXISTING;
 
-        if (!(flags & SD_BUS_NAME_DO_NOT_QUEUE))
+        if (flags & SD_BUS_NAME_QUEUE)
                 f |= KDBUS_NAME_QUEUE;
 
         *kdbus_flags = f;
@@ -1138,10 +1140,10 @@ int bus_kernel_create_starter(const char *bus, const char *name) {
         n = hello->items;
         strcpy(n->str, name);
         n->size = offsetof(struct kdbus_item, str) + strlen(n->str) + 1;
-        n->type = KDBUS_ITEM_STARTER_NAME;
+        n->type = KDBUS_ITEM_ACTIVATOR_NAME;
 
         hello->size = ALIGN8(offsetof(struct kdbus_cmd_hello, items) + n->size);
-        hello->conn_flags = KDBUS_HELLO_STARTER;
+        hello->conn_flags = KDBUS_HELLO_ACTIVATOR;
         hello->pool_size = KDBUS_POOL_SIZE;
 
         if (ioctl(fd, KDBUS_CMD_HELLO, hello) < 0) {