Browse Source

[5189] Miscellanous corrections.

Marcin Siodelski 8 years ago
parent
commit
193cd31c82

+ 3 - 1
src/bin/agent/ca_command_mgr.cc

@@ -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();

+ 0 - 1
src/bin/agent/ca_command_mgr.h

@@ -11,7 +11,6 @@
 #include <exceptions/exceptions.h>
 #include <boost/noncopyable.hpp>
 #include <boost/shared_ptr.hpp>
-#include <array>
 
 namespace isc {
 namespace agent {

+ 9 - 4
src/bin/agent/tests/ca_command_mgr_unittests.cc

@@ -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

+ 1 - 1
src/lib/asiolink/tests/unix_domain_socket_unittest.cc

@@ -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();
             }

+ 3 - 0
src/lib/asiolink/testutils/test_server_unix_socket.cc

@@ -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));

+ 1 - 1
src/lib/asiolink/unix_domain_socket.cc

@@ -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.

+ 1 - 1
src/lib/asiolink/unix_domain_socket.h

@@ -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);
 

+ 1 - 0
src/lib/config/tests/client_connection_unittests.cc

@@ -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: