From: Francis Dupont Date: Wed, 24 Oct 2018 20:31:07 +0000 (+0200) Subject: [153-netconf-agent] Make netconf more robust X-Git-Tag: 176-update-to-sysrepo-0-7-6-release_base~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dea8b62b8cdd3ddce4e5942a239fe34aa28e5a26;p=thirdparty%2Fkea.git [153-netconf-agent] Make netconf more robust --- diff --git a/src/bin/netconf/netconf.cc b/src/bin/netconf/netconf.cc index e560384f39..c402da087f 100644 --- a/src/bin/netconf/netconf.cc +++ b/src/bin/netconf/netconf.cc @@ -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 = diff --git a/src/bin/netconf/netconf_process.cc b/src/bin/netconf/netconf_process.cc index 94b5362846..aa2e53c0fc 100644 --- a/src/bin/netconf/netconf_process.cc +++ b/src/bin/netconf/netconf_process.cc @@ -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.