]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3710] removed code
authorRazvan Becheriu <razvan@isc.org>
Thu, 13 Mar 2025 12:48:27 +0000 (14:48 +0200)
committerRazvan Becheriu <razvan@isc.org>
Mon, 17 Mar 2025 13:11:33 +0000 (13:11 +0000)
src/hooks/dhcp/forensic_log/rotating_file.cc
src/hooks/dhcp/forensic_log/rotating_file.h
src/hooks/dhcp/mysql/mysql_legal_log.cc
src/hooks/dhcp/mysql/mysql_legal_log.h
src/hooks/dhcp/mysql/tests/mysql_forensic_unittest.cc
src/hooks/dhcp/pgsql/pgsql_legal_log.cc
src/hooks/dhcp/pgsql/pgsql_legal_log.h
src/hooks/dhcp/pgsql/tests/pgsql_forensic_unittest.cc
src/lib/dhcpsrv/legal_log_mgr.h
src/lib/dhcpsrv/legal_log_mgr_factory.cc
src/lib/dhcpsrv/tests/legal_log_mgr_factory_unittest.cc

index 4f48d1613885f6b949752b181278ef7becff007b..d50a7dbdc4420bc956bc5a2b2ae9bf860ce39eac 100644 (file)
@@ -271,7 +271,7 @@ RotatingFile::useExistingFiles(struct tm& time_info) {
 }
 
 void
-RotatingFile::open(ManagerID) {
+RotatingFile::open() {
     if (isOpen() || MultiThreadingMgr::instance().isTestMode()) {
         return;
     }
index 00d121dd88dd592b15fb1c26ada6fc715dc8b5e5..7dc942c943e9ee92bda0dbe9062519e4411826f3 100644 (file)
@@ -135,10 +135,8 @@ public:
     /// it is created.  If the file is already open, the method simply
     /// returns.
     ///
-    /// @param id the forensic backend manager ID.
-    ///
     /// @throw LegalLogMgrError if the file cannot be opened.
-    virtual void open(isc::dhcp::ManagerID id = 0);
+    virtual void open();
 
     /// @brief Closes the underlying file.
     ///
index 2ec9ce5b75618912b2fb4374b84b8acde63916a5..559e36a247ad9aeb76bdd917346ba1c1eac61a82 100644 (file)
@@ -280,16 +280,13 @@ MySqlStore::MySqlStore(const DatabaseConnection::ParameterMap& parameters)
     timer_name_ += "]DbReconnectTimer";
 }
 
-void MySqlStore::open(ManagerID id) {
+void MySqlStore::open() {
     LegalLogDbLogger pushed(mysql_legal_log_db_logger);
 
     // Test schema version first.
     std::pair<uint32_t, uint32_t> code_version(MYSQL_SCHEMA_VERSION_MAJOR,
                                                MYSQL_SCHEMA_VERSION_MINOR);
 
-    LegalLogMgrPtr store = LegalLogMgrFactory::instance(id);
-    LegalLogMgrFactory::instance(id).reset();
-
     string timer_name;
     bool retry = false;
     if (LegalLogMgr::getParameters().count("retry-on-startup")) {
@@ -310,8 +307,6 @@ void MySqlStore::open(ManagerID id) {
                   << db_version.second);
     }
 
-    LegalLogMgrFactory::instance(id) = store;
-
     // Create an initial context.
     pool_.reset(new MySqlStoreContextPool());
     pool_->pool_.push_back(createContext());
index f038b24d7f1b4a329d7f99bf223cd66d79934c05..d5be34e27a60e788f6ef14784fb73c86ce9c3094 100644 (file)
@@ -136,12 +136,10 @@ public:
     ///
     /// Finally, all the SQL commands are pre-compiled.
     ///
-    /// @param id the forensic backend manager ID.
-    ///
     /// @throw isc::db::DbOpenError Error opening the database
     /// @throw isc::db::DbOperationError An operation on the open
     ///        database has failed.
-    virtual void open(ManagerID id = 0);
+    virtual void open();
 
     /// @brief Closes the store.
     virtual void close();
index 34dfc58e6c8757d6de4659efd0a586ec7dec8e37..dbe39e40bccbb0f412b3f4a3c341341b14a5a0a9 100644 (file)
@@ -589,10 +589,7 @@ MySqlLegalLogDbLostCallbackTest::testRetryOpenDbLostAndRecoveredCallback() {
     std::shared_ptr<DbConnectionInitWithRetry> dbr(new DbConnectionInitWithRetry());
     params.emplace("retry-on-startup", "true");
 
-    ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new MySqlStore(params)));
-
-    // Check params validity is done by open().
-    EXPECT_THROW(LegalLogMgrFactory::instance()->open(), DbOpenErrorWithRetry);
+    ASSERT_THROW(LegalLogMgrFactory::addBackend(params), DbOpenErrorWithRetry);
 
     // Verify there is no instance.
     ASSERT_FALSE(LegalLogMgrFactory::instance());
@@ -633,10 +630,7 @@ MySqlLegalLogDbLostCallbackTest::testRetryOpenDbLostAndFailedCallback() {
     std::shared_ptr<DbConnectionInitWithRetry> dbr(new DbConnectionInitWithRetry());
     params.emplace("retry-on-startup", "true");
 
-    ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new MySqlStore(params)));
-
-    // Check params validity is done by open().
-    EXPECT_THROW(LegalLogMgrFactory::instance()->open(), DbOpenErrorWithRetry);
+    ASSERT_THROW(LegalLogMgrFactory::addBackend(params), DbOpenErrorWithRetry);
 
     // Verify there is no instance.
     ASSERT_FALSE(LegalLogMgrFactory::instance());
@@ -677,10 +671,7 @@ MySqlLegalLogDbLostCallbackTest::testRetryOpenDbLostAndRecoveredAfterTimeoutCall
     std::shared_ptr<DbConnectionInitWithRetry> dbr(new DbConnectionInitWithRetry());
     params.emplace("retry-on-startup", "true");
 
-    ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new MySqlStore(params)));
-
-    // Check params validity is done by open().
-    EXPECT_THROW(LegalLogMgrFactory::instance()->open(), DbOpenErrorWithRetry);
+    ASSERT_THROW(LegalLogMgrFactory::addBackend(params), DbOpenErrorWithRetry);
 
     // Verify there is no instance.
     ASSERT_FALSE(LegalLogMgrFactory::instance());
