@@ -77,11 +77,13 @@ LeaseMgrFactory::create(const std::string& dbaccess) {
77
77
LeaseMgrFactory::registerFactory (" postgresql" , pgsql_factory, true );
78
78
#endif
79
79
80
- if (parameters[type] == string (" memfile" )) {
81
- LOG_INFO (dhcpsrv_logger, DHCPSRV_MEMFILE_DB).arg (redacted);
82
- getLeaseMgrPtr ().reset (new Memfile_LeaseMgr (parameters));
83
- return ;
84
- }
80
+ // Factory method
81
+ auto memfile_factory = [](const DatabaseConnection::ParameterMap& parameters) -> TrackingLeaseMgrPtr {
82
+ LOG_INFO (dhcpsrv_logger, DHCPSRV_MEMFILE_DB)
83
+ .arg (DatabaseConnection::redactedAccessString (parameters));
84
+ return (TrackingLeaseMgrPtr (new Memfile_LeaseMgr (parameters)));
85
+ };
86
+ LeaseMgrFactory::registerFactory (" memfile" , memfile_factory, true );
85
87
86
88
string db_type = it->second ;
87
89
auto index = map_.find (db_type);
@@ -121,6 +123,7 @@ LeaseMgrFactory::destroy() {
121
123
.arg (getLeaseMgrPtr ()->getType ());
122
124
}
123
125
getLeaseMgrPtr ().reset ();
126
+ LeaseMgrFactory::deregisterFactory (" memfile" , true );
124
127
// Code will be moved to appropriate hook library.
125
128
#ifdef HAVE_MYSQL
126
129
LeaseMgrFactory::deregisterFactory (" mysql" , true );
@@ -152,7 +155,7 @@ LeaseMgrFactory::recreate(const std::string& dbaccess, bool preserve_callbacks)
152
155
153
156
bool
154
157
LeaseMgrFactory::haveInstance () {
155
- return (getLeaseMgrPtr (). get ());
158
+ return (!! getLeaseMgrPtr ());
156
159
}
157
160
158
161
TrackingLeaseMgr&
0 commit comments