diff options
author | Francis Dupont <fdupont@isc.org> | 2019-09-21 08:52:27 +0200 |
---|---|---|
committer | Francis Dupont <fdupont@isc.org> | 2019-09-27 11:07:21 +0200 |
commit | 469f43a8285f84d014a1315a45232100f4343d1b (patch) | |
tree | fc22f937132d995deb63746c05774bc00df87ed1 /src/bin/netconf | |
parent | [918-check-c-11-thread-support-in-configure] Added ChangeLog entry for thread... (diff) | |
download | kea-469f43a8285f84d014a1315a45232100f4343d1b.tar.xz kea-469f43a8285f84d014a1315a45232100f4343d1b.zip |
[907-remove-kea-thread-library] Checkpoint (todo finish netconf)
Diffstat (limited to 'src/bin/netconf')
-rw-r--r-- | src/bin/netconf/Makefile.am | 1 | ||||
-rw-r--r-- | src/bin/netconf/netconf_process.cc | 12 | ||||
-rw-r--r-- | src/bin/netconf/tests/Makefile.am | 1 | ||||
-rw-r--r-- | src/bin/netconf/tests/control_socket_unittests.cc | 20 | ||||
-rw-r--r-- | src/bin/netconf/tests/netconf_unittests.cc | 21 |
5 files changed, 26 insertions, 29 deletions
diff --git a/src/bin/netconf/Makefile.am b/src/bin/netconf/Makefile.am index 4dab196f0c..1dbd9346d0 100644 --- a/src/bin/netconf/Makefile.am +++ b/src/bin/netconf/Makefile.am @@ -55,7 +55,6 @@ kea_netconf_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la kea_netconf_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la kea_netconf_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la kea_netconf_LDADD += $(top_builddir)/src/lib/log/libkea-log.la -kea_netconf_LDADD += $(top_builddir)/src/lib/util/threads/libkea-threads.la kea_netconf_LDADD += $(top_builddir)/src/lib/util/libkea-util.la kea_netconf_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la kea_netconf_LDADD += $(LOG4CPLUS_LIBS) $(CRYPTO_LIBS) $(BOOST_LIBS) $(SYSREPO_LIBS) diff --git a/src/bin/netconf/netconf_process.cc b/src/bin/netconf/netconf_process.cc index 17e728d3f8..769efebb99 100644 --- a/src/bin/netconf/netconf_process.cc +++ b/src/bin/netconf/netconf_process.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -14,15 +14,14 @@ #include <asiolink/io_error.h> #include <cc/command_interpreter.h> #include <config/timeouts.h> -#include <util/threads/thread.h> #include <boost/pointer_cast.hpp> +#include <thread> using namespace isc::asiolink; using namespace isc::config; using namespace isc::data; using namespace isc::http; using namespace isc::process; -using namespace isc::util::thread; namespace isc { namespace netconf { @@ -47,7 +46,7 @@ NetconfProcess::run() { try { // Initialize netconf agent in a thread. - Thread th([this]() { + std::thread th([this]() { if (shouldShutdown()) { return; } @@ -67,7 +66,9 @@ NetconfProcess::run() { // Call init. agent_.init(cfg_mgr); - }); + }); + + th.detach(); // Let's process incoming data or expiring timers in a loop until // shutdown condition is detected. @@ -75,6 +76,7 @@ NetconfProcess::run() { runIO(); } stopIOService(); + } catch (const std::exception& ex) { LOG_FATAL(netconf_logger, NETCONF_FAILED).arg(ex.what()); try { diff --git a/src/bin/netconf/tests/Makefile.am b/src/bin/netconf/tests/Makefile.am index 42cb31dfe2..207d35e118 100644 --- a/src/bin/netconf/tests/Makefile.am +++ b/src/bin/netconf/tests/Makefile.am @@ -66,7 +66,6 @@ netconf_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la netconf_unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la netconf_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la netconf_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la -netconf_unittests_LDADD += $(top_builddir)/src/lib/util/threads/libkea-threads.la netconf_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la netconf_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la netconf_unittests_LDADD += $(LOG4CPLUS_LIBS) $(CRYPTO_LIBS) diff --git a/src/bin/netconf/tests/control_socket_unittests.cc b/src/bin/netconf/tests/control_socket_unittests.cc index b3c0fca5b7..7525f74bce 100644 --- a/src/bin/netconf/tests/control_socket_unittests.cc +++ b/src/bin/netconf/tests/control_socket_unittests.cc @@ -20,10 +20,9 @@ #include <http/tests/response_test.h> #include <testutils/threaded_test.h> #include <testutils/sandbox.h> -#include <util/threads/thread.h> -#include <util/threads/sync.h> #include <gtest/gtest.h> #include <sstream> +#include <thread> using namespace std; using namespace isc; @@ -33,12 +32,11 @@ using namespace isc::data; using namespace isc::http; using namespace isc::http::test; using namespace isc::test; -using namespace isc::util::thread; namespace { /// @brief Type definition for the pointer to Thread objects. -typedef boost::shared_ptr<Thread> ThreadPtr; +typedef boost::shared_ptr<thread> ThreadPtr; //////////////////////////////// STDOUT //////////////////////////////// @@ -149,7 +147,7 @@ public: /// @brief Destructor. virtual ~UnixControlSocketTest() { if (thread_) { - thread_->wait(); + thread_->join(); thread_.reset(); } // io_service must be stopped after the thread returns, @@ -308,7 +306,7 @@ TEST_F(UnixControlSocketTest, configGet) { ASSERT_TRUE(ucs); // Run a reflecting server in a thread. - thread_.reset(new Thread([this]() { reflectServer(); })); + thread_.reset(new thread([this]() { reflectServer(); })); waitReady(); @@ -332,7 +330,7 @@ TEST_F(UnixControlSocketTest, configTest) { ASSERT_TRUE(ucs); // Run a reflecting server in a thread. - thread_.reset(new Thread([this]() { reflectServer(); })); + thread_.reset(new thread([this]() { reflectServer(); })); waitReady(); @@ -359,7 +357,7 @@ TEST_F(UnixControlSocketTest, configSet) { ASSERT_TRUE(ucs); // Run a reflecting server in a thread. - thread_.reset(new Thread([this]() { reflectServer(); })); + thread_.reset(new thread([this]() { reflectServer(); })); waitReady(); @@ -386,7 +384,7 @@ TEST_F(UnixControlSocketTest, timeout) { ASSERT_TRUE(ucs); // Run a timeout server in a thread. - thread_.reset(new Thread([this]() { waitReady(); })); + thread_.reset(new thread([this]() { waitReady(); })); // Try configGet: it should get a communication error, EXPECT_THROW(ucs->configGet("foo"), ControlSocketError); @@ -513,7 +511,7 @@ public: /// @brief Destructor. virtual ~HttpControlSocketTest() { if (thread_) { - thread_->wait(); + thread_->join(); thread_.reset(); } // io_service must be stopped after the thread returns, @@ -546,7 +544,7 @@ public: /// /// Run IO in a thread. void start() { - thread_.reset(new Thread([this]() { + thread_.reset(new thread([this]() { // The thread is ready to go. Signal it to the main // thread so it can start the actual test. signalReady(); diff --git a/src/bin/netconf/tests/netconf_unittests.cc b/src/bin/netconf/tests/netconf_unittests.cc index 289d58109c..b5a9e876dc 100644 --- a/src/bin/netconf/tests/netconf_unittests.cc +++ b/src/bin/netconf/tests/netconf_unittests.cc @@ -14,7 +14,6 @@ #include <asiolink/interval_timer.h> #include <asiolink/io_service.h> #include <cc/command_interpreter.h> -#include <util/threads/thread.h> #include <yang/yang_models.h> #include <yang/yang_revisions.h> #include <yang/translator_config.h> @@ -24,6 +23,7 @@ #include <testutils/sandbox.h> #include <gtest/gtest.h> #include <sstream> +#include <thread> using namespace std; using namespace isc; @@ -35,7 +35,6 @@ using namespace isc::http; using namespace isc::test; using namespace isc::yang; using namespace isc::yang::test; -using namespace isc::util::thread; #ifndef HAVE_PRE_0_7_6_SYSREPO using namespace sysrepo; #endif @@ -46,7 +45,7 @@ namespace { const string TEST_SOCKET = "test-socket"; /// @brief Type definition for the pointer to Thread objects. -typedef boost::shared_ptr<Thread> ThreadPtr; +typedef boost::shared_ptr<thread> ThreadPtr; /// @brief Test version of the NetconfAgent class. class NakedNetconfAgent : public NetconfAgent { @@ -107,7 +106,7 @@ public: virtual ~NetconfAgentTest() { NetconfProcess::shut_down = true; if (thread_) { - thread_->wait(); + thread_->join(); thread_.reset(); } // io_service must be stopped after the thread returns, @@ -191,7 +190,7 @@ public: io_service_->stop(); io_service_.reset(); if (thread_) { - thread_->wait(); + thread_->join(); thread_.reset(); } if (agent_) { @@ -460,7 +459,7 @@ TEST_F(NetconfAgentLogTest, logChanges) { EXPECT_NO_THROW(subs->module_change_subscribe(KEA_DHCP4_SERVER.c_str(), cb, 0, 0, SR_SUBSCR_APPLY_ONLY)); - thread_.reset(new Thread([this]() { io_service_->run(); })); + thread_.reset(new thread([this]() { io_service_->run(); })); // Change configuration (subnet #1 moved from 10.0.0.0/24 to 10.0.1/0/24). const YRTree tree1 = { @@ -527,7 +526,7 @@ TEST_F(NetconfAgentLogTest, logChanges2) { EXPECT_NO_THROW(subs->module_change_subscribe(KEA_DHCP4_SERVER.c_str(), cb, 0, 0, SR_SUBSCR_APPLY_ONLY)); - thread_.reset(new Thread([this]() { io_service_->run(); })); + thread_.reset(new thread([this]() { io_service_->run(); })); // Change configuration (subnet #1 moved to #10). string xpath = "/kea-dhcp4-server:config/subnet4[id='1']"; @@ -625,7 +624,7 @@ TEST_F(NetconfAgentTest, keaConfig) { CfgServersMapPair service_pair = *servers_map->begin(); // Launch server. - thread_.reset(new Thread([this]() { fakeServer(); signalStopped(); })); + thread_.reset(new thread([this]() { fakeServer(); signalStopped(); })); // Wait until the server is listening. waitReady(); @@ -726,7 +725,7 @@ TEST_F(NetconfAgentTest, yangConfig) { CfgServersMapPair service_pair = *servers_map->begin(); // Launch server. - thread_.reset(new Thread([this]() { fakeServer(); signalStopped();})); + thread_.reset(new thread([this]() { fakeServer(); signalStopped();})); // Wait until the server is listening. waitReady(); @@ -893,7 +892,7 @@ TEST_F(NetconfAgentTest, update) { EXPECT_EQ(2, agent_->subscriptions_.size()); // Launch server. - thread_.reset(new Thread([this]() { fakeServer(); signalStopped(); })); + thread_.reset(new thread([this]() { fakeServer(); signalStopped(); })); // Wait until the server is listening. waitReady(); @@ -1023,7 +1022,7 @@ TEST_F(NetconfAgentTest, validate) { EXPECT_EQ(2, agent_->subscriptions_.size()); // Launch server twice. - thread_.reset(new Thread([this]() + thread_.reset(new thread([this]() { fakeServer(); fakeServer(); |