@@ -749,10 +740,7 @@ MySqlLegalLogDbLostCallbackTest::testRetryOpenDbLostAndFailedAfterTimeoutCallbac
     std::shared_ptr<DbConnectionInitWithRetry> dbr(new DbConnectionInitWithRetry());
     params.emplace("retry-on-startup", "true");
 
-    ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new MySqlStore(params)));
-
-    // Check params validity is done by open().
-    EXPECT_THROW(LegalLogMgrFactory::instance()->open(), DbOpenErrorWithRetry);
+    ASSERT_THROW(LegalLogMgrFactory::addBackend(params), DbOpenErrorWithRetry);
 
     // Verify there is no instance.
     ASSERT_FALSE(LegalLogMgrFactory::instance());
@@ -808,10 +796,7 @@ MySqlLegalLogDbLostCallbackTest::testNoCallbackOnOpenFailure() {
     // Verify that a MySqlStore with no database name is rejected.
     DatabaseConnection::ParameterMap params = db::DatabaseConnection::parse(invalidConnectString());
 
-    ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new MySqlStore(params)));
-
-    // Check params validity is done by open().
-    EXPECT_THROW(LegalLogMgrFactory::instance()->open(), DbOpenError);
+    ASSERT_THROW(LegalLogMgrFactory::addBackend(params), DbOpenError);
 
     io_service_->poll();
 
@@ -846,11 +831,7 @@ MySqlLegalLogDbLostCallbackTest::testDbLostAndRecoveredCallback() {
     // Verify that a MySqlStore with database name is not rejected.
     DatabaseConnection::ParameterMap params = db::DatabaseConnection::parse(validConnectString());
 
-    ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new MySqlStore(params)));
-    LegalLogMgrFactory::setParameters(params);
-
-    // Check params validity is done by open().
-    EXPECT_NO_THROW_LOG(LegalLogMgrFactory::instance()->open());
+    ASSERT_NO_THROW(LegalLogMgrFactory::addBackend(params));
 
     ASSERT_TRUE(LegalLogMgrFactory::instance());
 
