]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-bus: Preserve interfaces addition order
authorArkadiusz Bokowy <arkadiusz.bokowy@gmail.com>
Thu, 12 Jun 2025 14:20:29 +0000 (16:20 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 17 Jun 2025 08:28:35 +0000 (17:28 +0900)
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.

src/libsystemd/sd-bus/bus-objects.c
test/units/TEST-23-UNIT-FILE.oneshot-restart.sh

index 7309ad621a0a7a48d119fc28d53fad711c001d8a..cc1ef226f0cdd7467f5b65e49637eabef5b886e6 100644 (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;
index d06dbaae8cfce32885638d5fccc205bd9de3d807..b5a4d2d30a7c565395d969b01eabf75287cb1c5d 100755 (executable)
@@ -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"