Commit dea8b62b authored by Francis Dupont's avatar Francis Dupont

[153-netconf-agent] Make netconf more robust

parent 14a9deda
......@@ -106,7 +106,7 @@ NetconfAgent::~NetconfAgent() {
void
NetconfAgent::init(NetconfCfgMgrPtr cfg_mgr) {
if (NetconfProcess::global_shut_down_flag) {
if (NetconfProcess::global_shut_down_flag || !cfg_mgr) {
return;
}
const CfgServersMapPtr& servers =
......
......@@ -47,10 +47,18 @@ NetconfProcess::run() {
try {
// Initialize sysrepo.
agent_.initSysrepo();
if (!shouldShutdown()) {
agent_.initSysrepo();
}
// Initialize netconf agent in a thread.
Thread th([this]() { agent_.init(getNetconfCfgMgr()); });
NetconfCfgMgrPtr cfg_mgr;
if (!shouldShutdown()) {
cfg_mgr = getNetconfCfgMgr();
}
// Initialize the agent in a thread.
Thread th([cfg_mgr]() { 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