@@ -904,10 +885,7 @@ MySqlLegalLogDbLostCallbackTest::testDbLostAndFailedCallback() {
     // Verify that a MySqlStore with database name is not rejected.
     DatabaseConnection::ParameterMap params = db::DatabaseConnection::parse(validConnectString());
 
-    ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new MySqlStore(params)));
-
-    // Check params validity is done by open().
-    EXPECT_NO_THROW_LOG(LegalLogMgrFactory::instance()->open());
+    ASSERT_NO_THROW(LegalLogMgrFactory::addBackend(params));
 
     ASSERT_TRUE(LegalLogMgrFactory::instance());
 
@@ -968,11 +946,7 @@ MySqlLegalLogDbLostCallbackTest::testDbLostAndRecoveredAfterTimeoutCallback() {
     // Verify that a MySqlStore with database name is not rejected.
     DatabaseConnection::ParameterMap params = db::DatabaseConnection::parse(access);
 
-    ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new MySqlStore(params)));
-    LegalLogMgrFactory::setParameters(params);
-
-    // Check params validity is done by open().
-    EXPECT_NO_THROW_LOG(LegalLogMgrFactory::instance()->open());
+    ASSERT_NO_THROW(LegalLogMgrFactory::addBackend(params));
 
     ASSERT_TRUE(LegalLogMgrFactory::instance());
 
@@ -1062,10 +1036,7 @@ MySqlLegalLogDbLostCallbackTest::testDbLostAndFailedAfterTimeoutCallback() {
     // Verify that a MySqlStore with database name is not rejected.
     DatabaseConnection::ParameterMap params = db::DatabaseConnection::parse(access);
 
-    ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new MySqlStore(params)));
-
-    // Check params validity is done by open().
-    EXPECT_NO_THROW_LOG(LegalLogMgrFactory::instance()->open());
+    ASSERT_NO_THROW(LegalLogMgrFactory::addBackend(params));
 
     ASSERT_TRUE(LegalLogMgrFactory::instance());
 
index f952ad7a9e55dc6ae09f51b4ba005558a54b988f..49a8a5239167fd6a6fcf63ec2f12c230571265f1 100644 (file)
@@ -177,7 +177,7 @@ PgSqlStore::PgSqlStore(const DatabaseConnection::ParameterMap& parameters)
     timer_name_ += "]DbReconnectTimer";
 }
 
-void PgSqlStore::open(ManagerID id) {
+void PgSqlStore::open() {
     LegalLogDbLogger pushed(pgsql_legal_log_db_logger);
 
     // Check TLS support.
@@ -207,9 +207,6 @@ void PgSqlStore::open(ManagerID id) {
     pair<uint32_t, uint32_t> code_version(PGSQL_SCHEMA_VERSION_MAJOR,
                                           PGSQL_SCHEMA_VERSION_MINOR);
 
-    LegalLogMgrPtr store = LegalLogMgrFactory::instance(id);
-    LegalLogMgrFactory::instance(id).reset();
-
     string timer_name;
     bool retry = false;
     if (LegalLogMgr::getParameters().count("retry-on-startup")) {
@@ -230,8 +227,6 @@ void PgSqlStore::open(ManagerID id) {
                   << db_version.second);
     }
 
-    LegalLogMgrFactory::instance(id) = store;
-
     // Create an initial context.
     pool_.reset(new PgSqlStoreContextPool());
     pool_->pool_.push_back(createContext());
index 88051766636749526e66624ec6bae8242ca041d0..8742663d7ebf40ba711445f9607cd5a1704eee0d 100644 (file)
@@ -131,12 +131,10 @@ public:
     ///
     /// Finally, all the SQL commands are pre-compiled.
     ///
-    /// @param id the forensic backend manager ID.
-    ///
     /// @throw isc::db::DbOpenError Error opening the database
     /// @throw isc::db::DbOperationError An operation on the open
     ///        database has failed.
-    virtual void open(ManagerID id = 0);
+    virtual void open();
 
     /// @brief Closes the store.
     virtual void close();
index 75801bff29c97a2b811881f42240a85481e2c2a3..95b747eaca7b86a2e52fcfc42e6de2e0badd712c 100644 (file)
@@ -506,10 +506,7 @@ PgSqlLegalLogDbLostCallbackTest::testRetryOpenDbLostAndRecoveredCallback() {
     std::shared_ptr<DbConnectionInitWithRetry> dbr(new DbConnectionInitWithRetry());
     params.emplace("retry-on-startup", "true");
 
-    ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new PgSqlStore(params)));
-
-    // Check params validity is done by open().
-    EXPECT_THROW(LegalLogMgrFactory::instance()->open(), DbOpenErrorWithRetry);
+    ASSERT_THROW(LegalLogMgrFactory::addBackend(params), DbOpenErrorWithRetry);
 
     // Verify there is no instance.
     ASSERT_FALSE(LegalLogMgrFactory::instance());
@@ -550,10 +547,7 @@ PgSqlLegalLogDbLostCallbackTest::testRetryOpenDbLostAndFailedCallback() {
     std::shared_ptr<DbConnectionInitWithRetry> dbr(new DbConnectionInitWithRetry());
     params.emplace("retry-on-startup", "true");
 
-    ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new PgSqlStore(params)));
-
-    // Check params validity is done by open().
-    EXPECT_THROW(LegalLogMgrFactory::instance()->open(), DbOpenErrorWithRetry);
+    ASSERT_THROW(LegalLogMgrFactory::addBackend(params), DbOpenErrorWithRetry);
 
     // Verify there is no instance.
     ASSERT_FALSE(LegalLogMgrFactory::instance());
@@ -594,10 +588,7 @@ PgSqlLegalLogDbLostCallbackTest::testRetryOpenDbLostAndRecoveredAfterTimeoutCall
     std::shared_ptr<DbConnectionInitWithRetry> dbr(new DbConnectionInitWithRetry());
     params.emplace("retry-on-startup", "true");
 
-    ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new PgSqlStore(params)));
-
-    // Check params validity is done by open().
-    EXPECT_THROW(LegalLogMgrFactory::instance()->open(), DbOpenErrorWithRetry);
+    ASSERT_THROW(LegalLogMgrFactory::addBackend(params), DbOpenErrorWithRetry);
 
     // Verify there is no instance.
     ASSERT_FALSE(LegalLogMgrFactory::instance());
