Skip to content

Commit

Permalink
[#3536] addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Razvan Becheriu committed Sep 11, 2024
1 parent f7329af commit f269180
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/lib/dhcpsrv/lease_mgr_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ LeaseMgrFactory::create(const std::string& dbaccess) {
LeaseMgrFactory::registerFactory("postgresql", pgsql_factory, true);
#endif

if (parameters[type] == string("memfile")) {
LOG_INFO(dhcpsrv_logger, DHCPSRV_MEMFILE_DB).arg(redacted);
getLeaseMgrPtr().reset(new Memfile_LeaseMgr(parameters));
return;
}
// Factory method
auto memfile_factory = [](const DatabaseConnection::ParameterMap& parameters) -> TrackingLeaseMgrPtr {
LOG_INFO(dhcpsrv_logger, DHCPSRV_MEMFILE_DB)
.arg(DatabaseConnection::redactedAccessString(parameters));
return (TrackingLeaseMgrPtr(new Memfile_LeaseMgr(parameters)));
};
LeaseMgrFactory::registerFactory("memfile", memfile_factory, true);

string db_type = it->second;
auto index = map_.find(db_type);
Expand Down Expand Up @@ -121,6 +123,7 @@ LeaseMgrFactory::destroy() {
.arg(getLeaseMgrPtr()->getType());
}
getLeaseMgrPtr().reset();
LeaseMgrFactory::deregisterFactory("memfile", true);
// Code will be moved to appropriate hook library.
#ifdef HAVE_MYSQL
LeaseMgrFactory::deregisterFactory("mysql", true);
Expand Down Expand Up @@ -152,7 +155,7 @@ LeaseMgrFactory::recreate(const std::string& dbaccess, bool preserve_callbacks)

bool
LeaseMgrFactory::haveInstance() {
return (getLeaseMgrPtr().get());
return (!!getLeaseMgrPtr());
}

TrackingLeaseMgr&
Expand Down

0 comments on commit f269180

Please sign in to comment.