treewide: Cleanup signal emission
Don't emit properties changed prior to interfaces added.
Change-Id: I7f88b8052a323ca49ce9f16fe446596213e3fdb5
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/dhcp_configuration.cpp b/src/dhcp_configuration.cpp
index d421111..154bbee 100644
--- a/src/dhcp_configuration.cpp
+++ b/src/dhcp_configuration.cpp
@@ -49,10 +49,10 @@
conf.setFile(newest_file.path());
}
- ConfigIntf::dnsEnabled(getDHCPProp(conf, "UseDNS"));
- ConfigIntf::ntpEnabled(getDHCPProp(conf, "UseNTP"));
- ConfigIntf::hostNameEnabled(getDHCPProp(conf, "UseHostname"));
- ConfigIntf::sendHostNameEnabled(getDHCPProp(conf, "SendHostname"));
+ ConfigIntf::dnsEnabled(getDHCPProp(conf, "UseDNS"), true);
+ ConfigIntf::ntpEnabled(getDHCPProp(conf, "UseNTP"), true);
+ ConfigIntf::hostNameEnabled(getDHCPProp(conf, "UseHostname"), true);
+ ConfigIntf::sendHostNameEnabled(getDHCPProp(conf, "SendHostname"), true);
emit_object_added();
}
diff --git a/src/ethernet_interface.cpp b/src/ethernet_interface.cpp
index e3e7662..b57a24f 100644
--- a/src/ethernet_interface.cpp
+++ b/src/ethernet_interface.cpp
@@ -88,17 +88,27 @@
manager(manager), bus(bus), objPath(std::move(objPath)),
ifIdx(info.intf.idx)
{
- interfaceName(*info.intf.name);
+ interfaceName(*info.intf.name, true);
auto dhcpVal = getDHCPValue(config);
- EthernetInterfaceIntf::dhcp4(dhcpVal.v4);
- EthernetInterfaceIntf::dhcp6(dhcpVal.v6);
- EthernetInterfaceIntf::ipv6AcceptRA(getIPv6AcceptRA(config));
- EthernetInterfaceIntf::nicEnabled(enabled);
+ EthernetInterfaceIntf::dhcp4(dhcpVal.v4, true);
+ EthernetInterfaceIntf::dhcp6(dhcpVal.v6, true);
+ EthernetInterfaceIntf::ipv6AcceptRA(getIPv6AcceptRA(config), true);
+ EthernetInterfaceIntf::nicEnabled(enabled, true);
EthernetInterfaceIntf::ntpServers(
- config.map.getValueStrings("Network", "NTP"));
+ config.map.getValueStrings("Network", "NTP"), true);
- updateInfo(info.intf);
+ updateInfo(info.intf, true);
+
+ if (info.defgw4)
+ {
+ EthernetInterface::defaultGateway(std::to_string(*info.defgw4), true);
+ }
+ if (info.defgw6)
+ {
+ EthernetInterface::defaultGateway6(std::to_string(*info.defgw6), true);
+ }
+ emit_object_added();
if (info.intf.vlan_id)
{
@@ -108,14 +118,6 @@
}
vlan.emplace(bus, this->objPath.c_str(), info.intf, *this);
}
- if (info.defgw4)
- {
- EthernetInterface::defaultGateway(std::to_string(*info.defgw4));
- }
- if (info.defgw6)
- {
- EthernetInterface::defaultGateway6(std::to_string(*info.defgw6));
- }
for (const auto& [_, addr] : info.addrs)
{
addAddr(addr);
@@ -124,28 +126,26 @@
{
addStaticNeigh(neigh);
}
-
- this->emit_object_added();
}
-void EthernetInterface::updateInfo(const InterfaceInfo& info)
+void EthernetInterface::updateInfo(const InterfaceInfo& info, bool skipSignal)
{
- EthernetInterfaceIntf::linkUp(info.flags & IFF_RUNNING);
+ EthernetInterfaceIntf::linkUp(info.flags & IFF_RUNNING, skipSignal);
if (info.mac)
{
- MacAddressIntf::macAddress(std::to_string(*info.mac));
+ MacAddressIntf::macAddress(std::to_string(*info.mac), skipSignal);
}
if (info.mtu)
{
- EthernetInterfaceIntf::mtu(*info.mtu);
+ EthernetInterfaceIntf::mtu(*info.mtu, skipSignal);
}
if (ifIdx > 0)
{
auto ethInfo = ignoreError("GetEthInfo", *info.name, {}, [&] {
return system::getEthInfo(*info.name);
});
- EthernetInterfaceIntf::autoNeg(ethInfo.autoneg);
- EthernetInterfaceIntf::speed(ethInfo.speed);
+ EthernetInterfaceIntf::autoNeg(ethInfo.autoneg, skipSignal);
+ EthernetInterfaceIntf::speed(ethInfo.speed, skipSignal);
}
}
@@ -874,8 +874,8 @@
VlanIfaces(bus, objPath.c_str(), VlanIfaces::action::defer_emit),
parentIdx(*info.parent_idx), eth(eth)
{
- VlanIntf::id(*info.vlan_id);
- this->emit_object_added();
+ VlanIntf::id(*info.vlan_id, true);
+ emit_object_added();
}
void EthernetInterface::VlanProperties::delete_()
diff --git a/src/ethernet_interface.hpp b/src/ethernet_interface.hpp
index e617eae..a1e9975 100644
--- a/src/ethernet_interface.hpp
+++ b/src/ethernet_interface.hpp
@@ -96,7 +96,7 @@
void addStaticNeigh(const NeighborInfo& info);
/** @brief Updates the interface information based on new InterfaceInfo */
- void updateInfo(const InterfaceInfo& info);
+ void updateInfo(const InterfaceInfo& info, bool skipSignal = false);
/** @brief Function used to load the ntpservers
*/
diff --git a/src/ipaddress.cpp b/src/ipaddress.cpp
index 560129d..07e37e4 100644
--- a/src/ipaddress.cpp
+++ b/src/ipaddress.cpp
@@ -59,13 +59,12 @@
IPIfaces(bus, objPath.str.c_str(), IPIfaces::action::defer_emit),
parent(parent), objPath(std::move(objPath))
{
- IP::address(std::to_string(addr.getAddr()));
- IP::prefixLength(addr.getPfx());
+ IP::address(std::to_string(addr.getAddr()), true);
+ IP::prefixLength(addr.getPfx(), true);
IP::type(std::visit([](auto v) { return Proto<decltype(v)>::value; },
- addr.getAddr()));
- IP::origin(origin);
-
- // Emit deferred signal.
+ addr.getAddr()),
+ true);
+ IP::origin(origin, true);
emit_object_added();
}
std::string IPAddress::address(std::string /*ipAddress*/)
diff --git a/src/neighbor.cpp b/src/neighbor.cpp
index 0f5140e..6b8d853 100644
--- a/src/neighbor.cpp
+++ b/src/neighbor.cpp
@@ -34,11 +34,9 @@
NeighborObj(bus, objPath.str.c_str(), NeighborObj::action::defer_emit),
parent(parent), objPath(std::move(objPath))
{
- NeighborObj::ipAddress(std::to_string(addr));
- NeighborObj::macAddress(std::to_string(lladdr));
- NeighborObj::state(state);
-
- // Emit deferred signal.
+ NeighborObj::ipAddress(std::to_string(addr), true);
+ NeighborObj::macAddress(std::to_string(lladdr), true);
+ NeighborObj::state(state, true);
emit_object_added();
}
diff --git a/src/system_configuration.cpp b/src/system_configuration.cpp
index 192f12d..0ba4d82 100644
--- a/src/system_configuration.cpp
+++ b/src/system_configuration.cpp
@@ -28,9 +28,9 @@
Iface(bus, objPath.c_str(), Iface::action::defer_emit),
bus(bus)
{
- SystemConfigIntf::hostName(getHostNameFromSystem());
+ SystemConfigIntf::hostName(getHostNameFromSystem(), true);
- this->emit_object_added();
+ emit_object_added();
}
std::string SystemConfiguration::hostName(std::string name)