@@ -666,10 +657,7 @@ PgSqlLegalLogDbLostCallbackTest::testRetryOpenDbLostAndFailedAfterTimeoutCallbac
     std::shared_ptr<DbConnectionInitWithRetry> dbr(new DbConnectionInitWithRetry());
     params.emplace("retry-on-startup", "true");
 
-    ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new PgSqlStore(params)));
-
-    // Check params validity is done by open().
-    EXPECT_THROW(LegalLogMgrFactory::instance()->open(), DbOpenErrorWithRetry);
+    ASSERT_THROW(LegalLogMgrFactory::addBackend(params), DbOpenErrorWithRetry);
 
     // Verify there is no instance.
     ASSERT_FALSE(LegalLogMgrFactory::instance());
@@ -725,10 +713,7 @@ PgSqlLegalLogDbLostCallbackTest::testNoCallbackOnOpenFailure() {
     // Verify that a PgSqlStore with no database name is rejected.
     DatabaseConnection::ParameterMap params = db::DatabaseConnection::parse(invalidConnectString());
 
-    ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new PgSqlStore(params)));
-
-    // Check params validity is done by open().
-    EXPECT_THROW(LegalLogMgrFactory::instance()->open(), DbOpenError);
+    ASSERT_THROW(LegalLogMgrFactory::addBackend(params), DbOpenError);
 
     io_service_->poll();
 
@@ -763,11 +748,7 @@ PgSqlLegalLogDbLostCallbackTest::testDbLostAndRecoveredCallback() {
     // Verify that a PgSqlStore with database name is not rejected.
     DatabaseConnection::ParameterMap params = db::DatabaseConnection::parse(validConnectString());
 
-    ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new PgSqlStore(params)));
-    LegalLogMgrFactory::setParameters(params);
-
-    // Check params validity is done by open().
-    EXPECT_NO_THROW_LOG(LegalLogMgrFactory::instance()->open());
+    ASSERT_NO_THROW(LegalLogMgrFactory::addBackend(params));
 
     ASSERT_TRUE(LegalLogMgrFactory::instance());
 
@@ -821,10 +802,7 @@ PgSqlLegalLogDbLostCallbackTest::testDbLostAndFailedCallback() {
     // Verify that a PgSqlStore with database name is not rejected.
     DatabaseConnection::ParameterMap params = db::DatabaseConnection::parse(validConnectString());
 
-    ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new PgSqlStore(params)));
-
-    // Check params validity is done by open().
-    EXPECT_NO_THROW_LOG(LegalLogMgrFactory::instance()->open());
+    ASSERT_NO_THROW(LegalLogMgrFactory::addBackend(params));
 
     ASSERT_TRUE(LegalLogMgrFactory::instance());
 
