summaryrefslogtreecommitdiffstats
path: root/src/bin/netconf
diff options
context:
space:
mode:
authorRazvan Becheriu <razvan@isc.org>2021-08-29 00:03:56 +0200
committerRazvan Becheriu <razvan@isc.org>2021-08-29 00:18:07 +0200
commit964efd2d7aff7ddca6c27691fb289665348e6494 (patch)
tree33c5f213a1608fb823261a01e2c28b6a7db1538f /src/bin/netconf
parent[#2043] allow callbacks to create CS inside the CS constructor and destructor (diff)
downloadkea-964efd2d7aff7ddca6c27691fb289665348e6494.tar.xz
kea-964efd2d7aff7ddca6c27691fb289665348e6494.zip
[#2061] fixed TSAN warnings in kea-netconf
Diffstat (limited to 'src/bin/netconf')
-rw-r--r--src/bin/netconf/netconf_process.cc33
-rw-r--r--src/bin/netconf/tests/netconf_unittests.cc22
2 files changed, 20 insertions, 35 deletions
diff --git a/src/bin/netconf/netconf_process.cc b/src/bin/netconf/netconf_process.cc
index 62cbdb23ae..ef1672b119 100644
--- a/src/bin/netconf/netconf_process.cc
+++ b/src/bin/netconf/netconf_process.cc
@@ -40,30 +40,15 @@ NetconfProcess::run() {
LOG_INFO(netconf_logger, NETCONF_STARTED).arg(VERSION);
try {
- // Initialize netconf agent in a thread.
- std::thread th([this]() {
- try {
- // Initialize sysrepo.
- agent_.initSysrepo();
-
- // Get the configuration manager.
- NetconfCfgMgrPtr cfg_mgr(getNetconfCfgMgr());
-
- // Call init.
- agent_.init(cfg_mgr);
- } catch (...) {
- // Should not happen but in case...
- std::exception_ptr eptr = std::current_exception();
- getIoService()->post([eptr] () {
- if (eptr) {
- std::rethrow_exception(eptr);
- }
- });
- }
- });
-
- // Detach the thread.
- th.detach();
+ // Initialize netconf agent.
+ // Initialize sysrepo.
+ agent_.initSysrepo();
+
+ // Get the configuration manager.
+ NetconfCfgMgrPtr 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.
diff --git a/src/bin/netconf/tests/netconf_unittests.cc b/src/bin/netconf/tests/netconf_unittests.cc
index 76419328c0..bd9be00f42 100644
--- a/src/bin/netconf/tests/netconf_unittests.cc
+++ b/src/bin/netconf/tests/netconf_unittests.cc
@@ -187,31 +187,28 @@ class NetconfAgentLogTest : public dhcp::test::LogContentTest {
public:
/// @brief Constructor.
NetconfAgentLogTest()
- : io_service_(new IOService()),
+ : finished_(false),
+ io_service_(new IOService()),
thread_(),
agent_(new NakedNetconfAgent) {
}
/// @brief Destructor.
virtual ~NetconfAgentLogTest() {
+ if (agent_) {
+ clearYang(agent_);
+ agent_->clear();
+ }
+ agent_.reset();
// io_service must be stopped to make the thread to return.
io_service_->stop();
- io_service_.reset();
if (thread_) {
thread_->join();
thread_.reset();
}
- if (agent_) {
- clearYang(agent_);
- agent_->clear();
- }
- agent_.reset();
+ io_service_.reset();
}
-
- /// @brief To know when the callback was called.
- bool finished_;
-
/// @brief Default change callback (print changes and return OK).
sr_error_t callback(sysrepo::S_Session sess,
const char* module_name,
@@ -233,6 +230,9 @@ public:
}
}
+ /// @brief To know when the callback was called.
+ std::atomic<bool> finished_;
+
/// @brief IOService object.
IOServicePtr io_service_;