sd-bus: Preserve interfaces addition order

When adding a new interface to the object add it at the end of the list.
This way, when iterating over the list, e.g., during handling introspect
call, the order of returned interfaces will mach the order in which they
were added.
This commit is contained in:
Arkadiusz Bokowy
2025-06-12 16:20:29 +02:00
committed by Yu Watanabe
parent 2db991dc35
commit 998aa62a21
2 changed files with 4 additions and 1 deletions

View File

@@ -1973,6 +1973,9 @@ static int add_object_vtable_internal(
}
}
if (!existing)
existing = LIST_FIND_TAIL(vtables, n->vtables);
s->node_vtable.node = n;
LIST_INSERT_AFTER(vtables, n->vtables, existing, &s->node_vtable);
bus->nodes_modified = true;

View File

@@ -90,9 +90,9 @@ read -r x <"$FIFO_FILE"
assert_eq "$x" "finished"
cmp -b <(systemctl show "$UNIT_NAME" -p Result -p NRestarts -p SubState) <<EOF
SubState=dead
Result=success
NRestarts=1
SubState=dead
EOF
systemctl disable "$UNIT_NAME"