Skip to content

Commit 6419c57

Browse files
author
Razvan Becheriu
committed
[#3449] clean up on destructor
1 parent 0fe6f2e commit 6419c57

File tree

7 files changed

+16
-26
lines changed

7 files changed

+16
-26
lines changed

src/bin/dhcp4/tests/dhcp4_test_utils.h

+1-10
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,7 @@ class NakedDhcpv4Srv: public Dhcpv4Srv {
209209
fake_received_.push_back(pkt);
210210
}
211211

212-
virtual ~NakedDhcpv4Srv() {
213-
// Close the lease database
214-
isc::dhcp::LeaseMgrFactory::destroy();
215-
216-
getIOService()->restart();
217-
try {
218-
getIOService()->poll();
219-
} catch (...) {
220-
}
221-
}
212+
virtual ~NakedDhcpv4Srv() = default;
222213

223214
/// @brief Runs processing DHCPDISCOVER.
224215
///

src/bin/dhcp6/tests/dhcp6_test_utils.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,7 @@ class NakedDhcpv6Srv: public isc::dhcp::Dhcpv6Srv {
216216
fake_received_.push_back(pkt);
217217
}
218218

219-
virtual ~NakedDhcpv6Srv() {
220-
// Close the lease database
221-
isc::dhcp::LeaseMgrFactory::destroy();
222-
getIOService()->stopAndPoll();
223-
}
219+
virtual ~NakedDhcpv6Srv() = default;
224220

225221
/// @brief Processes incoming Solicit message.
226222
///

src/hooks/dhcp/high_availability/ha_callouts.cc

+1-4
Original file line numberDiff line numberDiff line change
@@ -429,11 +429,8 @@ int load(LibraryHandle& handle) {
429429
/// @return 0 if deregistration was successful, 1 otherwise
430430
int unload() {
431431
if (impl) {
432-
IOServicePtr io_service = impl->getIOService();
433-
IOServiceMgr::instance().unregisterIOService(io_service);
434-
io_service->stopAndPoll();
432+
IOServiceMgr::instance().unregisterIOService(impl->getIOService());
435433
impl.reset();
436-
io_service->stopAndPoll();
437434
}
438435
LOG_INFO(ha_logger, HA_DEINIT_OK);
439436
return (0);

src/hooks/dhcp/high_availability/ha_impl.cc

+3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ HAImpl::~HAImpl() {
6666
// than relying on destruction order.
6767
service->stopClientAndListener();
6868
}
69+
config_.reset();
70+
services_.reset(new HAServiceMapper());
71+
io_service_->stopAndPoll();
6972
}
7073

7174
void

src/hooks/dhcp/high_availability/ha_impl.h

-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ class HAImpl : public boost::noncopyable {
245245

246246
/// @brief Pointer to the high availability services (state machines).
247247
HAServiceMapperPtr services_;
248-
249248
};
250249

251250
/// @brief Pointer to the High Availability hooks library implementation.

src/hooks/dhcp/mysql_cb/mysql_cb_callouts.cc

+5-3
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,11 @@ int unload() {
9494
// Unregister the factories and remove MySQL backends
9595
isc::dhcp::MySqlConfigBackendDHCPv4::unregisterBackendType();
9696
isc::dhcp::MySqlConfigBackendDHCPv6::unregisterBackendType();
97-
IOServiceMgr::instance().unregisterIOService(isc::dhcp::MySqlConfigBackendImpl::getIOService());
98-
if (isc::dhcp::MySqlConfigBackendImpl::getIOService()) {
99-
isc::dhcp::MySqlConfigBackendImpl::getIOService()->stopAndPoll();
97+
IOServicePtr io_service = isc::dhcp::MySqlConfigBackendImpl::getIOService();
98+
if (io_service) {
99+
IOServiceMgr::instance().unregisterIOService(io_service);
100+
io_service->stopAndPoll();
101+
isc::dhcp::MySqlConfigBackendImpl::setIOService(IOServicePtr());
100102
}
101103
return (0);
102104
}

src/hooks/dhcp/pgsql_cb/pgsql_cb_callouts.cc

+5-3
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,11 @@ int unload() {
9494
// Unregister the factories and remove PostgreSQL backends
9595
isc::dhcp::PgSqlConfigBackendDHCPv4::unregisterBackendType();
9696
isc::dhcp::PgSqlConfigBackendDHCPv6::unregisterBackendType();
97-
IOServiceMgr::instance().unregisterIOService(isc::dhcp::PgSqlConfigBackendImpl::getIOService());
98-
if (isc::dhcp::PgSqlConfigBackendImpl::getIOService()) {
99-
isc::dhcp::PgSqlConfigBackendImpl::getIOService()->stopAndPoll();
97+
IOServicePtr io_service = isc::dhcp::PgSqlConfigBackendImpl::getIOService();
98+
if (io_service) {
99+
IOServiceMgr::instance().unregisterIOService(io_service);
100+
io_service->stopAndPoll();
101+
isc::dhcp::PgSqlConfigBackendImpl::setIOService(IOServicePtr());
100102
}
101103
return (0);
102104
}

0 commit comments

Comments
 (0)