]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5317] Use ASIO unix domain sockets in DHCPv6 server.
authorMarcin Siodelski <marcin@isc.org>
Wed, 21 Jun 2017 17:16:28 +0000 (19:16 +0200)
committerMarcin Siodelski <marcin@isc.org>
Wed, 21 Jun 2017 17:16:28 +0000 (19:16 +0200)
src/bin/dhcp6/ctrl_dhcp6_srv.cc
src/bin/dhcp6/tests/ctrl_dhcp6_srv_unittest.cc

index d5c572c094eefb3e3a7b8e55e087699c5bcf1bce..87bf60bfde3cd895dc5b7b9b0ca65d20b3e83d7a 100644 (file)
@@ -615,8 +615,12 @@ ControlledDhcpv6Srv::ControlledDhcpv6Srv(uint16_t port)
     }
     server_ = this; // remember this instance for use in callback
 
+    // TimerMgr uses IO service to run asynchronous timers.
     TimerMgr::instance()->setIOService(getIOService());
 
+    // CommandMgr uses IO service to run asynchronous socket operations.
+    CommandMgr::instance().setIOService(getIOService());
+
     // These are the commands always supported by the DHCPv6 server.
     // Please keep the list in alphabetic order.
     CommandMgr::instance().registerCommand("build-report",
index f325ab3e6bc1ec03b81eac9e0a7c2b16b0dfb3ea..481384ebe007f37c7f3dde4fce8f2553f51decbc 100644 (file)
@@ -114,6 +114,14 @@ public:
         reset();
     };
 
+    /// @brief Returns pointer to the server's IO service.
+    ///
+    /// @return Pointer to the server's IO service or null pointer if the server
+    /// hasn't been created.
+    IOServicePtr getIOService() {
+        return (server_ ? server_->getIOService() : IOServicePtr());
+    }
+
     void createUnixChannelServer() {
         static_cast<void>(::remove(socket_path_.c_str()));
 
@@ -196,11 +204,13 @@ public:
         // detect the control socket connect and call the  accept handler
         ASSERT_TRUE(client->connectToServer(socket_path_));
         ASSERT_NO_THROW(server_->receivePacket(0));
+        ASSERT_NO_THROW(getIOService()->run_one());
 
         // Send the command and then call server's receivePacket() so it can
         // detect the inbound data and call the read handler
         ASSERT_TRUE(client->sendCommand(command));
         ASSERT_NO_THROW(server_->receivePacket(0));
+        ASSERT_NO_THROW(getIOService()->run_one());
 
         // Read the response generated by the server. Note that getResponse
         // only fails if there an IO error or no response data was present.
@@ -210,6 +220,8 @@ public:
         // Now disconnect and process the close event
         client->disconnectFromServer();
         ASSERT_NO_THROW(server_->receivePacket(0));
+
+        ASSERT_NO_THROW(getIOService()->poll());
     }
 
     /// @brief Checks response for list-commands