sdbusplus: Provide option to skip signal property
InterfacesAdded signal itself will send out all propety
details and it's values during start-up of a D-Bus daemon service.
Sending properties changed signal confuses the signal handler
as it can't differentiate between service restart or real
property change event. Exposing a way to skip sending
properties changed signal during initialize (to avoid
breaking any old one).
Tested-by:
1. Verified that when initialize(true) is called, properties
changed signal are not sent out from D-Bus daemon
2. Still old method works fine.
Change-Id: Ib436ea9313b08623d931c58b11a770081511ab72
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
diff --git a/sdbusplus/asio/object_server.hpp b/sdbusplus/asio/object_server.hpp
index 0026530..fda791b 100644
--- a/sdbusplus/asio/object_server.hpp
+++ b/sdbusplus/asio/object_server.hpp
@@ -674,7 +674,7 @@
return sd_bus_error_set_const(error, SD_BUS_ERROR_INVALID_ARGS, NULL);
}
- bool initialize()
+ bool initialize(const bool skipPropertyChangedSignal = false)
{
// can only register once
if (initialized_)
@@ -690,9 +690,12 @@
this);
conn_->emit_interfaces_added(path_.c_str(),
std::vector<std::string>{name_});
- for (const std::string& name : propertyNames_)
+ if (!skipPropertyChangedSignal)
{
- signal_property(name);
+ for (const std::string& name : propertyNames_)
+ {
+ signal_property(name);
+ }
}
return true;
}