don't emit unnecessary signals
Fix a number of places where DBus signals are emitted when they should
not be:
-Prior to claiming a well known DBus service name
-When using the map-of-properties sdbusplus interface constructor
On a system with ~175 inventory interfaces this eliminates 650
PropertiesChanged and ObjectManager signals on PIM startup.
Change-Id: I7b8fa6af69ca3553f5b2ea49e488a75a592a4d0b
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/gen_serialization.mako.hpp b/gen_serialization.mako.hpp
index f441670..bae2d33 100644
--- a/gen_serialization.mako.hpp
+++ b/gen_serialization.mako.hpp
@@ -16,6 +16,10 @@
CEREAL_CLASS_VERSION(${iface.namespace()}, CLASS_VERSION);
% endfor
+// Emitting signals prior to claiming a well known DBus service name causes
+// un-necessary DBus traffic and wakeups. De-serialization only happens prior
+// to claiming a well known name, so don't emit signals.
+static constexpr auto skipSignals = true;
namespace cereal
{
@@ -48,7 +52,7 @@
%>\
a(${props});
% for p in properties:
-<% t = "object." + p.camelCase + "(" + p.CamelCase + ")" %>\
+<% t = "object." + p.camelCase + "(" + p.CamelCase + ", skipSignals)" %>\
${t};
% endfor
}
diff --git a/manager.cpp b/manager.cpp
index 72a95d9..bcfb823 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -167,17 +167,21 @@
{
// Add the new interface.
auto& ctor = std::get<MakeInterfaceType>(opsit->second);
+ // skipSignal = true here to avoid getting PropertiesChanged
+ // signals while the interface is constructed. We'll emit an
+ // ObjectManager signal for this interface below.
refaceit = refaces.insert(
refaceit, std::make_pair(ifaceit->first,
ctor(_bus, path.str.c_str(),
- ifaceit->second, false)));
+ ifaceit->second, true)));
signals.push_back(ifaceit->first);
}
else
{
// Set the new property values.
auto& assign = std::get<AssignInterfaceType>(opsit->second);
- assign(ifaceit->second, refaceit->second, false);
+ assign(ifaceit->second, refaceit->second,
+ _status != ManagerStatus::RUNNING);
}
if (!restoreFromCache)
{
@@ -204,13 +208,16 @@
++ifaceit;
}
- if (newObject)
+ if (_status == ManagerStatus::RUNNING)
{
- _bus.emit_object_added(path.str.c_str());
- }
- else if (!signals.empty())
- {
- _bus.emit_interfaces_added(path.str.c_str(), signals);
+ if (newObject)
+ {
+ _bus.emit_object_added(path.str.c_str());
+ }
+ else if (!signals.empty())
+ {
+ _bus.emit_interfaces_added(path.str.c_str(), signals);
+ }
}
}
@@ -245,7 +252,8 @@
#ifdef CREATE_ASSOCIATIONS
if (newObj)
{
- _associations.createAssociations(absPath, false);
+ _associations.createAssociations(absPath,
+ state != ManagerStatus::RUNNING);
}
#endif
++objit;