Commit 0c7dca54 authored by Francis Dupont's avatar Francis Dupont

[153-netconf-agent] Revamp the init thread

parent eff4bbda
......@@ -53,7 +53,10 @@ public:
/// Load Kea server configurations from YANG datastore.
/// Subscribe changes in YANG datastore.
///
/// @param cfg_mgr The configuration manager.
/// If @c NetconfProcess::global_shut_down_flag becomes true
/// returns as soon as possible.
///
/// @param cfg_mgr The configuration manager (can be null).
void init(NetconfCfgMgrPtr cfg_mgr);
/// @brief Clear.
......
......@@ -46,19 +46,28 @@ NetconfProcess::run() {
LOG_INFO(netconf_logger, NETCONF_STARTED).arg(VERSION);
try {
// Initialize sysrepo.
if (!shouldShutdown()) {
agent_.initSysrepo();
}
// Initialize netconf agent in a thread.
NetconfCfgMgrPtr cfg_mgr;
if (!shouldShutdown()) {
cfg_mgr = getNetconfCfgMgr();
}
// Initialize the agent in a thread.
Thread th([this, cfg_mgr]() { agent_.init(cfg_mgr); });
Thread th([this]() {
if (shouldShutdown()) {
return;
}
// Initialize sysrepo.
agent_.initSysrepo();
if (shouldShutdown()) {
return;
}
// Get the configuration manager.
NetconfCfgMgrPtr cfg_mgr;
if (shouldShutdown()) {
return;
} else {
cfg_mgr = getNetconfCfgMgr();
}
// Call init.
agent_.init(cfg_mgr);
});
// Let's process incoming data or expiring timers in a loop until
// shutdown condition is detected.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment