Recreate the network objects once the timer expires
As we get multiple network change events once systemd-
networkd starts,This commit starts the timer once it
gets the network change event and refresh the network
objects once the timer expires.
Change-Id: I86d1547763d03f527a8bdb04e2b2780f6cd6fdc2
Signed-off-by: Ratan Gupta <ratagupt@in.ibm.com>
diff --git a/network_manager_main.cpp b/network_manager_main.cpp
index 993efc7..7fa3b05 100644
--- a/network_manager_main.cpp
+++ b/network_manager_main.cpp
@@ -1,5 +1,7 @@
+#include "config.h"
#include "network_manager.hpp"
#include "rtnetlink_server.hpp"
+#include "timer.hpp"
#include <memory>
@@ -13,6 +15,12 @@
{
std::unique_ptr<phosphor::network::Manager> manager = nullptr;
+std::unique_ptr<phosphor::network::Timer> refreshTimer = nullptr;
+
+void refreshObjects()
+{
+ manager->createChildObjects();
+}
} //namespace network
} //namespace phosphor
@@ -21,6 +29,12 @@
{
using namespace phosphor::logging;
+ std::function<void()> func(
+ std::bind(&phosphor::network::refreshObjects));
+
+ phosphor::network::refreshTimer =
+ std::make_unique<phosphor::network::Timer>(func);
+
auto bus = sdbusplus::bus::new_default();
// Need sd_event to watch for OCC device errors
@@ -51,6 +65,6 @@
phosphor::network::manager->createChildObjects();
-
return svr.run();
}
+