From: Francis Dupont Date: Thu, 25 Oct 2018 21:54:04 +0000 (+0200) Subject: [153-netconf-agent] Revamp the init thread X-Git-Tag: 176-update-to-sysrepo-0-7-6-release_base~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c7dca543a613b89fc68d1f2384992264c66cbbd;p=thirdparty%2Fkea.git [153-netconf-agent] Revamp the init thread --- diff --git a/src/bin/netconf/netconf.h b/src/bin/netconf/netconf.h index 7142d5aad5..c8d58d7382 100644 --- a/src/bin/netconf/netconf.h +++ b/src/bin/netconf/netconf.h @@ -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. diff --git a/src/bin/netconf/netconf_process.cc b/src/bin/netconf/netconf_process.cc index c242f2ded6..9cef199909 100644 --- a/src/bin/netconf/netconf_process.cc +++ b/src/bin/netconf/netconf_process.cc @@ -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.