]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5189] Miscellanous corrections.
authorMarcin Siodelski <marcin@isc.org>
Mon, 29 May 2017 11:30:12 +0000 (13:30 +0200)
committerMarcin Siodelski <marcin@isc.org>
Mon, 29 May 2017 11:30:12 +0000 (13:30 +0200)
src/bin/agent/ca_command_mgr.cc
src/bin/agent/ca_command_mgr.h
src/bin/agent/tests/ca_command_mgr_unittests.cc
src/lib/asiolink/tests/unix_domain_socket_unittest.cc
src/lib/asiolink/testutils/test_server_unix_socket.cc
src/lib/asiolink/unix_domain_socket.cc
src/lib/asiolink/unix_domain_socket.h
src/lib/config/tests/client_connection_unittests.cc

index 1e19fe41409938e579d1f30a8a4ca44ac030cfde..21555448b2a7b33543afd8864cdb65bcdc136171 100644 (file)
@@ -30,6 +30,7 @@ using namespace isc::process;
 namespace {
 
 /// @brief Client side connection timeout.
+/// @todo Make it configurable.
 const long CONNECTION_TIMEOUT = 5000;
 
 }
@@ -206,7 +207,8 @@ CtrlAgentCommandMgr::forwardCommand(const std::string& service,
                    // Capture error code and parsed data.
                    received_ec = ec;
                    received_feed = feed;
-                   // Stop the IO service so as we can continue.
+                   // Got the IO service so stop IO service. This causes to
+                   // stop IO service when all handlers have been invoked.
                    io_service->stopWork();
                }, ClientConnection::Timeout(CONNECTION_TIMEOUT));
     io_service->run();
index cad7614a82305e7f8805d304a5b821afd18e8412..819fa3399c1ffa191e55ed41a80fc5eaded934ec 100644 (file)
@@ -11,7 +11,6 @@
 #include <exceptions/exceptions.h>
 #include <boost/noncopyable.hpp>
 #include <boost/shared_ptr.hpp>
-#include <array>
 
 namespace isc {
 namespace agent {
index ff163ee35812dbcc8d144028aca39b9eb9d8a0b4..5b2b98c29f619396a0e5f8c856c2d4791786a424 100644 (file)
@@ -229,9 +229,9 @@ public:
         bindServerSocket(server_response, true);
 
         // The client side communication is synchronous. To be able to respond
-        // to this we need to run the server side socket at the same time.
-        // Running IO service in a thread guarantees that the server responds
-        // as soon as it receives the control command.
+        // to this we need to run the server side socket at the same time as the
+        // client. Running IO service in a thread guarantees that the server
+        //responds as soon as it receives the control command.
         isc::util::thread::Thread th(boost::bind(&IOService::run,
                                                  getIOService().get()));
 
@@ -243,13 +243,15 @@ public:
         ConstElementPtr answer = mgr_.handleCommand("foo", ConstElementPtr(),
                                                     command);
 
+        // Cancel all asynchronous operations and let the handlers to be invoked
+        // with operation_aborted error code.
         server_socket_->stopServer();
         getIOService()->stopWork();
 
+        // Wait for the thread to finish.
         th.wait();
 
         EXPECT_EQ(expected_responses, server_socket_->getResponseNum());
-
         checkAnswer(answer, expected_result0, expected_result1, expected_result2);
     }
 
@@ -367,9 +369,12 @@ TEST_F(CtrlAgentCommandMgrTest, forwardListCommands) {
     ConstElementPtr answer = mgr_.handleCommand("list-commands", ConstElementPtr(),
                                                 command);
 
+    // Cancel all asynchronous operations and let the handlers to be invoked
+    // with operation_aborted error code.
     server_socket_->stopServer();
     getIOService()->stopWork();
 
+    // Wait for the thread to finish.
     th.wait();
 
     // Answer of 3 is specific to the stub response we send when the
index bc298d04b54e60ded0d8ca61df45a996fcc07789..353f9e9830e905354264f8f21cbad68b9ab4f75d 100644 (file)
@@ -132,7 +132,7 @@ TEST_F(UnixDomainSocketTest, asyncSendReceive) {
             connect_handler_invoked = true;
             // Operation aborted indicates that IO service has been stopped. This
             // shouldn't happen here.
-            if (ec && ec.value() != boost::asio::error::operation_aborted) {
+            if (ec && (ec.value() != boost::asio::error::operation_aborted)) {
                 ADD_FAILURE() << "error occurred while asynchronously connecting"
                     " via unix domain socket: " << ec.message();
             }
index 3dcb869ff0f325edda441a38468f70a14314d8cb..d995c7a26dcc6e075422027dd91d3c4856853106 100644 (file)
@@ -257,6 +257,9 @@ TestServerUnixSocket::bindServerSocket(const bool use_thread) {
     server_acceptor_.listen();
     accept();
 
+    // When threads are in use, we need to post a handler which will be invoked
+    // when the thread has already started and the IO service is running. The
+    // main thread can move forward when it receives this signal from the handler.
     if (use_thread) {
         io_service_.post(boost::bind(&TestServerUnixSocket::signalRunning,
                                      this));
index c6436a8a66f96265bf15579044730fa6ded813c6..04f51c0d1065dd59f35fbf65bf0b34428f11f2f2 100644 (file)
@@ -105,7 +105,7 @@ public:
     /// @brief Asynchronously receive data over the socket.
     ///
     /// This method schedules asynchronous receive and installs the
-    /// @ref UnixDomainSocket::receiveHandler is a callback.
+    /// @ref UnixDomainSocketImpl::receiveHandler is a callback.
     ///
     /// @param data Pointer to a buffer into which the data should be read.
     /// @param length Length of the buffer.
index db5ca294a94f4a68da5a4641789d7c5cacdb7301..0bb2164929fe340087818b276d737d7b1ff2ecfe 100644 (file)
@@ -80,7 +80,7 @@ public:
     ///
     /// @param data Pointer to data to be sent.
     /// @param length Number of bytes to be sent.
-    /// @param handler Callback to be invoked when data have been sent or an
+    /// @param handler Callback to be invoked when data have been sent or
     /// sending error is signalled.
     void asyncSend(const void* data, const size_t length, const Handler& handler);
 
index 3d9f7cd63e4a784510e020b9c4257c9b2ba07d33..a87e01977e5826a8be460decb7022dd9e1c422ef 100644 (file)
@@ -26,6 +26,7 @@ const std::string TEST_SOCKET = "test-socket";
 /// @brief Test timeout in ms.
 const long TEST_TIMEOUT = 10000;
 
+// Test fixture class for @ref ClientConnection.
 class ClientConnectionTest : public ::testing::Test {
 public: