|
| 1 | +# SPDX-License-Identifier: LGPL-2.1-or-later |
| 2 | +# SPDX-FileCopyrightText: 2025 Arkadiusz Bokowy <[email protected]> |
| 3 | +From 998aa62a21c69b34700f6cbbeb540beddffa9c89 Mon Sep 17 00:00:00 2001 |
| 4 | +From: Arkadiusz Bokowy < [email protected]> |
| 5 | +Date: Thu, 12 Jun 2025 16:20:29 +0200 |
| 6 | +Subject: [PATCH] sd-bus: Preserve interfaces addition order |
| 7 | + |
| 8 | +When adding a new interface to the object add it at the end of the list. |
| 9 | +This way, when iterating over the list, e.g., during handling introspect |
| 10 | +call, the order of returned interfaces will mach the order in which they |
| 11 | +were added. |
| 12 | +--- |
| 13 | + src/libsystemd/sd-bus/bus-objects.c | 3 +++ |
| 14 | + test/units/TEST-23-UNIT-FILE.oneshot-restart.sh | 2 +- |
| 15 | + 2 files changed, 4 insertions(+), 1 deletion(-) |
| 16 | + |
| 17 | +diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c |
| 18 | +index 7309ad621a0a7..cc1ef226f0cdd 100644 |
| 19 | +--- a/src/libsystemd/sd-bus/bus-objects.c |
| 20 | ++++ b/src/libsystemd/sd-bus/bus-objects.c |
| 21 | +@@ -1973,6 +1973,9 @@ static int add_object_vtable_internal( |
| 22 | + } |
| 23 | + } |
| 24 | + |
| 25 | ++ if (!existing) |
| 26 | ++ existing = LIST_FIND_TAIL(vtables, n->vtables); |
| 27 | ++ |
| 28 | + s->node_vtable.node = n; |
| 29 | + LIST_INSERT_AFTER(vtables, n->vtables, existing, &s->node_vtable); |
| 30 | + bus->nodes_modified = true; |
0 commit comments