@@ -885,11 +863,7 @@ PgSqlLegalLogDbLostCallbackTest::testDbLostAndRecoveredAfterTimeoutCallback() {
     // Verify that a PgSqlStore with database name is not rejected.
     DatabaseConnection::ParameterMap params = db::DatabaseConnection::parse(access);
 
-    ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new PgSqlStore(params)));
-    LegalLogMgrFactory::setParameters(params);
-
-    // Check params validity is done by open().
-    EXPECT_NO_THROW_LOG(LegalLogMgrFactory::instance()->open());
+    ASSERT_NO_THROW(LegalLogMgrFactory::addBackend(params));
 
     ASSERT_TRUE(LegalLogMgrFactory::instance());
 
@@ -979,10 +953,7 @@ PgSqlLegalLogDbLostCallbackTest::testDbLostAndFailedAfterTimeoutCallback() {
     // Verify that a PgSqlStore with database name is not rejected.
     DatabaseConnection::ParameterMap params = db::DatabaseConnection::parse(access);
 
-    ASSERT_NO_THROW_LOG(LegalLogMgrFactory::instance().reset(new PgSqlStore(params)));
-
-    // Check params validity is done by open().
-    EXPECT_NO_THROW_LOG(LegalLogMgrFactory::instance()->open());
+    ASSERT_NO_THROW(LegalLogMgrFactory::addBackend(params));
 
     ASSERT_TRUE(LegalLogMgrFactory::instance());
 
index c1a5a46bb62c14a9a0ebf84f0dfca021dee363e7..6abeb3fe645cb0dd849606a93de432649c87b3fd 100644 (file)
@@ -35,9 +35,6 @@ class LegalLogMgr;
 /// @brief Defines a smart pointer to a LegalLogMgr.
 typedef boost::shared_ptr<LegalLogMgr> LegalLogMgrPtr;
 
-/// @brief Manger ID used by hook libraries to retrieve respective LegalLogMgr instance.
-typedef uint64_t ManagerID;
-
 /// @brief LegalLogMgr abstract class
 class LegalLogMgr {
 public:
@@ -87,9 +84,7 @@ public:
     static void parseExtraParameters(const isc::data::ConstElementPtr& parameters, isc::db::DatabaseConnection::ParameterMap& map);
 
     /// @brief Opens the store.
-    ///
-    /// @param id the forensic backend manager ID.
-    virtual void open(ManagerID id = 0) = 0;
+    virtual void open() = 0;
 
     /// @brief Closes the store.
     virtual void close() = 0;
@@ -272,6 +267,9 @@ private:
     isc::db::DatabaseConnection::ParameterMap parameters_;
 };
 
+/// @brief Manger ID used by hook libraries to retrieve respective LegalLogMgr instance.
+typedef uint64_t ManagerID;
+
 /// @brief LegalLogMgr pool
 typedef std::map<ManagerID, std::pair<isc::db::DatabaseConnection::ParameterMap, LegalLogMgrPtr>> LegalLogMgrPool;
 
index 2590aa7ba1e14e5863077dda8b51840734304060..20ff27f6d923b43ee4ec44a8187eed13feb73caa 100644 (file)
@@ -104,7 +104,7 @@ LegalLogMgrFactory::addBackend(DatabaseConnection::ParameterMap& parameters, Man
     // Add the parameters and an empty instance in case retry on startup is configured.
     pool_[id] = pair<DatabaseConnection::ParameterMap, LegalLogMgrPtr>(parameters, LegalLogMgrPtr());
 
-    backend->open(id);
+    backend->open();
 
     // Apply extra parameters.
     if (parameters.find("request-parser-format") != parameters.end()) {
index 970c67204787a38446b1ca3c85f40df8146db684..dfa7bab397c906b425eb9f2ea9092db49dc09de9 100644 (file)
@@ -38,7 +38,7 @@ public:
     }
 
     /// @brief Opens the store.
-    virtual void open(ManagerID) {
+    virtual void open() {
     }
 
     /// @brief Closes the store.