add Associations endpoints change delay timer
When multiple associations that point to the same interface are
created, each change (adding or removing one) leads to updating
"endpoints" property on dbus. This property update is time consuming
with many endpoints already present, because each update needs to send
the whole list of current elements plus/minus one. With a lot of
changes in short time it can cause the service to be unresponsive.
This change adds timer to delay updating dbus property. This way many
associations updates can be aggregated into single dbus property
update.
Tested: Ran on hardware with dbus sensor tester. 4000 created sensors
with interfaces are processed within 10 seconds. Time before the change
was above 2 minutes.
Signed-off-by: Kallas, Pawel <pawel.kallas@intel.com>
Change-Id: I1083c027ab12238249cffc67fb29a8ffef6baf83
diff --git a/src/processing.cpp b/src/processing.cpp
index 5590d16..4298541 100644
--- a/src/processing.cpp
+++ b/src/processing.cpp
@@ -40,6 +40,7 @@
}
void processNameChangeDelete(
+ boost::asio::io_context& io,
boost::container::flat_map<std::string, std::string>& nameOwners,
const std::string& wellKnown, const std::string& oldOwner,
InterfaceMapType& interfaceMap, AssociationMaps& assocMaps,
@@ -67,7 +68,8 @@
assocDefsInterface);
if (assoc != ifaces->second.end())
{
- removeAssociation(pathIt->first, wellKnown, server, assocMaps);
+ removeAssociation(io, pathIt->first, wellKnown, server,
+ assocMaps);
}
// Instead of checking if every single path is the endpoint of an
@@ -80,7 +82,7 @@
{
// Remove the 2 association D-Bus paths and move the
// association to pending.
- moveAssociationToPending(pathIt->first, assocMaps, server);
+ moveAssociationToPending(io, pathIt->first, assocMaps, server);
}
}
pathIt->second.erase(wellKnown);
@@ -95,7 +97,8 @@
}
}
-void processInterfaceAdded(InterfaceMapType& interfaceMap,
+void processInterfaceAdded(boost::asio::io_context& io,
+ InterfaceMapType& interfaceMap,
const sdbusplus::message::object_path& objPath,
const InterfacesAdded& intfAdded,
const std::string& wellKnown,
@@ -127,7 +130,7 @@
}
std::vector<Association> associations =
std::get<std::vector<Association>>(*variantAssociations);
- associationChanged(server, associations, objPath.str, wellKnown,
+ associationChanged(io, server, associations, objPath.str, wellKnown,
interfaceMap, assocMaps);
}
}
@@ -174,5 +177,5 @@
}
// The new interface might have an association pending
- checkIfPendingAssociation(objPath.str, interfaceMap, assocMaps, server);
+ checkIfPendingAssociation(io, objPath.str, interfaceMap, assocMaps, server);
}