]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1375] removed unused IOService
authorRazvan Becheriu <razvan@isc.org>
Fri, 6 Nov 2020 09:02:01 +0000 (11:02 +0200)
committerRazvan Becheriu <razvan@isc.org>
Wed, 9 Dec 2020 17:12:46 +0000 (19:12 +0200)
src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp4/ctrl_dhcp4_srv.h
src/bin/dhcp6/ctrl_dhcp6_srv.cc
src/bin/dhcp6/ctrl_dhcp6_srv.h
src/lib/database/database_connection.cc
src/lib/database/tests/database_connection_unittest.cc
src/lib/dhcpsrv/tests/mysql_lease_mgr_unittest.cc
src/lib/dhcpsrv/tests/pgsql_lease_mgr_unittest.cc
src/lib/mysql/mysql_connection.h
src/lib/pgsql/pgsql_connection.h

index 094a65db4657584b19da976da1787a6ca79bc23c..fb2a45254d02b712426f5b8fa8f5ccbb44337163 100644 (file)
@@ -814,7 +814,7 @@ ControlledDhcpv4Srv::processConfig(isc::data::ConstElementPtr config) {
 
         CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess();
         cfg_db->setAppendedParameters("universe=4");
-        cfg_db->createManagers(server_->io_service_);
+        cfg_db->createManagers(server_->getIOService());
     } catch (const std::exception& ex) {
         err << "Unable to open database: " << ex.what();
         return (isc::config::createAnswer(1, err.str()));
@@ -967,8 +967,7 @@ ControlledDhcpv4Srv::checkConfig(isc::data::ConstElementPtr config) {
 
 ControlledDhcpv4Srv::ControlledDhcpv4Srv(uint16_t server_port /*= DHCP4_SERVER_PORT*/,
                                          uint16_t client_port /*= 0*/)
-    : Dhcpv4Srv(server_port, client_port), io_service_(boost::make_shared<IOService>()),
-      timer_mgr_(TimerMgr::instance()) {
+    : Dhcpv4Srv(server_port, client_port), timer_mgr_(TimerMgr::instance()) {
     if (getInstance()) {
         isc_throw(InvalidOperation,
                   "There is another Dhcpv4Srv instance already.");
@@ -1062,7 +1061,7 @@ ControlledDhcpv4Srv::ControlledDhcpv4Srv(uint16_t server_port /*= DHCP4_SERVER_P
 
 void ControlledDhcpv4Srv::shutdownServer(int exit_value) {
     setExitValue(exit_value);
-    io_service_->stop();       // Stop ASIO transmissions
+    getIOService()->stop();   // Stop ASIO transmissions
     shutdown();               // Initiate DHCPv4 shutdown procedure.
 }
 
@@ -1117,14 +1116,6 @@ ControlledDhcpv4Srv::~ControlledDhcpv4Srv() {
                     // at this stage anyway.
 }
 
-void ControlledDhcpv4Srv::sessionReader(void) {
-    // Process one asio event. If there are more events, iface_mgr will call
-    // this callback more than once.
-    if (getInstance()) {
-        getInstance()->io_service_->run_one();
-    }
-}
-
 void
 ControlledDhcpv4Srv::reclaimExpiredLeases(const size_t max_leases,
                                           const uint16_t timeout,
index 81c6ce636549bd76764d3d943aba9eae8241c17f..8195dc288d6a7b254c35c23e667b793d62e99dc4 100644 (file)
@@ -444,9 +444,6 @@ private:
     /// the server. Some of them need to be static methods.
     static ControlledDhcpv4Srv* server_;
 
-    /// @brief IOService object, used for all ASIO operations.
-    isc::asiolink::IOServicePtr io_service_;
-
     /// @brief Instance of the @c TimerMgr.
     ///
     /// Shared pointer to the instance of timer @c TimerMgr is held here to
index c687d1bfba58d50a82baeb4f9094aaa272130b83..5133a906526fee0edcc36726a887b560d783c207 100644 (file)
@@ -817,7 +817,7 @@ ControlledDhcpv6Srv::processConfig(isc::data::ConstElementPtr config) {
 
         CfgDbAccessPtr cfg_db = CfgMgr::instance().getStagingCfg()->getCfgDbAccess();
         cfg_db->setAppendedParameters("universe=6");
-        cfg_db->createManagers(server_->io_service_);
+        cfg_db->createManagers(server_->getIOService());
     } catch (const std::exception& ex) {
         err << "Unable to open database: " << ex.what();
         return (isc::config::createAnswer(1, err.str()));
@@ -986,8 +986,7 @@ ControlledDhcpv6Srv::checkConfig(isc::data::ConstElementPtr config) {
 
 ControlledDhcpv6Srv::ControlledDhcpv6Srv(uint16_t server_port,
                                          uint16_t client_port)
-    : Dhcpv6Srv(server_port, client_port), io_service_(boost::make_shared<IOService>()),
-      timer_mgr_(TimerMgr::instance()) {
+    : Dhcpv6Srv(server_port, client_port), timer_mgr_(TimerMgr::instance()) {
     if (getInstance()) {
         isc_throw(InvalidOperation,
                   "There is another Dhcpv6Srv instance already.");
@@ -1081,8 +1080,8 @@ ControlledDhcpv6Srv::ControlledDhcpv6Srv(uint16_t server_port,
 
 void ControlledDhcpv6Srv::shutdownServer(int exit_value) {
     setExitValue(exit_value);
-    io_service_->stop();    // Stop ASIO transmissions
-    shutdown();            // Initiate DHCPv6 shutdown procedure.
+    getIOService()->stop();   // Stop ASIO transmissions
+    shutdown();               // Initiate DHCPv6 shutdown procedure.
 }
 
 ControlledDhcpv6Srv::~ControlledDhcpv6Srv() {
@@ -1136,14 +1135,6 @@ ControlledDhcpv6Srv::~ControlledDhcpv6Srv() {
                     // at this stage anyway.
 }
 
-void ControlledDhcpv6Srv::sessionReader(void) {
-    // Process one asio event. If there are more events, iface_mgr will call
-    // this callback more than once.
-    if (getInstance()) {
-        getInstance()->io_service_->run_one();
-    }
-}
-
 void
 ControlledDhcpv6Srv::reclaimExpiredLeases(const size_t max_leases,
                                           const uint16_t timeout,
index fabfe6bf763f9acd707b4e1ef8918967e243766a..a7a4642823885ec58da0ef6ce2cc06368bd2f98e 100644 (file)
@@ -444,9 +444,6 @@ private:
     /// the server. Some of them need to be static methods.
     static ControlledDhcpv6Srv* server_;
 
-    /// @brief IOService object, used for all ASIO operations.
-    isc::asiolink::IOServicePtr io_service_;
-
     /// @brief Instance of the @c TimerMgr.
     ///
     /// Shared pointer to the instance of timer @c TimerMgr is held here to
index 6c5d427dc2e8b0624be14ef4b373cff6386f43c8..03e0f78547cec594c859e0a04a4ce5da5cf31526 100644 (file)
@@ -138,7 +138,7 @@ DatabaseConnection::makeReconnectCtl(const std::string& timer_name) {
         // Wasn't specified so we'll use default of 0;
     }
 
-    reconnect_ctl_ = boost::make_shared<ReconnectCtl>(timer_name, type, retries,
+    reconnect_ctl_ = boost::make_shared<ReconnectCtl>(type, timer_name, retries,
                                                       interval);
 }
 
index 7442454045418731a49d5da358b375cfe44dd375..f7e26720e50aa201bd15d6c334710b42dd1abc44 100644 (file)
@@ -230,7 +230,6 @@ TEST_F(DatabaseConnectionCallbackTest, dbRecoveredCallback) {
     ASSERT_EQ(3, db_reconnect_ctl_->maxRetries());
     ASSERT_EQ(3, db_reconnect_ctl_->retriesLeft());
     EXPECT_EQ(60000, db_reconnect_ctl_->retryInterval());
-    ASSERT_TRUE(db_reconnect_ctl_->checkRetries());
 
     /// Verify that checkRetries() correctly decrements
     /// down to zero, and that retriesLeft() returns
@@ -294,7 +293,6 @@ TEST_F(DatabaseConnectionCallbackTest, dbFailedCallback) {
     ASSERT_EQ(3, db_reconnect_ctl_->maxRetries());
     ASSERT_EQ(3, db_reconnect_ctl_->retriesLeft());
     EXPECT_EQ(60000, db_reconnect_ctl_->retryInterval());
-    ASSERT_TRUE(db_reconnect_ctl_->checkRetries());
 
     /// Verify that checkRetries() correctly decrements
     /// down to zero, and that retriesLeft() returns
index 7f18d0a4cb4378272ef06e4af608614d4e4accef..88aa540004da755583c794de2b5876b0b3c564bc 100644 (file)
@@ -964,7 +964,7 @@ public:
 
     virtual std::string invalidConnectString() {
        return (connectionString(MYSQL_VALID_TYPE, INVALID_NAME, VALID_HOST,
-                        VALID_USER, VALID_PASSWORD));
+                                VALID_USER, VALID_PASSWORD));
     }
 };
 
index 6fc7d4efde77af1bf6f5115ca80c05d79a0c0afe..988ea8895ea70d278320f3344dc30055f4061125 100644 (file)
@@ -920,7 +920,7 @@ public:
 
     virtual std::string invalidConnectString() {
         return (connectionString(PGSQL_VALID_TYPE, VALID_NAME, INVALID_HOST,
-                        VALID_USER, VALID_PASSWORD));
+                                 VALID_USER, VALID_PASSWORD));
     }
 };
 
index ada6eb495f4eecd257afadeb82771e983e8367ba..7272a90a122f19cc68441e10dcab707bdf183eac 100644 (file)
@@ -654,7 +654,7 @@ public:
     ///
     /// @note The recover function must be run on the IO Service thread.
     void startRecoverDbConnection() {
-        if (callback_) {
+        if (callback_ && io_service_) {
             io_service_->post(std::bind(callback_, reconnectCtl()));
         }
     }
index 9337727f5875082fdffcfe13944f65cf76756285..d7b1f254b5cf30feb1a9e0a845ad4b2376600574 100644 (file)
@@ -421,7 +421,7 @@ public:
     ///
     /// @note The recover function must be run on the IO Service thread.
     void startRecoverDbConnection() {
-        if (callback_) {
+        if (callback_ && io_service_) {
             io_service_->post(std::bind(callback_, reconnectCtl()));
         }
     }