]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[153-netconf-agent] Revamp the init thread
authorFrancis Dupont <fdupont@isc.org>
Thu, 25 Oct 2018 21:54:04 +0000 (23:54 +0200)
committerFrancis Dupont <fdupont@isc.org>
Tue, 30 Oct 2018 11:50:38 +0000 (07:50 -0400)
src/bin/netconf/netconf.h
src/bin/netconf/netconf_process.cc

index 7142d5aad51e292f533bf4e20230b66b4bdb1547..c8d58d73824543f068181942e5f98a3be29f9481 100644 (file)
@@ -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.
index c242f2ded6b01c4160343221dd37333c0db6365c..9cef1999098028fe342e74027b87bbcb398d4640 100644 (file)
@@ -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.