mapper: Delete unecessary parent paths on removes
When any application creates a path on D-Bus, D-Bus will
automatically create all of the parent paths if they
don't already exist with 3 interfaces -
org.freedesktop.DBus.Peer, Introspectable, and Properties.
The mapper knows about those from either an introspection
or from explictly adding them during an interfacesAdded
signal, so now it also has to delete them out of the mapper
on an interfacesRemoved signal for the path being removed.
To do this, when a path is removed, it will traverse all of its
parents and check for the case of where a parent path only has
3 interfaces on it with the same owner, and there are no other
children remaining with that owner.
For example, if /A/B/C/D/E on owner X.Y is received in the
interfacesRemoved handler, then after /A/B/C/D/E is removed
from the interfaces map it will now check to see if /A/B/C/D
is such that:
* /A/B/C/D on owner X.Y has exactly 3 interfaces
* There is no remaining path on X.Y that starts with /A/B/C/D/.
If those are met, then /A/B/C/D on path X.Y will be removed from
the interfaces map, and then the next parent /A/B/C will be checked.
As soon as a parent doesn't need to be removed, the searching
will stop.
Tested: Check that these 3 interface paths that had been created
are properly deleted, such as
/xyz/openbmc_project/logging/entry when the last error
log is removed.
Change-Id: Ia9b79e6905108a76ddd6b425c22104bd77aedb24
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
1 file changed