]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[153-netconf-agent] Make netconf more robust
authorFrancis Dupont <fdupont@isc.org>
Wed, 24 Oct 2018 20:31:07 +0000 (22:31 +0200)
committerFrancis Dupont <fdupont@isc.org>
Tue, 30 Oct 2018 11:50:38 +0000 (07:50 -0400)
src/bin/netconf/netconf.cc
src/bin/netconf/netconf_process.cc

index e560384f39fb16872e67f88de53d92033b3b8eb5..c402da087f34d3ea2806860bc9376d1c32526360 100644 (file)
@@ -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 =
index 94b536284660cdfa881162454f1dc8b455c30cc4..aa2e53c0fc9a44eb41b914dd53504e9007beb591 100644 (file)
@@ -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.