From: Arkadiusz Bokowy Date: Thu, 12 Jun 2025 14:20:29 +0000 (+0200) Subject: sd-bus: Preserve interfaces addition order X-Git-Tag: v258-rc1~306 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=998aa62a21c69b34700f6cbbeb540beddffa9c89;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c index 7309ad621a0..cc1ef226f0c 100644 --- a/src/libsystemd/sd-bus/bus-objects.c +++ b/src/libsystemd/sd-bus/bus-objects.c @@ -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; diff --git a/test/units/TEST-23-UNIT-FILE.oneshot-restart.sh b/test/units/TEST-23-UNIT-FILE.oneshot-restart.sh index d06dbaae8cf..b5a4d2d30a7 100755 --- a/test/units/TEST-23-UNIT-FILE.oneshot-restart.sh +++ b/test/units/TEST-23-UNIT-FILE.oneshot-restart.sh @@ -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) <